/* SDS design system: tokens and shared components for the website, portal and console.
   Colours are tokens on :root, redefined for dark mode. Layout works at 360px with no horizontal scroll. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f4f7;
  --text: #17202a;
  --text-muted: #5a6573;
  --border: #d8dee6;
  --brand: #0b5d57;          /* deep teal: trust, safety */
  --brand-strong: #084a46;
  --brand-soft: #e3f1ef;
  --accent: #1d4ed8;
  --focus: #1d4ed8;
  --ok: #067647;  --ok-soft: #e6f4ec;
  --warn: #8a5300; --warn-soft: #fdf3e1;
  --bad: #b42318; --bad-soft: #fde8e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419; --surface: #171d24; --surface-2: #1e2630; --text: #e7ebf0; --text-muted: #9aa5b1;
    --border: #2b3440; --brand: #5fc7bd; --brand-strong: #8fd9d1; --brand-soft: #173533;
    --accent: #7aa2ff; --focus: #7aa2ff;
    --ok: #6ee7a8; --ok-soft: #163325; --warn: #f5b461; --warn-soft: #3a2a12; --bad: #ff8a80; --bad-soft: #3d1b18;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419; --surface: #171d24; --surface-2: #1e2630; --text: #e7ebf0; --text-muted: #9aa5b1;
  --border: #2b3440; --brand: #5fc7bd; --brand-strong: #8fd9d1; --brand-soft: #173533;
  --accent: #7aa2ff; --focus: #7aa2ff;
  --ok: #6ee7a8; --ok-soft: #163325; --warn: #f5b461; --warn-soft: #3a2a12; --bad: #ff8a80; --bad-soft: #3d1b18;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); }
img, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + .9vw, 1.75rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--text-muted); }
.small { font-size: .875rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 12px; top: 12px; }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 8px; border: 1px solid transparent; font: 600 .95rem/1 var(--font); cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--border); }
.btn-block { width: 100%; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .9rem; }
.input, .select, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; }
textarea.input { min-height: 130px; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.hint { color: var(--text-muted); font-size: .85rem; }

/* Badges and notices */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.notice { padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.notice-error { border-color: var(--bad); color: var(--bad); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }

/* Responsive data: a table on wide screens, stacked cards on narrow ones */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
@media (max-width: 720px) {
  .data-table thead { position: absolute; left: -9999px; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; background: var(--surface); }
  .data-table td { border: 0; padding: 4px 0; }
  .data-table td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
}

/* Empty and loading states */
.empty { text-align: center; padding: 40px 16px; color: var(--text-muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 6px; }

/* Sign-in card */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand-mark { min-width: 30px; height: 30px; padding: 0 7px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .9rem; }

/* Progress: a thin bar for page loads and uploads; a spinner for busy buttons */
.progress { height: 4px; width: 100%; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--brand); transition: width .2s ease; }
.progress-bar.indeterminate { width: 40%; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.topline { position: fixed; top: 0; left: 0; right: 0; z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; }
.topline.on { opacity: 1; }
.busy { position: relative; }
.busy::after { content: ""; width: 14px; height: 14px; margin-left: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .progress-bar, .busy::after, .progress-bar.indeterminate { animation: none; transition: none; } }

/* Drop zone for bulk upload */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 16px; text-align: center; background: var(--surface-2); cursor: pointer; }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.file-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; max-height: 320px; overflow: auto; }
.file-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.file-list li.bad { border-color: var(--bad); }
.file-list .name { overflow-wrap: anywhere; font-weight: 600; }
.file-list li .btn { min-height: 36px; padding: 0 10px; font-size: .9rem; }
.file-list .progress { grid-column: 1 / -1; }
