:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #edf3f1;
  --ink: #17211f;
  --muted: #65736f;
  --line: #d9e2df;
  --brand: #0d766e;
  --brand-2: #1f9d89;
  --accent: #d98324;
  --danger: #b84032;
  --radius: 8px;
  --shadow: 0 18px 45px rgba(16, 32, 29, .09);
  --shadow-soft: 0 8px 22px rgba(16, 32, 29, .06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button,
a,
input,
select,
textarea {
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease, color .16s ease, transform .16s ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(31, 157, 137, .25);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #102521;
  color: #f4fbf8;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--brand-2);
  color: #ffffff;
  font-weight: 800;
}

.brand span,
.privacy-note span,
.eyebrow,
small {
  display: block;
  color: var(--muted);
  font-size: .82rem;
}

.sidebar .brand span,
.privacy-note span {
  color: #a7bbb5;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item,
.mobile-nav button,
.mobile-nav a {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
}

.nav-item {
  display: block;
  padding: 12px 13px;
  border-radius: var(--radius);
  color: #cde0dc;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, .1);
  color: #ffffff;
}

.privacy-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius);
}

.privacy-note a {
  display: inline-block;
  margin-top: 10px;
  color: #ffffff;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  display: grid;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card form,
.stack-form {
  display: grid;
  gap: 13px;
}

.compact-form {
  margin-top: 14px;
}

.panel-separator {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.alert,
.notice,
.empty-state {
  margin: 0;
  border-radius: var(--radius);
  padding: 12px 14px;
}

.alert {
  background: #fff0ed;
  color: var(--danger);
}

.notice {
  margin-bottom: 16px;
  background: #e7f5ee;
  color: #126445;
  font-weight: 700;
}

.notice input,
.setup-link-box input {
  margin-top: 10px;
  font-weight: 500;
}

.empty-state {
  border: 1px dashed var(--line);
  background: #fbfdfc;
  color: var(--muted);
}

.workspace {
  min-width: 0;
  padding: 28px;
  max-width: 1480px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.05rem;
}

.top-actions,
.panel-header,
.form-actions,
.summary-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-switch {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.language-switch a {
  min-height: 32px;
  min-width: 40px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
  text-decoration: none;
}

.language-switch a.active {
  background: var(--brand);
  color: #ffffff;
}

.auth-language {
  justify-self: start;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
}

.search span {
  color: var(--muted);
  font-size: .85rem;
}

.search input {
  border: 0;
  outline: 0;
  min-width: 210px;
}

.icon-button,
.primary-action,
.ghost-button,
.segmented button,
.day {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  min-height: 40px;
}

.icon-button {
  width: 42px;
  background: var(--surface);
}

.icon-button:hover,
.ghost-button:hover,
.day:hover {
  border-color: #a7bbb5;
  box-shadow: var(--shadow-soft);
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--brand);
  color: #ffffff;
  padding: 0 16px;
  font-weight: 700;
  text-decoration: none;
}

.primary-action:hover {
  background: #0a625b;
  transform: translateY(-1px);
}

.primary-action.compact,
.ghost-button {
  min-height: 36px;
  padding: 0 12px;
}

.ghost-button {
  background: var(--surface);
  color: var(--ink);
}

.context-strip {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr .7fr;
  gap: 10px;
  margin-bottom: 18px;
}

.context-strip div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .78);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
}

.context-strip span,
.inline-control,
.field-hint {
  color: var(--muted);
  font-size: .8rem;
}

.context-strip strong {
  display: block;
  margin-top: 3px;
  font-size: .92rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid,
.machine-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel,
.machine-card,
.ticket-card,
.customer-card,
.document-card,
.schedule-item,
.team-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric,
.panel {
  backdrop-filter: saturate(1.08);
}

.metric {
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto 16px 0 16px;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: var(--brand-2);
}

.metric strong {
  display: block;
  font-size: 2rem;
  margin: 8px 0 2px;
}

.metric.warning strong {
  color: var(--danger);
}

.panel {
  padding: 18px;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 16px;
}

.inline-control {
  width: min(210px, 100%);
  gap: 5px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
}

select:hover,
input:hover,
textarea:hover {
  border-color: #b6c7c2;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(31, 157, 137, .12);
  outline: 0;
}

textarea {
  resize: vertical;
}

.dashboard-layout,
.split-layout,
.planner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .9fr);
  gap: 16px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, .75fr);
  gap: 16px;
}

.audit-panel {
  grid-column: 1 / -1;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfc;
}

.inline-form {
  display: inline;
}

.danger-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #e5b7af;
  border-radius: var(--radius);
  background: #fff0ed;
  color: var(--danger);
  font-weight: 700;
}

.danger-button:hover {
  border-color: var(--danger);
}

.muted-text {
  color: var(--muted);
  font-size: .85rem;
}

.ticket-list,
.customer-list,
.document-list,
.schedule,
.team-list {
  display: grid;
  gap: 10px;
}

.ticket-card,
.customer-card,
.document-card,
.schedule-item,
.team-card,
.machine-card {
  padding: 14px;
}

.ticket-card:hover,
.customer-card:hover,
.document-card:hover,
.schedule-item:hover,
.team-card:hover,
.machine-card:hover {
  border-color: #b6c7c2;
  box-shadow: var(--shadow-soft);
}

.ticket-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  box-shadow: none;
}

.ticket-meta,
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.status,
.tag-row span,
.ticket-meta span,
.card-meta span,
.photo-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--surface-2);
  color: #31433f;
  font-size: .78rem;
  white-space: nowrap;
}

.status.work {
  background: #e7f5ee;
  color: #126445;
}

.status.wait {
  background: #fff0da;
  color: #8c4f0f;
}

.status.done {
  background: #e7f5ee;
  color: #126445;
}

.status {
  font-weight: 700;
}

.machine-focus {
  overflow: hidden;
}

.machine-visual {
  position: relative;
  height: 172px;
  margin: 2px 0 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #dce9e4, #f9fbfa);
  display: grid;
  place-items: center;
}

.machine-body {
  width: 122px;
  height: 116px;
  border-radius: 7px;
  background: #c2d2cd;
  border: 5px solid #edf3f1;
  box-shadow: inset 0 -16px 0 rgba(0, 0, 0, .08);
}

.machine-display {
  position: absolute;
  width: 44px;
  height: 28px;
  border-radius: 4px;
  background: var(--brand);
  transform: translateY(-18px);
}

.machine-base {
  position: absolute;
  bottom: 35px;
  width: 158px;
  height: 12px;
  border-radius: 999px;
  background: #7d918b;
}

.timeline {
  display: grid;
  gap: 13px;
}

.timeline div {
  display: grid;
  grid-template-columns: 18px 1fr;
  column-gap: 10px;
}

.timeline span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand-2);
  margin-top: 6px;
}

.data-list {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
}

.data-list div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.machine-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0;
}

.machine-card {
  min-height: 180px;
  display: grid;
  align-content: space-between;
  box-shadow: none;
}

.machine-card header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.serial {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: .82rem;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

tbody tr:hover {
  background: #f8fbfa;
}

.calendar-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.day {
  background: var(--surface-2);
  padding: 10px;
}

.day.active {
  background: var(--brand);
  color: #ffffff;
}

.day span,
.day strong {
  display: block;
}

.schedule-item {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 12px;
  align-items: center;
  box-shadow: none;
}

.team-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: none;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-weight: 800;
}

.report-form {
  display: grid;
  gap: 16px;
}

.report-progress {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.report-progress div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfc;
  color: var(--muted);
}

.report-progress span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b9c8c4;
}

.report-progress .done {
  color: var(--ink);
  border-color: #b9ddd4;
  background: #eef8f5;
}

.report-progress .done span {
  background: var(--brand);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  min-height: 31px;
  border: 0;
  background: transparent;
  padding: 0 10px;
}

.segmented .active {
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(0, 0, 0, .08);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.single {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .86rem;
}

.field-hint {
  font-weight: 500;
}

label input,
label select,
label textarea {
  color: var(--ink);
  font-size: .95rem;
}

.summary-bar {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.summary-bar span {
  color: var(--muted);
}

.upload-zone {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
  margin-top: 14px;
}

.quick-capture {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.quick-capture button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: #263632;
  font-weight: 700;
}

.quick-capture button:hover {
  border-color: var(--brand-2);
  background: #e7f5ee;
}

.file-drop {
  min-height: 118px;
  border: 1px dashed #9fb2ad;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  text-align: center;
  background: #fbfdfc;
}

.file-drop:hover {
  border-color: var(--brand-2);
  background: #f2faf7;
}

.file-drop input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-drop span {
  color: var(--ink);
  font-weight: 800;
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 8px;
}

canvas {
  width: 100%;
  height: 180px;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: repeating-linear-gradient(0deg, #fff, #fff 38px, #f5f8f7 39px);
  touch-action: none;
}

canvas:focus {
  outline: 3px solid rgba(31, 157, 137, .25);
}

.signature-panel .form-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.document-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  box-shadow: none;
}

.chart-bars {
  height: 280px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: end;
  padding-top: 20px;
}

.chart-bars div {
  height: var(--value);
  min-height: 40px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  display: flex;
  align-items: end;
  justify-content: center;
  padding: 8px 4px;
  color: #ffffff;
  font-size: .8rem;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1120px) {
  .metrics-grid,
  .machine-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-layout,
  .split-layout,
  .planner-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .context-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    padding: 18px 14px 86px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .context-strip {
    margin-bottom: 14px;
  }

  .context-strip div:nth-child(2),
  .context-strip div:nth-child(3) {
    display: none;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .search {
    grid-column: 1 / -1;
  }

  .search input {
    min-width: 0;
  }

  .primary-action {
    min-height: 42px;
  }

  .metrics-grid,
  .machine-grid,
  .form-grid,
  .upload-zone,
  .report-progress,
  .quick-capture {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-header > .segmented,
  .panel-header > .inline-control,
  .panel-header > select,
  .panel-header > button {
    width: 100%;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .ticket-card,
  .schedule-item {
    grid-template-columns: 1fr;
  }

  .calendar-strip {
    overflow-x: auto;
    grid-template-columns: repeat(5, minmax(72px, 1fr));
    padding-bottom: 4px;
  }

  .data-list div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .chart-bars {
    height: 220px;
  }

  h1 {
    font-size: 1.65rem;
  }

  .mobile-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .96);
    box-shadow: var(--shadow);
  }

  .mobile-nav button {
    min-height: 44px;
    text-align: center;
    color: var(--muted);
    border-radius: 6px;
  }

  .mobile-nav a {
    min-height: 44px;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
    border-radius: 6px;
  }

  .mobile-nav button.active,
  .mobile-nav a.active {
    background: var(--brand);
    color: #ffffff;
  }
}

@media print {
  .sidebar,
  .top-actions,
  .mobile-nav,
  .ghost-button,
  .nav-list {
    display: none !important;
  }

  .app-shell,
  .workspace {
    display: block;
    padding: 0;
  }

  .view {
    display: none !important;
  }

  #technician {
    display: block !important;
  }

  .panel {
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 12px;
  }
}
