/* ==========================================================================
   Ela-tech ITSC – shared design tokens and components
   ========================================================================== */
:root {
  --navy-950: #070f22;
  --navy-900: #0b1730;
  --navy-800: #13244a;
  --navy-700: #1d3363;
  --blue-600: #1653f0;
  --blue-500: #2f6bff;
  --blue-100: #e6eeff;
  --blue-50: #f3f7ff;
  --teal-500: #0fb5a6;
  --teal-100: #d9f6f2;
  --amber-500: #f5a524;
  --amber-100: #fff3dc;
  --red-600: #d23c3c;
  --red-100: #fde8e8;
  --green-600: #13915b;
  --green-100: #dcf5e8;

  --ink: #0e1a33;
  --ink-2: #3c4a66;
  --ink-3: #6b7894;
  --line: #e2e8f2;
  --line-2: #cfd8e6;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eef2f8;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(14, 26, 51, .06);
  --shadow: 0 6px 24px -8px rgba(14, 26, 51, .16), 0 2px 6px rgba(14, 26, 51, .05);
  --shadow-lg: 0 24px 60px -20px rgba(11, 23, 48, .35);
  --focus: 0 0 0 3px rgba(47, 107, 255, .35);

  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
a { color: var(--blue-600); text-underline-offset: 3px; }
a:hover { color: var(--blue-500); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.02em; color: var(--ink); }
p { margin: 0 0 1em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--navy-900); color: #fff; padding: .6rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 1rem; color: #fff; }

.icon { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.25em; }
.icon-lg { width: 1.75rem; height: 1.75rem; }
.icon-xl { width: 2.25rem; height: 2.25rem; }

.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .9em; }
.text-right { text-align: right; }
.stack > * + * { margin-top: 1rem; }
.cluster { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.spread { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .6rem 1.1rem;
  font: inherit; font-weight: 650; font-size: .95rem; line-height: 1.2; text-decoration: none;
  color: var(--btn-fg); background: var(--btn-bg); border: 1px solid var(--btn-bd);
  border-radius: 999px; cursor: pointer; transition: transform .12s ease, background .15s, box-shadow .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { color: var(--btn-fg); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-busy="true"] { opacity: .65; cursor: progress; }
.btn-primary { --btn-bg: var(--blue-600); --btn-fg: #fff; --btn-bd: var(--blue-600); box-shadow: 0 8px 20px -8px rgba(22, 83, 240, .7); }
.btn-primary:hover { --btn-bg: var(--blue-500); color: #fff; border-color: var(--blue-500); }
.btn-accent { --btn-bg: var(--amber-500); --btn-fg: var(--navy-950); --btn-bd: var(--amber-500); }
.btn-accent:hover { --btn-bg: #ffb840; border-color: #ffb840; }
.btn-dark { --btn-bg: var(--navy-900); --btn-fg: #fff; --btn-bd: var(--navy-900); }
.btn-dark:hover { --btn-bg: var(--navy-700); color: #fff; }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn-ghost:hover { --btn-bg: var(--surface-3); border-color: transparent; }
.btn-outline-light { --btn-bg: rgba(255,255,255,.06); --btn-fg: #fff; --btn-bd: rgba(255,255,255,.35); }
.btn-outline-light:hover { --btn-bg: rgba(255,255,255,.14); color: #fff; border-color: #fff; }
.btn-danger { --btn-bg: var(--red-600); --btn-fg: #fff; --btn-bd: var(--red-600); }
.btn-danger:hover { color: #fff; filter: brightness(1.08); }
.btn-success { --btn-bg: var(--green-600); --btn-fg: #fff; --btn-bd: var(--green-600); }
.btn-success:hover { color: #fff; filter: brightness(1.08); }
.btn-sm { min-height: 36px; padding: .35rem .8rem; font-size: .85rem; }
.btn-lg { min-height: 52px; padding: .8rem 1.5rem; font-size: 1.02rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--blue-600); cursor: pointer; text-decoration: underline; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 650; line-height: 1.4;
  white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-priority::before { border-radius: 2px; }
.badge-info { background: var(--blue-100); color: #1742b8; }
.badge-ok { background: var(--green-100); color: #0c6b42; }
.badge-warn { background: var(--amber-100); color: #8a5300; }
.badge-danger { background: var(--red-100); color: #a52424; }
.badge-accent { background: var(--teal-100); color: #07766c; }
.badge-muted { background: var(--surface-3); color: var(--ink-2); }
.tag { display: inline-block; padding: .15rem .55rem; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-size: .78rem; font-weight: 600; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1.02rem; }
.card-foot { padding: .9rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 1rem 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.form-grid .span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > label, .field legend { font-weight: 650; font-size: .9rem; color: var(--ink); }
.req { color: var(--red-600); }
.field input:not([type=checkbox]):not([type=radio]):not([type=range]), .field select, .field textarea, .input {
  width: 100%; min-height: 46px; padding: .6rem .8rem;
  font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--blue-500); box-shadow: var(--focus); }
.field input[type=file] { min-height: 74px; padding: .75rem; background: var(--blue-50); border: 1.5px dashed var(--line-2); border-radius: var(--radius); color: var(--ink-2); cursor: pointer; }
.field input[type=file]:hover { border-color: var(--blue-500); background: var(--surface); }
.field input[type=file]::file-selector-button { margin-right: 1rem; padding: .7rem 1rem; border: 0; border-radius: var(--radius-sm); background: var(--blue-600); color: #fff; font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; transition: background .15s, transform .15s; }
.field input[type=file]:hover::file-selector-button { background: var(--navy-700); }
.field input[type=range] { width: 100%; accent-color: var(--blue-600); min-height: 32px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red-600); }
.field .help { margin: 0; font-size: .82rem; color: var(--ink-3); }
.field .error { margin: 0; font-size: .85rem; color: var(--red-600); font-weight: 600; }
.field fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.field legend { padding: 0; margin-bottom: .45rem; }
.choice-grid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.choice, .check {
  display: flex; align-items: center; gap: .6rem; padding: .65rem .8rem; min-height: 46px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-weight: 550;
}
.choice:has(input:checked), .check:has(input:checked) { border-color: var(--blue-500); background: var(--blue-50); }
.choice input, .check input { width: 1.15rem; height: 1.15rem; accent-color: var(--blue-600); flex: none; margin: 0; }
.form-errors { padding: .85rem 1rem; border-radius: var(--radius-sm); background: var(--red-100); color: #8f1f1f; font-weight: 600; }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1.5rem; }
.fieldset-title { font-size: 1rem; margin: 1.5rem 0 .75rem; padding-top: 1.25rem; border-top: 1px solid var(--line); display: flex; align-items: center; gap: .5rem; }
.fieldset-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- Alerts / messages ---------- */
.alerts { display: grid; gap: .5rem; margin-bottom: 1.25rem; }
.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 550; }
.alert .icon { margin-top: .15rem; }
.alert-success { background: var(--green-100); color: #0b5a38; border-color: #b6e8cf; }
.alert-error { background: var(--red-100); color: #8f1f1f; border-color: #f5c2c2; }
.alert-info { background: var(--blue-100); color: #1a3f9e; border-color: #c9d9ff; }
.alert-warning { background: var(--amber-100); color: #7a4a00; border-color: #fbdca2; }
.alert-close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; padding: 0 .25rem; font-size: 1.2rem; line-height: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--blue-50); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-link { font-weight: 700; text-decoration: none; color: var(--ink); }
.row-link:hover { color: var(--blue-600); text-decoration: underline; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 2.25rem 1.25rem; color: var(--ink-3); }
.empty .icon { width: 2.5rem; height: 2.5rem; color: var(--line-2); margin-bottom: .5rem; }
.empty h3 { color: var(--ink-2); font-size: 1rem; margin-bottom: .25rem; }
.empty p { margin: 0 auto .75rem; max-width: 36ch; font-size: .92rem; }

/* ---------- Accordion (details) ---------- */
.accordion { display: grid; gap: .6rem; }
.accordion details { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.accordion summary { list-style: none; cursor: pointer; padding: 1rem 1.25rem; font-weight: 650; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--blue-600); transition: transform .2s; }
.accordion details[open] summary::after { transform: rotate(45deg); }
.accordion details > div { padding: 0 1.25rem 1.1rem; color: var(--ink-2); }

/* Controls that need JavaScript stay hidden until it has loaded. */
.js-only { display: none !important; }
.js .js-only { display: inline-flex !important; }

/* ---------- Brand (header, sidebar, login) ---------- */
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.12rem; letter-spacing: -.02em; }
.brand:hover { color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--blue-600), var(--teal-500)); color: #fff; font-weight: 800; font-size: .95rem; box-shadow: 0 6px 16px -6px rgba(22,83,240,.6); }
.brand small { display: block; font-size: .68rem; font-weight: 600; letter-spacing: .04em; color: var(--ink-3); text-transform: uppercase; }
