/* =====================================================================
   CareCollect console
   ---------------------------------------------------------------------
   Design note: this screen is watched for eight hours at a stretch by a
   dispatcher, so it is built to be read, not admired.

   The colour system is lifted from the one artefact everyone in this
   workflow already reads by colour — the vacutainer cap. Lavender EDTA,
   red serum, grey fluoride, blue citrate, green heparin, yellow urine.
   Status and sample type share that vocabulary, and every row carries a
   4px "cap spine" on its left edge so the board scans like a tube rack.

   Everything identifying — order numbers, barcodes, coordinates, ETAs —
   is set in tabular monospace so digits line up down a column and a
   wrong one stands out.
   ===================================================================== */

:root {
  /* surfaces */
  --ink:        #0F1620;
  --ink-2:      #1B2531;
  --ink-3:      #2A3646;
  --paper:      #F6F7F9;
  --card:       #FFFFFF;
  --line:       #E3E7ED;
  --line-soft:  #EEF1F5;

  /* text */
  --text:       #17202B;
  --text-2:     #5B6775;
  --text-3:     #8A94A2;
  --on-dark:    #DCE3EC;
  --on-dark-2:  #7C8899;

  /* brand — citrate blue */
  --brand:      #1B5E9E;
  --brand-2:    #144A7E;
  --brand-soft: #E8F0F8;

  /* cap colours, doubling as the status system */
  --cap-edta:   #8E44AD;   /* lavender  — assigned    */
  --cap-serum:  #C0392B;   /* red       — failed      */
  --cap-fluor:  #78838F;   /* grey      — draft       */
  --cap-citr:   #2980B9;   /* blue      — on the way  */
  --cap-hep:    #1E8E5A;   /* green     — collected   */
  --cap-urine:  #D4A017;   /* amber     — pending     */

  --radius:     6px;
  --radius-lg:  10px;
  --shadow:     0 1px 2px rgba(16,25,40,.06), 0 4px 12px rgba(16,25,40,.05);

  --sidebar-w:  236px;
  --topbar-h:   56px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* Data type. Anything a person might read out loud over the phone. */
.mono, .barcode-text, .order-no, .coord, .clock, td.num, .stat-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--ink);
  color: var(--on-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #fff;
}

.brand-mark {
  width: 26px; height: 26px;
  border-radius: 5px;
  background: var(--brand);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 13px; font-weight: 700; color: #fff;
}

.sidebar-scope {
  padding: 10px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--on-dark-2);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-scope strong { display: block; color: var(--on-dark); font-size: 13px;
  text-transform: none; letter-spacing: 0; margin-top: 2px; }

.nav-group { padding: 14px 0 4px; }
.nav-group-title {
  padding: 0 16px 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--on-dark-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--on-dark);
  border-left: 3px solid transparent;
  font-size: 13.5px;
}
.nav-item:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.nav-item.active {
  background: rgba(27,94,158,.22);
  border-left-color: var(--brand);
  color: #fff;
  font-weight: 550;
}
.nav-item .badge-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(255,255,255,.12);
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11px;
  color: var(--on-dark-2);
}

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.topbar .spacer { margin-left: auto; }

.clock-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  background: var(--line-soft);
  padding: 4px 9px;
  border-radius: var(--radius);
}

.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650;
}
.user-chip small { display: block; color: var(--text-3); font-size: 11px; line-height: 1.2; }

.content { padding: 20px; flex: 1 1 auto; }

/* ------------------------------------------------------------- surfaces */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px;
}
.card-head h2 { font-size: 13.5px; font-weight: 600; margin: 0; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px; }

/* The cap spine — the one piece of colour that carries meaning. */
.spine { border-left: 4px solid var(--cap-fluor); }
.spine-draft     { border-left-color: var(--cap-fluor); }
.spine-pending   { border-left-color: var(--cap-urine); }
.spine-assigned  { border-left-color: var(--cap-edta); }
.spine-otw       { border-left-color: var(--cap-citr); }
.spine-collected { border-left-color: var(--cap-hep); }
.spine-failed    { border-left-color: var(--cap-serum); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); }
.stat-value { font-size: 26px; font-weight: 650; margin-top: 4px; line-height: 1.1; }
.stat-note  { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* --------------------------------------------------------------- tables */

table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.grid td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.grid tbody tr:hover { background: #FAFBFC; }
table.grid td.num { text-align: right; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 550;
  padding: 2px 8px; border-radius: 20px;
  background: var(--line-soft); color: var(--text-2);
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-pending   { background: #FBF3DF; color: #8A6A05; }
.tag-assigned  { background: #F3E9F8; color: #6B2E88; }
.tag-otw       { background: #E6F1F9; color: #1B5E9E; }
.tag-collected { background: #E4F3EC; color: #14683F; }
.tag-failed    { background: #FBE9E7; color: #96271B; }

/* --------------------------------------------------------------- forms */

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 12px; font-weight: 550;
  color: var(--text-2); margin-bottom: 5px;
}
.input {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  outline: none;
}
.input.is-invalid { border-color: var(--cap-serum); }
.field-error { color: var(--cap-serum); font-size: 12px; margin-top: 4px; }
.field-hint  { color: var(--text-3); font-size: 12px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px;
  font: inherit; font-weight: 550;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); text-decoration: none; color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-3); text-decoration: none; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* --------------------------------------------------------------- alerts */

.alert {
  padding: 10px 13px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-success { background: #E4F3EC; border-color: #BFE3D0; color: #14683F; }
.alert-danger  { background: #FBE9E7; border-color: #F3C8C2; color: #96271B; }
.alert-warning { background: #FBF3DF; border-color: #EDDCAF; color: #7A5C05; }
.alert-info    { background: var(--brand-soft); border-color: #C9DDEF; color: var(--brand-2); }

/* ---------------------------------------------------------- empty state */

.empty { text-align: center; padding: 46px 20px; }
.empty h3 { font-size: 15px; font-weight: 600; margin: 0 0 5px; }
.empty p  { color: var(--text-2); margin: 0 0 16px; max-width: 380px; margin-inline: auto; }

/* ------------------------------------------------------------ auth page */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 460px;
  background: var(--ink);
}

/* The left panel is a tube rack rendered as light: six cap colours,
   which is the first thing anyone in this job recognises. */
.auth-side {
  position: relative;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: var(--on-dark);
  overflow: hidden;
}
.rack { position: absolute; inset: 0 0 0 48px; display: flex; gap: 14px; align-items: flex-start; }
.rack i {
  display: block; width: 26px; border-radius: 0 0 13px 13px;
  opacity: .85;
  animation: settle .9s cubic-bezier(.2,.7,.2,1) both;
}
.rack i:nth-child(1) { height: 46%; background: var(--cap-edta);  animation-delay: .00s; }
.rack i:nth-child(2) { height: 62%; background: var(--cap-serum); animation-delay: .06s; }
.rack i:nth-child(3) { height: 38%; background: var(--cap-fluor); animation-delay: .12s; }
.rack i:nth-child(4) { height: 71%; background: var(--cap-citr);  animation-delay: .18s; }
.rack i:nth-child(5) { height: 52%; background: var(--cap-hep);   animation-delay: .24s; }
.rack i:nth-child(6) { height: 33%; background: var(--cap-urine); animation-delay: .30s; }
@keyframes settle { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .rack i { animation: none; } }

.auth-side-copy { position: relative; max-width: 420px; }
.auth-side-copy h2 { font-size: 26px; line-height: 1.25; margin: 0 0 10px; color: #fff; letter-spacing: -0.02em; }
.auth-side-copy p  { color: var(--on-dark-2); margin: 0; }

.auth-panel { background: var(--card); display: flex; flex-direction: column; justify-content: center; padding: 40px; }
.auth-panel h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.02em; }
.auth-panel .sub { color: var(--text-2); margin: 0 0 24px; font-size: 13.5px; }
.auth-foot { margin-top: 24px; font-size: 12px; color: var(--text-3); }

@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .sidebar { position: fixed; left: -100%; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .content { padding: 14px; }
}

/* ------------------------------------------------------------- barcode */

.barcode-label {
  display: inline-block;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.barcode-label svg { display: block; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; }
}
