/* =============================================================================
   Intellyx TOC – one stylesheet for every screen.
   Brand tokens: Denz Web App Standard (Intellyx blue). Layout copied from the prototype.
   Mobile first: 360 px, then 768 px and 1280 px.
   ============================================================================= */

@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/inter-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 800; font-style: normal; font-display: swap; src: url("../fonts/inter-latin-800-normal.woff2") format("woff2"); }

:root {
  /* Brand tokens (Part K) */
  --primary: #2B6AD0;        /* buttons, links, focus ring (5.1:1 on white) */
  --primary-dark: #1F4591;   /* hover, headers */
  --accent: #68A4F1;         /* decoration only */
  --ink: #061E47;            /* headings, splash, sidebar */
  --surface-tint: #F3F7FD;   /* page background */
  --border: #C2C9CC;
  --text: #383B3D;
  --muted: #595F61;
  /* Supporting tints from the prototype */
  --ink-2: #0E2555;
  --tint-2: #E6F0FC;
  --tint-3: #C9D8F3;
  --tint-4: #94B1E7;
  --gray-1: #EDEFF0;
  --ok: #1B7F51;   --ok-bg: #DDF4E8;
  --warn: #8A5A0B; --warn-bg: #FFF1D6;
  --bad: #B03325;  --bad-bg: #FBE0DC;
  --kpi-amber: #A3660A;      /* white text on it: 4.2:1 (large text) */
  --radius: 10px;
  --shadow: 0 1px 2px rgba(6, 30, 71, .06), 0 6px 18px rgba(6, 30, 71, .06);
  --focus: 0 0 0 3px rgba(43, 106, 208, .45);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color: var(--text);
  background: var(--surface-tint);
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.icon { flex: none; vertical-align: -3px; }
.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: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 100; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- Splash */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--ink);   /* same navy as the logo background, so the logo blends in */
  color: #fff;
  animation: splash-out .4s ease 2.1s forwards;   /* removed by itself after 2.5 s, even without JS */
}
.splash img { width: min(360px, 78vw); height: auto; animation: splash-in .5s ease both; }
.splash .app-name { font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: .8rem; color: #DCE8FB; }
.splash.done { animation: splash-out .3s ease forwards; }
@keyframes splash-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .splash img { animation: none; }
  *, *::before, *::after { transition: none !important; animation-duration: .001s !important; }
}

/* ---------------------------------------------------------------- App shell */
.app { min-height: 100vh; display: flex; }
.side {
  width: 248px; flex: none; background: var(--ink); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .brand { padding: 16px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.12); }
.side .brand img { display: block; width: 100%; height: auto; border-radius: 8px; }
.side .brand .app-sub { display: block; font-size: .75rem; color: #C9D8F3; margin-top: 8px; letter-spacing: .06em; text-transform: uppercase; }
.nav { padding: 8px; flex: 1; }
.nav h4 { margin: 16px 10px 4px; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: #A9C1EC; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: 8px;
  color: #E3ECFB; text-decoration: none; font-size: .95rem;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.on { background: var(--primary); color: #fff; }
.nav a .badge { margin-left: auto; background: #E08A00; color: #1b1300; border-radius: 10px; padding: 0 8px; font-size: .75rem; font-weight: 700; }
.side .foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: .75rem; color: #A9C1EC; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  background: #fff; border-bottom: 1px solid var(--tint-3); padding: 10px 24px;
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20;
}
.top h1 { font-size: 1.2rem; }
.top .sp { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; font-size: .875rem; }
.who .meta { line-height: 1.25; }
.av { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.session-chip { font-size: .8rem; color: var(--muted); background: var(--surface-tint); border: 1px solid var(--tint-3); padding: 2px 10px; border-radius: 20px; white-space: nowrap; }
.top .menu-btn { display: none; }
.wrap { padding: 24px; max-width: 1320px; width: 100%; }

@media (max-width: 1023px) {
  .side { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s ease; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(6,30,71,.5); }
  .top .menu-btn { display: inline-flex; }
  .top { padding: 8px 16px; }
  .wrap { padding: 16px; }
  .who .meta, .session-chip { display: none; }
  .top h1 { font-size: 1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top .sp { display: none; }
  .who .btn span { display: none; }
}

/* ---------------------------------------------------------------- Cards, grids */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .g4, .g3, .g2 { grid-template-columns: minmax(0, 1fr); } }
.card { background: #fff; border: 1px solid var(--tint-3); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card > h3, .card-title { font-size: 1rem; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title .sp, .card > h3 .sp { flex: 1; }
.card-title a { font-size: .875rem; font-weight: 600; }

.kpi { min-height: 150px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; border: 0; color: #fff; padding: 20px 16px; }
.kpi .l { font-size: 1rem; font-weight: 600; }
.kpi .v { font-size: clamp(2.2rem, 4vw, 3.4rem); font-weight: 800; line-height: 1.05; margin: 8px 0; white-space: nowrap; }
.kpi .s { font-size: .85rem; opacity: .95; }
.kpi.k1 { background: var(--primary); }
.kpi.k2 { background: var(--ink-2); }
.kpi.k3 { background: var(--kpi-amber); }
.kpi.k4 { background: var(--bad); }

/* ---------------------------------------------------------------- Customer tiles (periodic table) */
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .8rem; color: var(--text); margin-bottom: 8px; align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.brand-key { font-size: .8rem; color: var(--muted); margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile {
  position: relative; min-height: 196px; border: 2px solid var(--tint-3); border-radius: 10px; background: #fff;
  padding: 10px 10px 8px; display: flex; flex-direction: column; align-items: center; text-decoration: none; color: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(31,69,145,.18); color: inherit; }
.tile .no { position: absolute; left: 9px; top: 7px; font-size: .75rem; color: var(--muted); font-weight: 600; }
.tile .dot { position: absolute; right: 9px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--border); }
.tile .dot.online { background: #22B573; box-shadow: 0 0 0 3px rgba(34,181,115,.2); animation: pulse 1.6s infinite; }
.tile .dot.offline { background: var(--bad); box-shadow: 0 0 0 3px rgba(176,51,37,.2); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(34,181,115,.07); } }
.tile .sym { font-size: 2.8rem; font-weight: 800; color: var(--ink); margin-top: 16px; line-height: 1; letter-spacing: -1px; }
.tile .nm { font-size: .8rem; color: var(--text); margin: 6px 0 8px; text-align: center; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .bk { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; flex: 1; align-content: flex-start; }
.bk i, .bdg { font-style: normal; font-size: .72rem; font-weight: 700; background: var(--tint-2); color: var(--primary-dark); border: 1px solid var(--tint-3); border-radius: 5px; padding: 1px 6px; }
.tile .ex { margin-top: 6px; width: 100%; text-align: center; font-size: .75rem; font-weight: 700; border-radius: 6px; padding: 3px 0; background: var(--gray-1); color: var(--muted); }
.tile.r-bad { border-color: #E39D93; } .tile.r-warn { border-color: #EBBE68; } .tile.r-ok { border-color: #9FD6B9; }
.tile.r-bad .ex { background: var(--bad-bg); color: var(--bad); }
.tile.r-warn .ex { background: var(--warn-bg); color: var(--warn); }
.tile.r-ok .ex { background: var(--ok-bg); color: var(--ok); }
.tile.add { border-style: dashed; justify-content: center; color: var(--primary); font-weight: 700; background: var(--surface-tint); text-align: center; }
.tile.add b { font-size: 2.5rem; line-height: 1; }
.tiles .empty { grid-column: 1 / -1; }
.cust-symbol { width: 72px; height: 72px; border-radius: 10px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; flex: none; }

/* ---------------------------------------------------------------- Tables, tags */
.tbl { overflow-x: auto; border: 1px solid var(--tint-3); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--tint-3); background: var(--surface-tint); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-1); vertical-align: top; font-size: .92rem; }
tr:last-child td { border-bottom: 0; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--tint-2); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.t-ok { background: var(--ok-bg); color: var(--ok); }
.t-warn { background: var(--warn-bg); color: var(--warn); }
.t-bad { background: var(--bad-bg); color: var(--bad); }
.t-info { background: var(--tint-2); color: var(--primary-dark); }
.t-gray { background: var(--gray-1); color: var(--text); }
.chip { display: inline-block; margin: 0 4px 4px 0; padding: 2px 9px; border-radius: 6px; background: var(--tint-2); color: var(--primary-dark); font-size: .8rem; font-weight: 600; border: 1px solid var(--tint-3); }

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer;
  font-weight: 600; font-size: .92rem; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn.sec { background: #fff; color: var(--primary); }
.btn.sec:hover { background: var(--tint-2); color: var(--primary-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.bar .sp { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--primary); border-radius: 8px; overflow: hidden; }
.seg a { padding: 8px 14px; min-height: 42px; display: inline-flex; align-items: center; gap: 6px; color: var(--primary); text-decoration: none; font-weight: 600; background: #fff; }
.seg a.on { background: var(--primary); color: #fff; }
.inline-form { display: inline; }

/* ---------------------------------------------------------------- Forms */
label, .label { display: block; font-size: .875rem; font-weight: 600; color: var(--text); margin: 12px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--tint-4); border-radius: 8px; background: #fff;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--bad); }
.help { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.err { font-size: .85rem; color: var(--bad); margin-top: 4px; font-weight: 600; }
.err::before { content: "⚠ "; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 600px) { .row2 { grid-template-columns: minmax(0, 1fr); } }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; padding: 0; margin: 0; list-style: none; }
.check-list li { display: flex; gap: 10px; align-items: center; min-height: 40px; }
.check-list label { font-weight: 400; margin: 0; }
.check-list input { width: 20px; height: 20px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 40px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; display: grid; place-items: center; }
.meter { height: 6px; background: var(--gray-1); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--bad); transition: width .2s ease; }
.meter-label { font-size: .8rem; margin-top: 4px; color: var(--muted); }
.hp { position: absolute; left: -5000px; }

/* ---------------------------------------------------------------- Messages / notes */
.msgs { display: grid; gap: 8px; margin-bottom: 16px; }
.msg, .note { padding: 12px 14px; border-radius: 8px; border: 1px solid var(--tint-3); background: var(--tint-2); color: var(--ink); font-size: .92rem; display: flex; gap: 10px; align-items: flex-start; }
.msg.success { background: var(--ok-bg); border-color: #A8DDC1; color: #0F4D31; }
.msg.error { background: var(--bad-bg); border-color: #EFB2A9; color: #7A2219; }
.msg.warning { background: var(--warn-bg); border-color: #F0CF8E; color: #5C3C07; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty .icon { color: var(--tint-4); }

/* ---------------------------------------------------------------- Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(6,30,71,.62); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 80; }
.modal-bg.on { display: flex; }
.modal { background: #fff; border-radius: 12px; max-width: 820px; width: 100%; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); position: relative; }
.modal .x { position: absolute; right: 12px; top: 12px; width: 44px; height: 44px; border: 0; background: none; cursor: pointer; color: var(--muted); border-radius: 8px; display: grid; place-items: center; }
.modal .x:hover { background: var(--gray-1); }
.mtabs { display: flex; gap: 4px; margin: 16px 0 12px; border-bottom: 1px solid var(--tint-3); overflow-x: auto; }
.mtabs a { padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; text-decoration: none; white-space: nowrap; }
.mtabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
.skeleton { background: linear-gradient(90deg, var(--gray-1), #f8f9fa, var(--gray-1)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 18px; margin: 10px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Session warning */
.session-modal { max-width: 440px; text-align: center; }
.session-modal .count { font-size: 2.4rem; font-weight: 800; color: var(--ink); margin: 8px 0 12px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); background: radial-gradient(circle at 30% 20%, var(--primary-dark), var(--ink) 65%); }
.auth .panel-brand { display: none; }
.auth .panel-form { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 440px; background: #fff; border-radius: 14px; padding: 28px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.auth-card .logo { display: block; width: 100%; max-width: 280px; margin: 0 auto 12px; border-radius: 10px; }
.auth-card h1 { font-size: 1.35rem; text-align: center; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 6px 0 16px; font-size: .92rem; }
.auth-card .links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-size: .9rem; }
.auth-card .center { text-align: center; }
.qr { display: grid; place-items: center; margin: 12px auto; width: 220px; height: 220px; background: #fff; border: 1px solid var(--tint-3); border-radius: 10px; padding: 6px; }
.qr svg { width: 100%; height: 100%; }
.setup-key { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .95rem; letter-spacing: .04em; background: var(--surface-tint); border: 1px dashed var(--tint-4); padding: 10px; border-radius: 8px; text-align: center; word-break: break-all; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 0; list-style: none; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 1.05rem; }
.codes li { background: var(--surface-tint); border: 1px solid var(--tint-3); border-radius: 8px; padding: 8px; text-align: center; }
.otp-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.steps-mini { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; }
.steps-mini span { width: 28px; height: 6px; border-radius: 4px; background: var(--gray-1); }
.steps-mini span.on { background: var(--primary); }
@media (min-width: 960px) {
  .auth { grid-template-columns: 1.1fr 1fr; }
  .auth .panel-brand { display: flex; flex-direction: column; justify-content: center; padding: 48px; color: #fff; }
  .auth .panel-brand img { width: 100%; max-width: 520px; border-radius: 12px; }
  .auth .panel-brand h2 { color: #fff; font-size: 1.6rem; margin: 24px 0 8px; }
  .auth .panel-brand p { color: #CFDDF5; max-width: 520px; }
  .auth .panel-form { background: var(--surface-tint); }
  .auth-card { box-shadow: var(--shadow); border: 1px solid var(--tint-3); }
  .auth-card .logo { display: none; }
}

/* ---------------------------------------------------------------- Charts */
.chart svg { width: 100%; height: auto; display: block; background: linear-gradient(var(--surface-tint), #fff); border: 1px solid var(--tint-3); border-radius: 8px; }
.chart .lbl { font-size: 11px; fill: var(--muted); }
.chart .val { font-size: 12px; font-weight: 700; fill: var(--ink); }

/* ---------------------------------------------------------------- Help */
.help-page h2 { margin: 24px 0 8px; }
.help-page ol, .help-page ul { padding-left: 22px; }
.help-page li { margin-bottom: 6px; }
.flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 16px; }
.flow span { background: #fff; border: 1px solid var(--tint-3); border-radius: 8px; padding: 6px 10px; font-size: .85rem; }
.flow i { color: var(--muted); font-style: normal; }

@media print {
  .side, .top, .no-print { display: none !important; }
}
