:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9e1ea;
  --blue: #0f62fe;
  --blue-dark: #0b4bc1;
  --green: #16833a;
  --yellow: #936d00;
  --red: #c7332f;
  --neutral: #5d6673;
  --shadow: 0 10px 30px rgba(22, 34, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  text-decoration: none;
}

.brand {
  min-width: 0;
}

.brand span:last-child {
  overflow-wrap: anywhere;
}

.brand-mark {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-weight: 800;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.mobile-menu-toggle,
.mobile-menu-session,
.mobile-logout-form {
  display: none;
}

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

.sidebar {
  padding: 20px 12px;
  background: #eef2f6;
  border-right: 1px solid var(--line);
}

.sidebar ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar a {
  display: block;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #344054;
  text-decoration: none;
}

.sidebar a.active,
.sidebar a:hover {
  background: var(--panel);
  color: var(--blue);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.content {
  width: min(1180px, 100%);
  padding: 28px;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-heading h1,
.login-brand h1,
.legal-page h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, 180px);
  gap: 10px;
  margin-bottom: 16px;
}

.dashboard-toolbar {
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(0, 1fr)) minmax(0, 140px) minmax(0, 170px);
}

.dashboard-toolbar label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.dashboard-toolbar .button {
  align-self: end;
}

.employee-toolbar {
  grid-template-columns: minmax(220px, 1fr) 220px 120px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  font: inherit;
}

input:disabled,
select:disabled {
  color: #98a2b3;
  background: #f8fafc;
}

.button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button-primary {
  width: 100%;
  min-height: 48px;
  background: var(--blue);
  color: white;
}

.button-primary:hover {
  background: var(--blue-dark);
}

.button-secondary {
  background: #edf2f7;
  color: #344054;
}

.button-danger {
  background: var(--red);
  color: white;
}

.button-danger:hover {
  background: #9f2825;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  text-decoration: none;
}

.card-list {
  display: grid;
  gap: 12px;
}

.card,
.empty-state,
.metric,
.login-panel,
.legal-page {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card,
.empty-state,
.metric {
  padding: 18px;
}

.card-clickable {
  cursor: pointer;
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.card-link:hover {
  border-color: #9bbcff;
}

.admin-order-card {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.admin-card-badges {
  margin-top: -4px;
}

.admin-card-meta {
  margin-top: 0;
}

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

.card-header > div {
  min-width: 0;
}

.card h2,
.card h3,
.empty-state h2,
.metric h2 {
  margin: 0 0 6px;
  font-size: 19px;
}

.card p,
.empty-state p,
.metric p {
  margin: 0;
  color: var(--muted);
}

.admin-order-card h2,
.admin-order-card p,
.admin-card-meta dd {
  overflow-wrap: anywhere;
}

.date {
  font-weight: 700;
  color: var(--blue) !important;
}

.badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-neutral {
  background: #edf2f7;
  color: var(--neutral);
}

.badge-blue {
  background: #e8f0ff;
  color: var(--blue-dark);
}

.badge-green {
  background: #e7f6eb;
  color: var(--green);
}

.badge-yellow {
  background: #fff4d6;
  color: #7a5200;
}

.badge-red {
  background: #fff1f0;
  color: var(--red);
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.meta-list dt {
  color: var(--muted);
  font-size: 13px;
}

.meta-list dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat( auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.employee-detail-grid,
.action-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.employee-panel,
.employee-action-card {
  min-width: 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.employee-panel h2,
.employee-action-card h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.employee-panel p,
.employee-action-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.employee-panel .button {
  width: 100%;
  justify-content: center;
  margin-bottom: 10px;
}

.contact-line {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.contact-line:last-child {
  border-bottom: 0;
}

.contact-line a {
  overflow-wrap: anywhere;
}

.compact-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.compact-list div {
  display: grid;
  gap: 3px;
}

.compact-list dt {
  font-size: .8rem;
  color: var(--muted);
}

.compact-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.employee-action-card {
  border-style: dashed;
}

.employee-action-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-style: solid;
}

.employee-action-card span {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.sync-panel,
.draft-restore {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 6px solid var(--neutral);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.draft-restore {
  grid-template-columns: minmax(0, 1fr) auto;
}

.sync-panel h2,
.draft-restore h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.sync-panel p,
.draft-restore p {
  margin: 0;
  color: var(--muted);
}

.sync-panel .button {
  white-space: nowrap;
}

.sync-indicator {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--neutral);
}

.sync-panel-green {
  border-left-color: var(--green);
}

.sync-panel-green .sync-indicator {
  background: var(--green);
}

.sync-panel-yellow {
  border-left-color: var(--yellow);
}

.sync-panel-yellow .sync-indicator {
  background: var(--yellow);
}

.sync-panel-red {
  border-left-color: var(--red);
}

.sync-panel-red .sync-indicator {
  background: var(--red);
}

.sync-device-note,
.sync-connection-note {
  margin-top: 6px !important;
  font-weight: 700;
}

.local-data-dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 41, 51, 0.42);
}

.local-data-dialog[hidden] {
  display: none;
}

.local-data-dialog-card {
  width: min(560px, 100%);
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.local-data-dialog-card h2 {
  margin: 0 0 10px;
}

.local-data-dialog-card p {
  margin: 8px 0 0;
}

.action-row,
.card-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.card-actions {
  margin-top: 16px;
}

.section-block {
  margin-top: 28px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 22px;
}

.form-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.form-card label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.form-card textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

.field-hint {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.notice-list {
  display: grid;
  gap: 8px;
}

.pilot-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 18px;
  margin: 0;
  padding-left: 22px;
}

.pilot-checklist li {
  padding: 4px 0;
  font-weight: 700;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

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

.confirmation-row {
  align-items: flex-start;
  font-weight: 700;
}

.photo-placeholder,
.danger-card {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.photo-upload {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.photo-picker {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  cursor: pointer;
}

.photo-picker input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  opacity: 0;
}

.photo-preview,
.photo-existing,
.defect-thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.photo-existing,
.photo-preview {
  min-height: 180px;
}

.photo-preview img,
.photo-existing img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.photo-preview span,
.photo-error {
  color: var(--muted);
  font-weight: 700;
}

.photo-error {
  margin: 0;
  color: var(--red);
}

.defect-card-layout {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 16px;
}

.defect-thumb {
  width: 132px;
  height: 132px;
}

.defect-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.defect-thumb span {
  padding: 10px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.photo-placeholder h2,
.danger-card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.photo-placeholder p,
.photo-placeholder span,
.danger-card p {
  margin: 0;
  color: var(--muted);
}

.defect-card.is-cancelled {
  background: #f8fafc;
  border-style: dashed;
}

.sub-title {
  margin-top: 18px;
}

.choice-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.choice-group legend {
  padding: 0 6px;
  font-weight: 800;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px !important;
  min-height: 36px;
  font-weight: 600 !important;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

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

.span-2 {
  grid-column: 1 / -1;
}

.alert-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.alert-list p {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff1f0;
  color: var(--red);
  font-weight: 700;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 24px;
  font-weight: 800;
}

.metric-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.metric-link:hover {
  border-color: #9bbcff;
}

.export-status-card,
.export-check-card,
.export-type-card {
  min-width: 0;
}

.export-check-list {
  gap: 10px;
}

.export-message {
  border-left: 6px solid var(--neutral);
}

.export-message p,
.export-message-list {
  margin: 0;
}

.export-message-list {
  display: grid;
  gap: 6px;
  padding-left: 20px;
  color: var(--muted);
}

.export-message-blocker {
  border-left-color: var(--red);
}

.export-message-warning {
  border-left-color: var(--yellow);
}

.export-type-card {
  display: grid;
  gap: 14px;
}

.export-type-card .button:disabled {
  cursor: not-allowed;
  opacity: .72;
}

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

.login-panel {
  width: min(440px, 100%);
  padding: 24px;
}

.login-brand {
  align-items: flex-start;
  margin-bottom: 18px;
}

.login-brand p,
.notice {
  margin: 4px 0 0;
  color: var(--muted);
}

.notice {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff1f0;
  color: var(--red);
  font-weight: 700;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
  color: var(--muted);
}

.portal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.legal-page {
  width: min(760px, calc(100% - 40px));
  margin: 40px auto;
  padding: 24px;
}

.back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--blue);
  font-weight: 700;
}

@media (max-width: 820px) {
  body {
    overflow-x: hidden;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  body.mobile-nav-open::before {
    position: fixed;
    inset: 64px 0 0;
    z-index: 15;
    background: rgba(31, 41, 51, 0.32);
    content: "";
  }

  .topbar {
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 10px 14px;
  }

  .brand {
    flex: 1 1 auto;
    font-size: 0.95rem;
  }

  .desktop-session {
    display: none;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-menu-toggle:focus-visible,
  .sidebar a:focus-visible,
  .mobile-logout-form .button:focus-visible {
    outline: 3px solid rgba(15, 98, 254, 0.28);
    outline-offset: 2px;
  }

  .hamburger-lines,
  .hamburger-lines::before,
  .hamburger-lines::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
  }

  .hamburger-lines {
    position: relative;
  }

  .hamburger-lines::before,
  .hamburger-lines::after {
    position: absolute;
    left: 0;
    content: "";
  }

  .hamburger-lines::before {
    top: -6px;
  }

  .hamburger-lines::after {
    top: 6px;
  }

  .shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 64px;
    right: 0;
    bottom: 0;
    z-index: 20;
    width: min(320px, calc(100vw - 32px));
    padding: 16px;
    overflow-y: auto;
    transform: translateX(100%);
    border-right: 0;
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow);
    transition: transform 160ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .mobile-menu-session {
    display: block;
    margin-bottom: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-weight: 700;
  }

  .sidebar ul {
    display: grid;
    gap: 8px;
    min-width: 0;
  }

  .sidebar a {
    min-height: 48px;
    padding: 12px 14px;
    font-weight: 700;
  }

  .mobile-logout-form {
    display: block;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }

  .mobile-logout-form .button {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .content {
    padding: 18px;
  }

  .page-heading,
  .card-header {
    flex-direction: column;
  }

  .toolbar,
  .dashboard-toolbar,
  .employee-toolbar,
  .meta-list,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .action-row,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .sync-panel,
  .draft-restore {
    grid-template-columns: 1fr;
  }

  .sync-panel .button,
  .draft-restore .button {
    width: 100%;
  }

  .defect-card-layout {
    grid-template-columns: 1fr;
  }

  .defect-thumb {
    width: 100%;
    height: 180px;
  }
}
