﻿/* AUREX dashboard. System fonts, no images, no libraries: a few KB. */
:root {
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f8f9fc; --line: #e3e7ee; --line-2: #eef1f6;
  --text: #0f1729; --muted: #5d6b82; --faint: #8a96a8;
  --accent: #4338ca; --accent-2: #eef0ff; --accent-text: #ffffff;
  --good: #0e8a5f; --good-bg: #e4f6ee; --bad: #d1293d; --bad-bg: #fdeaec; --warn: #a85b00; --warn-bg: #fff2dc; --info-bg: #eef0ff;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --radius: 12px; color-scheme: light;
}
/* "auto" follows the device; data-theme="light" or "dark" is the owner's explicit choice (Settings). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark;
    --bg: #0a0e16; --surface: #121826; --surface-2: #0f1522; --line: #232c3e; --line-2: #1a2232;
    --text: #e8ebf3; --muted: #94a0b6; --faint: #6c7890;
    --accent: #8a8cff; --accent-2: #1d2140; --accent-text: #0a0e16;
    --good: #3ddc97; --good-bg: #11301f; --bad: #ff6b7a; --bad-bg: #3a1620; --warn: #f5b84b; --warn-bg: #36280d; --info-bg: #1d2140;
    --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
:root[data-theme="dark"] { color-scheme: dark;
  --bg: #0a0e16; --surface: #121826; --surface-2: #0f1522; --line: #232c3e; --line-2: #1a2232;
  --text: #e8ebf3; --muted: #94a0b6; --faint: #6c7890;
  --accent: #8a8cff; --accent-2: #1d2140; --accent-text: #0a0e16;
  --good: #3ddc97; --good-bg: #11301f; --bad: #ff6b7a; --bad-bg: #3a1620; --warn: #f5b84b; --warn-bg: #36280d; --info-bg: #1d2140;
  --shadow: 0 1px 2px rgba(0,0,0,.4); }
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 750; letter-spacing: .14em; font-size: 17px; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-size: 15px; letter-spacing: 0; }
.navbtn { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border: 0; border-radius: 9px; background: none; color: var(--muted); cursor: pointer; text-align: left; font-weight: 550; }
.navbtn:hover { background: var(--surface-2); color: var(--text); }
.navbtn.on { background: var(--accent-2); color: var(--accent); }
.grow { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); margin: 6px -12px -18px; padding: 14px 22px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-2); color: var(--accent); display: grid; place-items: center; font-weight: 700; text-transform: uppercase; }
.userbox .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { border: 0; background: none; color: var(--muted); padding: 7px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.title { font-size: 19px; font-weight: 700; margin-right: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.page { max-width: 1180px; padding: 22px 24px 90px; }
.btn-estop { display: inline-flex; align-items: center; gap: 7px; background: var(--bad); color: #fff; border: 0; border-radius: 9px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.btn-estop:hover { filter: brightness(1.08); }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card > h3, .card-head h3 { font-size: 14.5px; font-weight: 650; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section { margin: 26px 0 10px; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stack { display: grid; gap: 14px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi .value { font-size: 26px; font-weight: 720; margin-top: 4px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--faint); font-size: 12.5px; margin-top: 2px; }
.kpi svg.spark { width: 100%; height: 34px; margin-top: 8px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-2); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.info { background: var(--info-bg); color: var(--accent); border-color: transparent; }
.up { color: var(--good); } .down { color: var(--bad); } .muted { color: var(--muted); } .faint { color: var(--faint); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.good { background: var(--good); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--info-bg); color: var(--text); border: 1px solid var(--line); }
.alert.bad { background: var(--bad-bg); border-color: transparent; } .alert.warn { background: var(--warn-bg); border-color: transparent; } .alert.good { background: var(--good-bg); border-color: transparent; }
.alert svg.i { margin-top: 2px; } .alert.bad svg.i { color: var(--bad); } .alert.warn svg.i { color: var(--warn); } .alert.good svg.i { color: var(--good); }
.alert .grow { min-width: 0; } .alert b { font-weight: 650; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 9px; padding: 8px 15px; font-weight: 650; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.card .row:not(.card-head), dialog .row { margin-top: 14px; }
.card .alert { margin-top: 12px; }

label.lbl { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
input[type=text], input[type=password], input[type=number], input:not([type]), select { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.switch-row:last-child { border-bottom: 0; }
.switch-row .t { font-weight: 600; } .switch-row .d { color: var(--muted); font-size: 12.5px; }
.toggle { position: relative; width: 40px; height: 23px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s; }
.toggle span::after { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.toggle input:checked + span { background: var(--accent); } .toggle input:checked + span::after { transform: translateX(17px); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; color: var(--muted); cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; word-break: break-all; }
.steps { margin: 0; padding-left: 18px; color: var(--muted); } .steps li { margin: 6px 0; } .steps b { color: var(--text); }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { position: sticky; top: 0; text-align: left; padding: 10px 14px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty b { display: block; color: var(--text); margin-bottom: 2px; }

/* health list */
.health { display: grid; gap: 0; }
.health > div { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.health > div:last-child { border-bottom: 0; }
.health .k { flex: 1; } .health .v { color: var(--muted); font-size: 13px; text-align: right; }

/* chart */
svg.chart { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-area { fill: var(--accent); opacity: .1; }
.chart-zero { stroke: var(--line); stroke-dasharray: 4 4; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-txt { fill: var(--faint); font-size: 11px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.8; vector-effect: non-scaling-stroke; stroke-linejoin: round; }

/* feedback */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: pop .18s ease-out; font-weight: 550; }
.toast.good { background: var(--good); color: #fff; } .toast.bad { background: var(--bad); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 20px; width: min(400px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(8,12,20,.55); }
dialog h3 { font-size: 16px; margin-bottom: 6px; }
.skel { height: 90px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: sh 1.2s infinite; border: 1px solid var(--line); }
@keyframes sh { to { background-position: -200% 0; } }

/* auth screens */
.authwrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.authcard { width: min(400px, 100%); }
.authcard .brand { justify-content: center; padding-bottom: 6px; font-size: 22px; }
.authcard .tag { text-align: center; color: var(--muted); margin-bottom: 18px; }

/* ---------- phones ---------- */
.bottom { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { padding: 10px 14px; }
  .title { font-size: 17px; }
  .page { padding: 16px 14px 96px; }
  .bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottom button { border: 0; background: none; color: var(--faint); display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 10.5px; font-weight: 600; cursor: pointer; }
  .bottom button.on { color: var(--accent); }
  .g2 { grid-template-columns: 1fr; }
  .btn-estop span { display: none; }
  #toasts { bottom: 78px; }
  .chips { order: 5; flex-basis: 100%; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 13px; }
  .kpi .value { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
}

dialog.wide { width: min(880px, 96vw); max-height: 92vh; overflow: auto; }

/* project progress */
svg.pbar { width: 100%; height: 8px; display: block; margin-top: 6px; }
svg.pbar.thin { height: 5px; }
.pbar-bg { fill: var(--line); } .pbar-fg { fill: var(--accent); }
.row.between { justify-content: space-between; width: 100%; }
button.progress { width: calc(100% - 8px); margin: 8px 4px; text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; cursor: pointer; font-size: 13px; color: var(--muted); }
button.progress:hover { border-color: var(--accent); }
button.progress b { color: var(--text); }
button.card.progress-card { width: 100%; text-align: left; cursor: pointer; display: block; color: var(--text); }
button.card.progress-card:hover { border-color: var(--accent); }

/* agent chat */
.chat { display: grid; gap: 10px; max-height: 52vh; overflow-y: auto; padding: 4px 2px 10px; min-height: 120px; }
.bubble { max-width: 88%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.bubble.user { justify-self: end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.bubble.assistant { justify-self: start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.steps-line { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.pbar.warn .pbar-fg { fill: var(--warn); } .pbar.bad .pbar-fg { fill: var(--bad); }
