/* StockMGMT — Focal Medical Imaging light theme.
   Tokens and component specs from branding/focal-brand-guidelines.jsx.
   Fonts are self-hosted (CSP allows same-origin only; works offline on LAN). */

@font-face {
  font-family: 'DM Sans';
  src: url('/fonts/dm-sans.woff2') format('woff2');
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Playfair Display';
  src: url('/fonts/playfair-display.woff2') format('woff2');
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }
:root {
  --focal-deep: #0B2545;
  --focal-teal: #13778A;
  --focal-sky: #45B7D1;
  --focal-warm: #F0A868;
  --focal-coral: #E8735A;
  --focal-slate: #5A6B7F;
  --focal-cloud: #F4F7FA;
  --focal-success: #2D9F6F;
  --focal-muted: #B0BAC5;
  --warm-text: #B8762E;           /* readable warm for text on tints */
  --line: rgba(0, 0, 0, 0.05);
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', Helvetica, Arial, sans-serif;
  --radius-card: 14px;
  --radius-button: 8px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.03);

  /* legacy aliases used across pages */
  --bg: var(--focal-cloud); --panel: #ffffff; --ink: var(--focal-deep);
  --muted: var(--focal-slate); --brand: var(--focal-teal);
  --brand-dark: #0e5f6e; --ok: var(--focal-success);
  --warn: var(--warm-text); --bad: var(--focal-coral);
}
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 var(--font-body);
  background: var(--focal-cloud); color: var(--focal-deep);
}
.hidden { display: none !important; }
.muted { color: var(--focal-slate); font-size: 0.92em; }
code { background: var(--focal-cloud); padding: 1px 5px; border-radius: 4px; }
a { color: var(--focal-teal); }
a:hover { color: var(--focal-sky); }

/* brand lockup (login + sidebar + print header) */
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup img { display: block; }
.brand-lockup .brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 21px;
  color: var(--focal-deep); letter-spacing: 0.02em; line-height: 1.1;
}
.brand-lockup .brand-desc {
  font-size: 8.5px; font-weight: 500; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--focal-slate); margin-top: 2px;
}
.brand-lockup .brand-app {
  font-size: 10px; font-weight: 600; color: var(--focal-teal); margin-top: 3px;
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* login */
#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: 32px; width: 380px; box-shadow: 0 8px 30px rgba(11, 37, 69, 0.08);
}
.login-card .brand-lockup { justify-content: center; margin-bottom: 6px; }
.login-card p.muted { text-align: center; margin-top: 0; }
.login-card label { display: block; margin: 14px 0 0; font-weight: 600; font-size: 13px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 20px; }
#totp-qr svg { display: block; margin: 10px auto; }

/* layout */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 218px; flex: 0 0 218px; background: #fff;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 0;
  position: sticky; top: 0; height: 100vh;
}
#sidebar .brand { padding: 4px 18px 16px; }
#sidebar a {
  color: var(--focal-slate); text-decoration: none; padding: 9px 18px;
  font-size: 14.5px; font-weight: 500; border-left: 3px solid transparent;
}
#sidebar a:hover { background: var(--focal-cloud); color: var(--focal-teal); }
#sidebar a.active {
  background: rgba(19, 119, 138, 0.10); color: var(--focal-teal);
  font-weight: 600; border-left-color: var(--focal-teal);
}
#sidebar .spacer { flex: 1; }
#sidebar #whoami { padding: 6px 18px; font-size: 12px; }
#app main { flex: 1; padding: 26px 30px; max-width: 1200px; min-width: 0; }

h2 {
  margin: 0 0 14px; font-family: var(--font-display);
  font-size: 24px; font-weight: 600; color: var(--focal-deep);
}
h3 { margin: 20px 0 8px; font-size: 16px; font-weight: 600; color: var(--focal-deep); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 { margin: 0; flex: 1; }

/* controls */
input, select, textarea, button {
  font: inherit; color: var(--focal-deep);
  border: 1.5px solid var(--focal-muted); border-radius: var(--radius-button);
  padding: 8px 12px; background: #fff;
}
input::placeholder, textarea::placeholder { color: var(--focal-muted); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--focal-teal);
  box-shadow: 0 0 0 3px rgba(19, 119, 138, 0.12);
}
button {
  background: linear-gradient(135deg, var(--focal-warm), var(--focal-coral));
  color: var(--focal-deep); border: none;
  padding: 9px 18px; cursor: pointer; font-weight: 600;
}
button:hover { filter: brightness(1.05); }
button.secondary {
  background: #fff; color: var(--focal-teal);
  border: 2px solid var(--focal-teal); padding: 7px 16px;
}
button.secondary:hover { background: rgba(19, 119, 138, 0.07); filter: none; }
button.danger { background: var(--focal-coral); color: #fff; }
button.danger:hover { filter: brightness(0.95); }
button:disabled { opacity: .5; cursor: default; filter: none; }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(19, 119, 138, 0.25); }

form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
form.grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; color: var(--focal-deep); }
form.grid .full { grid-column: 1 / -1; }

/* panels & tables */
.panel {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 20px; margin-bottom: 18px;
}
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-card);
}
table.data th, table.data td {
  text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
table.data th {
  background: var(--focal-cloud); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--focal-teal);
}
table.data td { color: var(--focal-slate); font-size: 13.5px; }
table.data td strong, table.data td b { color: var(--focal-deep); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #f7fafc; }
table.data td.num, table.data th.num { text-align: right; }

/* badges & states */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
}
.badge.ok { background: rgba(45, 159, 111, 0.12); color: var(--focal-success); }
.badge.warn { background: rgba(240, 168, 104, 0.20); color: var(--warm-text); }
.badge.bad { background: rgba(232, 115, 90, 0.14); color: var(--focal-coral); }
.badge.core { background: rgba(19, 119, 138, 0.10); color: var(--focal-teal); }
.badge.info { background: rgba(69, 183, 209, 0.15); color: #2b7f95; }
.error {
  background: rgba(232, 115, 90, 0.10); color: #b3402c;
  border: 1px solid rgba(232, 115, 90, 0.35);
  border-left: 4px solid var(--focal-coral);
  border-radius: 0 10px 10px 0; padding: 12px 16px; margin: 10px 0;
}
.callout {
  background: rgba(240, 168, 104, 0.14); border-left: 4px solid var(--focal-warm);
  border-radius: 0 12px 12px 0; padding: 14px 18px; margin: 10px 0;
}

/* dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 16px; cursor: pointer; transition: box-shadow .15s, transform .15s;
}
.tile:hover { box-shadow: 0 4px 14px rgba(11, 37, 69, 0.08); transform: translateY(-1px); }
.tile .n {
  font-size: 30px; font-weight: 700; color: var(--focal-teal);
  font-family: var(--font-display);
}
.tile.warn .n { color: var(--warm-text); }
.tile.bad .n { color: var(--focal-coral); }
.tile.ok .n { color: var(--focal-success); }
.tile .t { color: var(--focal-slate); font-size: 13px; margin-top: 2px; }

/* toast */
#toast { position: fixed; bottom: 22px; right: 22px; z-index: 50; }
.ok-toast, .error-toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 50;
  padding: 12px 18px; border-radius: var(--radius-button); color: #fff; font-weight: 600;
  box-shadow: 0 6px 20px rgba(11, 37, 69, 0.2);
}
.ok-toast { background: var(--focal-success); }
.error-toast { background: var(--focal-coral); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a {
  padding: 10px 16px; text-decoration: none; color: var(--focal-slate);
  font-weight: 500; font-size: 13.5px;
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--focal-teal); }
.tabs a.active { color: var(--focal-teal); font-weight: 600; border-bottom-color: var(--focal-teal); }

/* scan box */
textarea.scanbox { width: 100%; min-height: 120px; font-family: ui-monospace, Menlo, monospace; }

/* print header — branded header for report pages printed / saved as PDF */
#print-header { display: none; }

@media (max-width: 800px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  #sidebar a { border-left: none; border-bottom: 3px solid transparent; }
  #sidebar a.active { border-bottom-color: var(--focal-teal); }
  #app main { padding: 14px; }
}

@media print {
  #sidebar, .no-print, #toast, .ok-toast, .error-toast { display: none !important; }
  #app main { padding: 0; max-width: none; }
  body { background: #fff; }
  #print-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 0 10px; margin: 0 0 16px;
    border-bottom: 2.5px solid var(--focal-teal);
  }
  #print-header .brand-lockup img { width: 34px; height: 34px; }
  .panel, table.data, .tile { box-shadow: none; }
  table.data th { color: var(--focal-deep); }
}
