/* IVAC customer portal — navy brand palette, light + dark themes. */

:root,
[data-theme="light"] {
  --navy-900: #0A1733;
  --navy-800: #0F2147;
  --navy-700: #142C5C;
  --navy-600: #1B3A78;
  --navy-500: #234A9A;
  --navy-400: #3D62B0;
  --navy-300: #6B8AC9;
  --navy-200: #A3B6DD;
  --navy-100: #D4DEF0;
  --navy-50:  #EDF1FA;

  --bg: #F7F9FC;
  --surface: #FFFFFF;
  --text: #0A1733;
  --text-muted: rgba(10, 23, 51, 0.62);
  --border: #A3B6DD;
  --border-soft: #D4DEF0;

  --primary: #142C5C;
  --primary-hover: #0A1733;
  --primary-text: #FFFFFF;
  --accent: #4F9CFF;
  --accent-hover: #3D62B0;

  --success: #2BB673;
  --warning: #E0A800;
  --danger: #E5484D;

  --row-hover: #EDF1FA;
  --input-bg: #FFFFFF;
  --shadow: 0 1px 3px rgba(10, 23, 51, 0.08), 0 4px 16px rgba(10, 23, 51, 0.06);
}

[data-theme="dark"] {
  --bg: #0B1226;
  --surface: #0A1733;
  --text: #EDF1FA;
  --text-muted: rgba(237, 241, 250, 0.62);
  --border: #142C5C;
  --border-soft: #0F2147;

  --primary: #234A9A;
  --primary-hover: #1B3A78;
  --primary-text: #FFFFFF;
  --accent: #4F9CFF;
  --accent-hover: #6B8AC9;

  --row-hover: #0F2147;
  --input-bg: #0F2147;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------------------------------------------------------------- layout */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--navy-700) 0%, var(--navy-900) 100%);
  color: #EDF1FA;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(237, 241, 250, 0.12);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: block;
  object-fit: cover;
}

.brand-mark-lg { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto; }

.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 1px; }
.brand-sub { font-size: 10.5px; color: rgba(237, 241, 250, 0.65); margin-top: 1px; }

.nav { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 4px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 9px;
  color: rgba(237, 241, 250, 0.78);
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: rgba(237, 241, 250, 0.08); color: #FFFFFF; }

.nav-link.active {
  background: var(--navy-500);
  border-left-color: var(--accent);
  color: #FFFFFF;
}

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(237, 241, 250, 0.12); }

.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--navy-500);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }

.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(237, 241, 250, 0.25);
  border-radius: 8px;
  background: transparent;
  color: rgba(237, 241, 250, 0.85);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s;
}

.logout-btn:hover { background: rgba(229, 72, 77, 0.25); border-color: rgba(229, 72, 77, 0.5); color: #FFFFFF; }
.logout-btn svg { width: 15px; height: 15px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-title { font-size: 19px; font-weight: 700; margin: 0; }
.topbar-spacer { flex: 1; }

.content { padding: 28px; width: 100%; }

/* ------------------------------------------------------------- topbar UI */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover { background: var(--row-hover); color: var(--text); }
.icon-btn-danger:hover { background: rgba(229, 72, 77, 0.12); color: var(--danger); }

.menu-btn { display: none; }

/* ------------------------------------------------- collapsible sidebar */

.sidebar { transition: width 0.18s ease; }

/* Collapsed "rail": icons only. Driven by a class on <html> so it can be
   applied before first paint (no flash). Desktop only — on mobile the
   sidebar uses the off-canvas drawer instead. */
@media (min-width: 901px) {
  html.sidebar-collapsed .sidebar { width: 72px; }
  html.sidebar-collapsed .brand-text,
  html.sidebar-collapsed .nav-text,
  html.sidebar-collapsed .user-name,
  html.sidebar-collapsed .logout-text { display: none; }
  html.sidebar-collapsed .brand { justify-content: center; padding: 20px 0; }
  html.sidebar-collapsed .nav-link { justify-content: center; gap: 0; padding: 11px 0; border-left-width: 0; }
  html.sidebar-collapsed .user-chip { justify-content: center; margin-bottom: 0; }
  html.sidebar-collapsed .logout-btn { justify-content: center; padding: 9px 0; }
  html.sidebar-collapsed .logout-btn { margin-top: 10px; }
}

[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-desc { color: var(--text-muted); margin: 0; }

.section-title { font-size: 16px; font-weight: 700; margin: 26px 0 12px; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--bg) 55%, var(--surface));
  white-space: nowrap;
}

td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--row-hover); }

.cell-strong { font-weight: 600; }
/* Two related values share one column, stacked: owner over phone, visa type
   over file count. The second line is quieter so the first still reads first. */
.cell-stack > * { display: block; }
.cell-stack .stack-top { margin-bottom: 2px; }
.cell-stack .stack-sub { font-size: 12.5px; color: var(--text-muted); }
.cell-mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13.5px; }
.muted { color: var(--text-muted); }

.th-actions { text-align: right; }
.td-actions { text-align: right; }
.td-actions form { display: inline-block; margin: 0; }
.td-actions .icon-btn, .td-actions .btn { vertical-align: middle; }

.row-link { color: var(--text); }
.row-link:hover { color: var(--accent); }

.locked { color: var(--text-muted); opacity: 0.7; display: inline-flex; padding: 8px; }
.locked svg { width: 16px; height: 16px; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  background: var(--row-hover);
  color: var(--text);
}

.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-text); }

.btn-accent { background: var(--accent); color: #FFFFFF; }
.btn-accent:hover { background: var(--accent-hover); color: #FFFFFF; }

/* Pay Now link: rich "come pay me" animation until it has been clicked. */
.pay-link:not(.pay-clicked) {
  position: relative;
  overflow: hidden;
  border: none;
  background: linear-gradient(120deg, #4F9CFF, #6FB1FF, #3D7BE0, #4F9CFF);
  background-size: 300% 100%;
  color: #FFFFFF;
  animation: pay-gradient 4s ease infinite, pay-float 2.2s ease-in-out infinite,
             pay-glow 2.2s ease-in-out infinite;
}

/* Moving shine sweep across the surface. */
.pay-link:not(.pay-clicked)::before {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 45%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  animation: pay-shine 2.8s ease-in-out infinite;
}

.pay-link:not(.pay-clicked) svg {
  position: relative;
  animation: pay-nudge 1.6s ease-in-out infinite;
}

.pay-link:not(.pay-clicked):hover {
  animation-play-state: paused;
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 22px rgba(79, 156, 255, 0.55);
}

@keyframes pay-gradient {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes pay-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}

@keyframes pay-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 156, 255, 0.55), 0 4px 12px rgba(79, 156, 255, 0.35); }
  50%      { box-shadow: 0 0 0 8px rgba(79, 156, 255, 0), 0 8px 20px rgba(79, 156, 255, 0.55); }
}

@keyframes pay-shine {
  0%   { left: -60%; }
  60%  { left: 130%; }
  100% { left: 130%; }
}

@keyframes pay-nudge {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(2px, -2px); }
}

@media (prefers-reduced-motion: reduce) {
  .pay-link:not(.pay-clicked),
  .pay-link:not(.pay-clicked)::before,
  .pay-link:not(.pay-clicked) svg { animation: none; }
}

/* Pay Now link, once clicked (persisted per appointment in localStorage):
   burning red — flickering fire gradient + glow, flames rising off the top. */
.pay-link.pay-clicked {
  position: relative;
  z-index: 0;
  overflow: visible;
  border: none;
  background: linear-gradient(180deg, #F97316 0%, #EF4444 50%, #B91C1C 100%);
  background-size: 100% 200%;
  color: #FFFFFF;
  animation: pay-fire-flicker 1.3s ease-in-out infinite;
}
.pay-link.pay-clicked:hover { color: #FFFFFF; filter: brightness(1.1); }

/* Two flame tongues licking up from the top edge. */
.pay-link.pay-clicked::before,
.pay-link.pay-clicked::after {
  content: "";
  position: absolute;
  top: -8px;
  width: 10px;
  height: 14px;
  background: radial-gradient(circle at 50% 85%, #FDE047 0%, #FB923C 45%, #EF4444 70%, rgba(239, 68, 68, 0) 100%);
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
  filter: blur(1.5px);
  pointer-events: none;
  animation: pay-flame-rise 1s ease-in infinite;
}
.pay-link.pay-clicked::before { left: 22%; }
.pay-link.pay-clicked::after { right: 22%; animation-delay: 0.45s; animation-duration: 1.25s; }

@keyframes pay-fire-flicker {
  0%, 100% {
    background-position: 0 0;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.55), 0 0 22px rgba(239, 68, 68, 0.35);
  }
  25% {
    box-shadow: 0 0 16px rgba(249, 115, 22, 0.75), 0 0 30px rgba(239, 68, 68, 0.5);
  }
  50% {
    background-position: 0 60%;
    box-shadow: 0 0 8px rgba(249, 115, 22, 0.45), 0 0 18px rgba(239, 68, 68, 0.3);
  }
  75% {
    box-shadow: 0 0 14px rgba(253, 224, 71, 0.6), 0 0 26px rgba(239, 68, 68, 0.45);
  }
}

@keyframes pay-flame-rise {
  0% { transform: translateY(4px) scaleY(0.6); opacity: 0; }
  30% { opacity: 0.9; }
  100% { transform: translateY(-10px) scaleY(1.15) scaleX(0.7); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pay-link.pay-clicked { animation: none; }
  .pay-link.pay-clicked::before,
  .pay-link.pay-clicked::after { display: none; }
}

/* Pay-window countdown (8 min from when the link landed). */
.pay-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
  background: rgba(79, 156, 255, 0.12);
  color: var(--accent);
  border: 1px solid rgba(79, 156, 255, 0.35);
}
.pay-timer-clock { min-width: 44px; text-align: center; }
.pay-timer.pay-timer-warn {
  background: rgba(245, 158, 11, 0.14);
  color: #B45309;
  border-color: rgba(245, 158, 11, 0.45);
  animation: pay-timer-pulse 1s ease-in-out infinite;
}
.pay-timer.pay-timer-expired {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-muted, #64748B);
  border-color: rgba(148, 163, 184, 0.4);
  animation: none;
}
@keyframes pay-timer-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .pay-timer.pay-timer-warn { animation: none; }
}

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--row-hover); }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }

.btn:disabled, button.btn[disabled] {
  background: var(--border-soft);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.75;
}

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-pending    { background: rgba(224, 168, 0, 0.14);  color: #B68800; }
.badge-processing { background: rgba(79, 156, 255, 0.14); color: #2F7FE0; }
.badge-completed  { background: rgba(43, 182, 115, 0.14); color: #1E9960; }
.badge-paid       { background: rgba(139, 92, 246, 0.14); color: #6D3FD4; }
.badge-cancelled  { background: rgba(229, 72, 77, 0.14);  color: #D63E43; }
.badge-none       { background: var(--border-soft); color: var(--text-muted); }

[data-theme="dark"] .badge-pending    { color: #E0A800; }
[data-theme="dark"] .badge-processing { color: #4F9CFF; }
[data-theme="dark"] .badge-completed  { color: #2BB673; }
[data-theme="dark"] .badge-paid       { color: #A78BFA; }
[data-theme="dark"] .badge-cancelled  { color: #E5484D; }

/* ---------------------------------------------------------------- alerts */

.alerts { margin-bottom: 18px; display: flex; flex-direction: column; gap: 10px; }

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid;
  font-size: 14px;
  font-weight: 500;
}

.alert-success { background: rgba(43, 182, 115, 0.1);  border-color: rgba(43, 182, 115, 0.4);  color: var(--success); }
.alert-error   { background: rgba(229, 72, 77, 0.1);   border-color: rgba(229, 72, 77, 0.4);   color: var(--danger); }
.alert-warning { background: rgba(224, 168, 0, 0.1);   border-color: rgba(224, 168, 0, 0.4);   color: var(--warning); }
.alert-info    { background: rgba(79, 156, 255, 0.1);  border-color: rgba(79, 156, 255, 0.4);  color: var(--accent); }

.alert-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.7;
}
.alert-close:hover { opacity: 1; }

/* ----------------------------------------------------------------- forms */

.form-card { max-width: 560px; padding: 28px; margin-bottom: 18px; }

.form-intro { color: var(--text-muted); margin: 0 0 22px; font-size: 14px; }

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 7px;
}

.field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 156, 255, 0.22);
}

.field input[type="date"] { color-scheme: light; }
[data-theme="dark"] .field input[type="date"] { color-scheme: dark; }

/* Client-side invalid state (e.g. a phone number that isn't a BD mobile). */
.field input.input-invalid { border-color: var(--danger); }
.field input.input-invalid:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.22);
}

.field-error { color: var(--danger); font-size: 13px; margin: 6px 0 0; }
.field-help { color: var(--text-muted); font-size: 12px; margin: 6px 0 0; }

/* Existing attached PDFs shown when editing an appointment. */
.pdf-existing { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pdf-existing-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface);
}
.pdf-existing-icon { width: 18px; height: 18px; color: var(--danger); flex-shrink: 0; }
.pdf-existing-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The Application Id scraped off the PDF, alongside the applicant's slot. */
.pdf-existing-bgd { margin-left: 8px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.pdf-existing-link { flex-shrink: 0; font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none; }
.pdf-existing-link:hover { text-decoration: underline; }

/* Auto-pay toggle card + revealed payment fields. */
.autopay-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--input-bg);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.autopay-toggle:hover { border-color: var(--accent); }
.autopay-toggle:has(input:checked) {
  border-color: var(--accent);
  background: rgba(79, 156, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(79, 156, 255, 0.12);
}
.autopay-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
}
.autopay-toggle-text { display: flex; flex-direction: column; gap: 3px; }
.autopay-toggle-title { font-size: 14.5px; font-weight: 600; }
.autopay-toggle-desc { color: var(--text-muted); font-size: 12.5px; line-height: 1.45; }

.autopay-fields {
  margin: 14px 0 18px;
  padding: 16px 16px 2px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--input-bg);
}
.autopay-fields[hidden] { display: none; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 46px; }

.password-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
}

.password-toggle .icon-eye-off { display: none; }
.password-toggle.shown .icon-eye { display: none; }
.password-toggle.shown .icon-eye-off { display: block; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}

/* Inline "connect a phone number" row on the devices page. */
.connect-form .field { margin-bottom: 0; }

/* --------------------------------------------------- application PDFs upload */

.pdf-upload { margin-top: 2px; }

/* Native input is the no-JS fallback; JS hides it and shows the dropzone. */
.pdf-rawinput input { width: 100%; }

.pdf-dropzone {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 18px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pdf-dropzone:hover { border-color: var(--accent); background: var(--row-hover); }
.pdf-dropzone.dragover { border-color: var(--accent); background: rgba(79, 156, 255, 0.09); }
.pdf-dropzone-icon { width: 30px; height: 30px; color: var(--accent); }
.pdf-dropzone-title { font-size: 14px; font-weight: 600; }
.pdf-dropzone-link { color: var(--accent); text-decoration: underline; }
.pdf-dropzone-hint { font-size: 12px; color: var(--text-muted); }

.pdf-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.pdf-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.pdf-item.dragging { opacity: 0.5; }
.pdf-item.drag-over { box-shadow: 0 0 0 2px var(--accent); }

.pdf-handle { display: inline-flex; color: var(--text-muted); cursor: grab; flex-shrink: 0; }
.pdf-handle:active { cursor: grabbing; }
.pdf-handle svg { width: 16px; height: 16px; }

.pdf-fileicon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(229, 72, 77, 0.12);
  color: var(--danger);
  flex-shrink: 0;
}
.pdf-fileicon svg { width: 16px; height: 16px; }

.pdf-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pdf-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-size { font-size: 11.5px; color: var(--text-muted); }

.pdf-order {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--border-soft);
  color: var(--text-muted);
  letter-spacing: 0.2px;
}
.pdf-item:first-child .pdf-order { background: rgba(79, 156, 255, 0.15); color: #2F7FE0; }
[data-theme="dark"] .pdf-item:first-child .pdf-order { color: #4F9CFF; }

.pdf-remove {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pdf-remove:hover { background: rgba(229, 72, 77, 0.12); color: var(--danger); }
.pdf-remove svg { width: 16px; height: 16px; }
.connect-row { display: flex; gap: 10px; align-items: stretch; }
.connect-row input { flex: 1; }
.connect-row .btn { white-space: nowrap; }

/* ------------------------------------------------------------ empty state */

.empty-state {
  text-align: center;
  padding: 56px 24px;
}

.empty-state svg { width: 44px; height: 44px; color: var(--navy-300); margin-bottom: 14px; }
.empty-state h2 { font-size: 17px; margin: 0 0 6px; }
.empty-state p { color: var(--text-muted); margin: 0 0 20px; }

/* ------------------------------------------------------------- pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
}

.page-info { color: var(--text-muted); font-size: 13.5px; }

/* ----------------------------------------------------------- device detail */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 16px;
}
.back-link svg { width: 15px; height: 15px; }

.device-summary { padding: 22px 24px; margin-bottom: 8px; }

.device-summary-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.device-summary-head h2 { margin: 0; font-size: 18px; }
.device-summary-head p { margin: 2px 0 0; font-size: 13px; }

.device-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--navy-50);
  color: var(--navy-700);
  display: flex;
  align-items: center;
  justify-content: center;
}
[data-theme="dark"] .device-icon { background: var(--navy-800); color: var(--accent); }
.device-icon svg { width: 24px; height: 24px; }

.device-meta {
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.device-meta > div { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }

.meta-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.otp-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--primary);
}
[data-theme="dark"] .otp-code { color: var(--accent); }

.copy-btn { width: 28px; height: 28px; margin-left: 4px; }
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn.copied { color: var(--success); }

/* ------------------------------------------------------------------ login */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(79, 156, 255, 0.14), transparent 60%),
    radial-gradient(700px 450px at 0% 110%, rgba(35, 74, 154, 0.16), transparent 55%),
    var(--bg);
}

.login-theme-toggle { position: fixed; top: 18px; right: 18px; }

.login-wrap { width: 100%; max-width: 400px; padding: 24px; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 34px 30px 30px;
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 21px; margin: 14px 0 2px; }
.login-brand p { color: var(--text-muted); font-size: 13px; margin: 0; }

.login-card .alert { margin-bottom: 16px; }

.login-foot {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 18px;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 23, 51, 0.5);
    z-index: 30;
  }

  .sidebar-overlay.show { display: block; }

  .menu-btn { display: inline-flex; }
  .collapse-btn { display: none; }

  .topbar { padding: 12px 16px; }
  .content { padding: 18px 16px; }
}
