:root {
  --bg: #f5f6f8;
  --bg-strong: #eceff3;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --panel-tint: #eef2f6;
  --ink: #1f2937;
  --ink-strong: #111827;
  --muted: #6b7280;
  --line: #dde3ea;
  --line-strong: #bdc7d3;
  --brand: #235b5f;
  --brand-dark: #1d4a4d;
  --brand-weak: #e3f1f2;
  --accent: #234d70;
  --accent-dark: #173954;
  --accent-weak: #e5edf4;
  --amber: #b7791f;
  --amber-weak: #fff4d6;
  --red: #b42318;
  --red-weak: #fee4e2;
  --sidebar: #1f2937;
  --sidebar-soft: #2f3b4a;
  --shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
  --shadow-soft: 0 4px 14px rgba(17, 24, 39, 0.06);
  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  word-break: keep-all;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 440px) 1fr;
  background: var(--bg);
}

.login-panel {
  padding: 52px 44px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
  z-index: 1;
}

.login-visual {
  position: relative;
  padding: 56px;
  display: grid;
  align-content: center;
  gap: 20px;
  overflow: hidden;
  background: #f0f3f7;
}

.brand-mark {
  display: none;
}

.login-brand {
  width: fit-content;
  margin-bottom: 22px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
  color: var(--ink-strong);
  font-size: 18px;
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 8px;
  color: #52606d;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  color: var(--ink-strong);
  font-size: 32px;
  line-height: 1.14;
  letter-spacing: 0;
}

h2 {
  color: var(--ink-strong);
  font-size: 20px;
  line-height: 1.25;
  margin-bottom: 10px;
}

h3 {
  color: var(--ink-strong);
  font-size: 15px;
  line-height: 1.3;
  margin-bottom: 8px;
}

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

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

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 42px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: #9aa7b8;
}

textarea {
  resize: vertical;
  min-height: 76px;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.13);
}

.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  min-height: 39px;
  border-radius: 8px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink);
  background: #eef2f7;
  border: 1px solid transparent;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.btn:hover,
.tab:hover,
.nav-btn:hover {
  transform: none;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  stroke-width: 2.25;
}

.btn-primary {
  color: #fff;
  background: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  color: var(--brand-dark);
  background: var(--brand-weak);
  border-color: rgba(15, 118, 110, 0.16);
}

.btn-warning {
  color: #7a4b08;
  background: var(--amber-weak);
  border-color: rgba(183, 121, 31, 0.18);
}

.btn-danger {
  color: var(--red);
  background: var(--red-weak);
  border-color: rgba(180, 35, 24, 0.16);
}

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: #344054;
}

.demo-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.demo-strip .btn {
  width: 100%;
}

.ops-panel {
  width: min(680px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.ops-panel-header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.ops-panel-header h2 {
  margin-bottom: 0;
}

.ops-status {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  background: #eef7f0;
  color: #25633b;
  font-size: 12px;
  font-weight: 850;
}

.ops-list {
  display: grid;
}

.ops-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.ops-row:last-child {
  border-bottom: 0;
}

.ops-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.ops-row strong {
  color: var(--ink-strong);
  font-size: 14px;
}

.flow-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-weak);
}

.flow-icon svg {
  width: 18px;
  height: 18px;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: #f8fafc;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .brand-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.sidebar strong,
.nav-btn {
  white-space: nowrap;
}

.sidebar .brand-mark {
  display: none;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: 8px;
  padding: 10px 11px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke-width: 2.2;
}

.nav-btn.active,
.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.content {
  min-width: 0;
  padding: 24px;
}

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

.topbar-title p {
  margin-bottom: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.panel-header {
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border-radius: 8px 8px 0 0;
}

.panel-body {
  padding: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(360px, 1.3fr);
  gap: 16px;
  align-items: start;
}

.user-flow-panel {
  margin-bottom: 16px;
}

.user-flow-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.credential-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--panel-soft);
}

.mini-card strong {
  display: block;
  margin-bottom: 9px;
  color: var(--ink-strong);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 850;
  background: #edf2f7;
  color: #475467;
}

.badge.green { background: var(--brand-weak); color: var(--brand-dark); }
.badge.amber { background: var(--amber-weak); color: #7a4b08; }
.badge.red { background: var(--red-weak); color: var(--red); }
.badge.blue { background: var(--accent-weak); color: var(--accent-dark); }

.carrier-tabs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab {
  min-height: 37px;
  border-radius: 8px;
  padding: 8px 12px;
  color: #344054;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 800;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.tab.active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.14);
}

.queue {
  display: grid;
  gap: 12px;
}

.registration-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.04);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

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

.detail {
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 8px;
  min-width: 0;
}

.detail span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detail strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink-strong);
  font-size: 13px;
}

.notice {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 13px;
  border-radius: 8px;
  color: #344054;
}

.notice.warning {
  border-color: #f5cf80;
  background: var(--amber-weak);
}

.notice.danger {
  border-color: #f6b4ad;
  background: var(--red-weak);
}

.signature-pad {
  width: 100%;
  height: 150px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.58);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.28);
}

.modal-wide {
  width: min(1320px, 100%);
}

.coord-editor-modal {
  overflow: hidden;
}

.modal .panel-header {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 3;
}

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

.coord-editor {
  display: grid;
  grid-template-columns: 240px minmax(440px, 1fr) 250px;
  height: min(78vh, 820px);
  min-height: 560px;
  border-top: 1px solid var(--line);
  background: #eef1f5;
  overflow: hidden;
}

.coord-editor-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  background: #fff;
  border-right: 1px solid var(--line);
  overflow: auto;
}

.coord-fixed-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.coord-panel-section {
  display: grid;
  gap: 10px;
}

.coord-panel-section > strong {
  color: var(--ink-strong);
  font-size: 13px;
}

.coord-upload input {
  margin-top: 6px;
}

.coord-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.coord-editor-canvas {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #5e6670;
  overflow: hidden;
}

.coord-canvas-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  color: #fff;
  background: #202731;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.coord-canvas-toolbar strong,
.coord-canvas-toolbar span {
  display: block;
}

.coord-canvas-toolbar strong {
  font-size: 14px;
}

.coord-canvas-toolbar span {
  margin-top: 3px;
  color: #cbd5e1;
  font-size: 12px;
}

.pdf-coordinate-scroll {
  overflow: auto;
  padding: 20px;
  display: grid;
  place-items: start center;
}

.pdf-coordinate-stage {
  position: relative;
  width: min(100%, 620px);
  border: 1px solid rgba(15, 23, 42, 0.28);
  background: #fff;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.35);
  touch-action: none;
}

.pdf-coordinate-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  object-fit: fill;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.pdf-coordinate-preview.active {
  opacity: 1;
}

.pdf-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: #64748b;
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(15, 23, 42, 0.045) 1px, transparent 1px),
    #f8fafc;
  background-size: 24px 24px;
}

.pdf-empty strong {
  color: var(--ink-strong);
}

.pdf-coordinate-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.coord-overlay-box {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 22px;
  border: 2px solid currentColor;
  background: rgba(255, 255, 255, 0.68);
  color: var(--brand);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.coord-overlay-box span {
  max-width: 100%;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.92);
  color: inherit;
  font-size: 12px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coord-overlay-box i {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: currentColor;
  cursor: nwse-resize;
}

.coord-overlay-box.active {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
}

.coord-signature,
.coord-legend.coord-signature span { color: var(--brand); }

.coord-guardian,
.coord-legend.coord-guardian span { color: var(--accent); }

.coord-vCheck,
.coord-legend.coord-vCheck span { color: var(--amber); }

.coord-date,
.coord-legend.coord-date span { color: var(--red); }

.coord-side-panel {
  display: grid;
  gap: 8px;
}

.coord-legend {
  min-height: 39px;
  display: grid;
  grid-template-columns: 12px 1fr;
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
  text-align: left;
}

.coord-legend b {
  font-size: 13px;
}

.coord-legend small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.coord-legend span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 12px;
}

.coord-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.coord-details summary {
  cursor: pointer;
  font-weight: 850;
  color: var(--ink-strong);
}

.coord-details .mini-card {
  margin-top: 10px;
}

.empty {
  padding: 42px 20px;
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #101828;
  box-shadow: var(--shadow);
  z-index: 30;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .login-screen,
  .layout,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 320px;
  }

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

  .coord-editor {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    overflow: auto;
  }

  .coord-editor-panel,
  .coord-fixed-panel {
    border-left: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .coord-editor-canvas {
    min-height: 620px;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 640px) {
  .login-panel,
  .login-visual,
  .content {
    padding: 18px;
  }

  h1 {
    font-size: 25px;
  }

  .grid-3,
  .detail-grid,
  .two-col,
  .input-action,
  .coord-grid {
    grid-template-columns: 1fr;
  }

  .coord-editor-modal {
    max-height: 96vh;
  }

  .coord-editor-canvas {
    min-height: 520px;
  }

  .pdf-coordinate-scroll {
    padding: 12px;
  }

  .topbar,
  .panel-header,
  .card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .btn-row,
  .toolbar {
    width: 100%;
  }

  .btn,
  .demo-strip {
    width: 100%;
  }

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