/* ARES Console — styled after Apple's Human Interface Guidelines (macOS / iPadOS):
   system font, semantic colours with a dark appearance, a material sidebar, a toolbar,
   grouped content, and a tab bar in compact widths. */

:root{
  color-scheme: light dark;
  --bg:#f2f2f7;              /* grouped background */
  --card:#ffffff;            /* secondary grouped background */
  --fill:rgba(120,120,128,.12);
  --fill-2:rgba(120,120,128,.08);
  --label:#1c1c1e;
  --label-2:rgba(60,60,67,.72);
  --label-3:rgba(60,60,67,.5);
  --sep:rgba(60,60,67,.18);
  --accent:#3d6b2c;          /* brand green, 4.5:1 on white */
  --accent-tint:rgba(61,107,44,.12);
  --on-accent:#ffffff;
  --green:#1f7a35; --green-tint:rgba(31,122,53,.12);
  --orange:#a34d00; --orange-tint:rgba(201,105,0,.14);
  --red:#c4161c; --red-tint:rgba(215,0,21,.1);
  --sidebar:rgba(236,236,240,.78);
  --bar:rgba(242,242,247,.8);
  --shadow:0 1px 2px rgba(0,0,0,.04), 0 2px 10px rgba(0,0,0,.04);
  --font:-apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-display:-apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono:ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r:12px;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#000000; --card:#1c1c1e; --fill:rgba(120,120,128,.24); --fill-2:rgba(120,120,128,.16);
    --label:#f5f5f7; --label-2:rgba(235,235,245,.7); --label-3:rgba(235,235,245,.45); --sep:rgba(84,84,88,.6);
    --accent:#8cc66b; --accent-tint:rgba(140,198,107,.16); --on-accent:#0b1406;
    --green:#30d158; --green-tint:rgba(48,209,88,.16);
    --orange:#ff9f0a; --orange-tint:rgba(255,159,10,.16);
    --red:#ff453a; --red-tint:rgba(255,69,58,.16);
    --sidebar:rgba(30,30,32,.78); --bar:rgba(0,0,0,.72);
    --shadow:none;
  }
}

*{box-sizing:border-box;margin:0;padding:0}
html{-webkit-text-size-adjust:100%}
body{background:var(--bg);color:var(--label);font-family:var(--font);font-size:15px;line-height:1.45;-webkit-font-smoothing:antialiased;letter-spacing:-.005em}
button,input,select,textarea{font:inherit;color:inherit}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3{font-family:var(--font-display);font-weight:700;letter-spacing:-.02em;line-height:1.15}
h1{font-size:30px}
h2{font-size:19px;letter-spacing:-.01em}
h3{font-size:16px;font-weight:600}
.boot{padding:40px;color:var(--label-2)}
.muted{color:var(--label-2)}
.small{font-size:13px}
.num{font-variant-numeric:tabular-nums}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
svg.ic{width:18px;height:18px;flex-shrink:0;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}

/* ---------- shell: sidebar + toolbar + content ---------- */
.shell{display:grid;grid-template-columns:248px 1fr;min-height:100vh}
.shell.collapsed{grid-template-columns:0 1fr}
.side{position:sticky;top:0;height:100vh;overflow:hidden;background:var(--sidebar);
  -webkit-backdrop-filter:saturate(180%) blur(24px);backdrop-filter:saturate(180%) blur(24px);
  border-right:1px solid var(--sep);padding:14px 10px;display:flex;flex-direction:column;gap:2px}
.shell.collapsed .side{visibility:hidden;padding:0;border:0}
.brand{display:flex;align-items:center;gap:10px;padding:6px 10px 16px;color:var(--label);text-decoration:none}
.brand img{width:30px;height:30px;border-radius:8px;background:#fff;border:1px solid var(--sep)}
.brand b{display:block;font-size:15px;font-weight:600;line-height:1.1}
.brand small{font-size:11.5px;color:var(--label-2)}
.side .group{font-size:11.5px;font-weight:600;color:var(--label-3);padding:14px 10px 4px;letter-spacing:.01em}
.side a.nav{display:flex;align-items:center;gap:10px;min-height:34px;padding:6px 10px;border-radius:8px;color:var(--label);font-size:14px;text-decoration:none}
.side a.nav svg{color:var(--accent)}
.side a.nav:hover{background:var(--fill-2)}
.side a.nav.on{background:var(--accent-tint);font-weight:600}
.side a.nav:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}

.content{min-width:0;display:flex;flex-direction:column}
.toolbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 20px;
  background:var(--bar);-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px);border-bottom:1px solid var(--sep)}
.toolbar .title{font-weight:600;font-size:15px}
.toolbar .spacer{flex:1}
.icon-btn{display:inline-grid;place-items:center;width:34px;height:34px;border-radius:8px;border:0;background:none;color:var(--label-2);cursor:pointer}
.icon-btn:hover{background:var(--fill-2);color:var(--label)}
.menu-btn{display:inline-flex;align-items:center;gap:8px;border:0;background:var(--fill-2);border-radius:999px;padding:4px 12px 4px 4px;cursor:pointer;font-size:13.5px}
.menu-btn .av{width:26px;height:26px;font-size:11px}
.popover{position:absolute;right:16px;top:50px;background:var(--card);border:1px solid var(--sep);border-radius:12px;box-shadow:0 10px 30px rgba(0,0,0,.18);padding:6px;min-width:220px;z-index:30}
.popover .who{padding:8px 10px 10px;border-bottom:1px solid var(--sep);margin-bottom:4px}
.popover .who b{display:block}
.popover a,.popover button{display:flex;width:100%;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;border:0;background:none;color:var(--label);text-align:left;cursor:pointer;text-decoration:none;font-size:14px}
.popover a:hover,.popover button:hover{background:var(--fill-2);text-decoration:none}

.main{padding:22px 28px 60px;max-width:1280px;width:100%}
.head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin-bottom:20px}
.head p{margin-top:4px}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.grid2 > *,.metrics > *{min-width:0}

/* ---------- tab bar (compact width) ---------- */
.tabbar{display:none}

/* ---------- segmented control ---------- */
.seg{display:inline-grid;grid-auto-flow:column;grid-auto-columns:1fr;background:var(--fill);border-radius:9px;padding:2px;gap:2px}
.seg button{border:0;background:none;border-radius:7px;padding:5px 14px;font-size:13px;font-weight:500;cursor:pointer;color:var(--label);min-height:28px;white-space:nowrap}
.seg button[aria-pressed="true"]{background:var(--card);box-shadow:0 1px 3px rgba(0,0,0,.12),0 0 0 .5px rgba(0,0,0,.04);font-weight:600}
@media (prefers-color-scheme: dark){.seg button[aria-pressed="true"]{background:#636366}}
.seg button:focus-visible{outline:2px solid var(--accent);outline-offset:1px}

/* ---------- grouped boxes ---------- */
.card{background:var(--card);border-radius:var(--r);padding:16px 18px;box-shadow:var(--shadow)}
.card + .card{margin-top:16px}
.card h2{margin-bottom:4px}
.card .sub{font-size:13px;color:var(--label-2);margin-bottom:12px}
.card .cap{display:flex;justify-content:space-between;align-items:baseline;gap:10px;margin-bottom:10px}
.card .cap h2{margin:0}
.section-title{font-size:13px;font-weight:600;color:var(--label-2);margin:26px 4px 8px;text-transform:none}

.metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:12px}
.metric{background:var(--card);border-radius:var(--r);padding:14px 16px;box-shadow:var(--shadow);display:flex;flex-direction:column;gap:6px;min-height:104px}
.metric .top{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:600;color:var(--label-2)}
.metric .top svg{color:var(--accent);width:16px;height:16px}
.metric .v{font-family:var(--font-display);font-size:30px;font-weight:700;letter-spacing:-.02em;font-variant-numeric:tabular-nums;line-height:1.05}
.metric .v small{font-size:15px;font-weight:600;color:var(--label-2);margin-left:3px}
.metric .mnote{font-size:12.5px;color:var(--label-2)}
.metric .mnote.bad{color:var(--red);font-weight:600}

/* inset grouped list */
.ilist{display:flex;flex-direction:column}
.ilist .it{display:flex;align-items:center;gap:12px;min-height:52px;padding:8px 0;border-bottom:1px solid var(--sep)}
.ilist .it:last-child{border-bottom:0}
.ilist .it .main-t{flex:1;min-width:0}
.ilist .it .main-t b{display:block;font-weight:600;font-size:14.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ilist .it .main-t span{display:block;font-size:13px;color:var(--label-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ilist .it .trail{font-size:13px;color:var(--label-2);text-align:right;white-space:nowrap}
.av{width:34px;height:34px;border-radius:50%;background:var(--accent-tint);color:var(--accent);display:grid;place-items:center;font-weight:700;font-size:13px;flex-shrink:0}
.empty{color:var(--label-2);font-size:14px;padding:10px 0}

/* status labels: colour always paired with text */
.pill{display:inline-flex;align-items:center;gap:5px;border-radius:999px;padding:2px 9px;font-size:12px;font-weight:600;white-space:nowrap}
.pill::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}
.pill.active,.pill.ok{background:var(--green-tint);color:var(--green)}
.pill.hold,.pill.warn{background:var(--orange-tint);color:var(--orange)}
.pill.revoked,.pill.bad{background:var(--red-tint);color:var(--red)}
.pill.soft{background:var(--fill-2);color:var(--label-2)}
.pill.tag{background:var(--fill-2);color:var(--label);font-family:var(--mono);font-weight:600}
.pill.tag::before,.pill.soft::before{display:none}
.live{display:inline-flex;align-items:center;gap:6px;color:var(--green);font-size:12px;font-weight:600}
.live::before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor;box-shadow:0 0 0 3px var(--green-tint)}

/* ---------- tables ---------- */
.scroll{overflow-x:auto;margin:0 -18px;padding:0 18px}
.scroll table{min-width:860px}
table{width:100%;border-collapse:collapse;font-size:14px}
th,td{text-align:left;padding:9px 10px;vertical-align:top}
th{font-size:12px;font-weight:600;color:var(--label-2);white-space:nowrap;border-bottom:1px solid var(--sep)}
th button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:4px;border-radius:4px}
th button:hover{color:var(--label)}
th button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
th[aria-sort] button{color:var(--label)}
td.n,th.n{text-align:right;font-variant-numeric:tabular-nums}
th.n button{flex-direction:row-reverse}
tbody tr:nth-child(even) td{background:var(--fill-2)}
tbody tr td:first-child{border-radius:8px 0 0 8px}
tbody tr td:last-child{border-radius:0 8px 8px 0}
td select{min-width:140px}

/* ---------- chart ---------- */
.chart{display:grid;grid-template-columns:auto 1fr;gap:0 8px;margin-top:6px}
.chart .yaxis{display:flex;flex-direction:column;justify-content:space-between;height:160px;font-size:11px;color:var(--label-3);text-align:right;font-variant-numeric:tabular-nums}
.chart .plot{position:relative;height:160px;display:flex;align-items:flex-end;gap:5px;border-bottom:1px solid var(--label-3)}
.chart .grid{position:absolute;left:0;right:0;border-top:1px dashed var(--sep)}
.chart .bar{flex:1;display:flex;justify-content:center;height:100%;align-items:flex-end;position:relative;z-index:1}
.chart .bar i{display:block;width:100%;max-width:28px;background:var(--accent);border-radius:4px 4px 0 0}
.chart .bar.today i{background:var(--green)}
.chart .bar:hover i{filter:brightness(1.12)}
.chart .xaxis{grid-column:2;display:flex;gap:5px;font-size:11px;color:var(--label-3);margin-top:4px}
.chart .xaxis span{flex:1;text-align:center;white-space:nowrap}
.chart-summary{font-size:14px;margin:2px 0 10px}

/* ---------- buttons ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;border:0;border-radius:8px;min-height:32px;padding:6px 14px;font-weight:600;font-size:14px;cursor:pointer;background:var(--accent);color:var(--on-accent)}
.btn:hover{filter:brightness(1.08)}
.btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.btn.ghost{background:var(--fill);color:var(--label)}
.btn.small{min-height:28px;padding:4px 11px;font-size:13px}
.btn.danger{background:var(--red-tint);color:var(--red)}
.btn.warn{background:var(--orange-tint);color:var(--orange)}
.btn:disabled{opacity:.4;cursor:not-allowed;filter:none}

/* ---------- other pages ---------- */
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{white-space:nowrap;display:inline-flex;align-items:center;gap:6px;background:var(--fill-2);border-radius:999px;padding:4px 10px;font-size:12.5px;cursor:pointer;user-select:none;border:1px solid transparent}
.chip input{accent-color:var(--accent);margin:0}
.chip.on{background:var(--accent-tint);border-color:transparent}
.chip.ro{cursor:default}
.chip button{border:0;background:none;cursor:pointer;color:var(--label-2);font-size:15px;line-height:1;padding:0 0 0 2px}
.person{display:grid;grid-template-columns:1.3fr 2fr auto;gap:16px;align-items:start;padding:16px 0;border-bottom:1px solid var(--sep)}
.person:last-child{border-bottom:0}
.person .nm{font-weight:600}
.person .actions{display:flex;flex-direction:column;gap:6px;align-items:stretch}
.list > div{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--sep)}
.list > div:last-child{border-bottom:0}
.cols{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.task{border-radius:10px;padding:12px;background:var(--fill-2)}
.task + .task{margin-top:10px}
.task .t{font-weight:600}
.task .meta{font-size:12.5px;color:var(--label-2);margin:6px 0 10px;display:flex;flex-wrap:wrap;gap:6px 10px;align-items:center}
.task.late{box-shadow:inset 3px 0 0 var(--red)}
.dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--green);margin-right:6px}

/* ---------- forms & dialogs ---------- */
label.f{display:grid;gap:5px;font-size:13px;font-weight:600;color:var(--label-2)}
label.f + label.f,.fgrid + label.f,label.f + .fgrid{margin-top:12px}
.fgrid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
input[type=text],input[type=password],input[type=date],input[type=tel],select,textarea{border:1px solid var(--sep);background:var(--card);border-radius:8px;padding:8px 11px;font-weight:400;width:100%;color:var(--label);min-height:36px}
input:focus,select:focus,textarea:focus{outline:3px solid var(--accent-tint);border-color:var(--accent)}
.hint{font-size:12.5px;color:var(--label-3);font-weight:400}
.err{background:var(--red-tint);color:var(--red);border-radius:8px;padding:10px 12px;font-size:14px;margin-top:12px}
.note{background:var(--orange-tint);color:var(--label);border-radius:8px;padding:10px 12px;font-size:13.5px}
dialog{margin:auto;border:0;border-radius:14px;padding:0;width:min(560px,94vw);max-height:90vh;background:var(--card);color:var(--label);box-shadow:0 24px 70px rgba(0,0,0,.3)}
dialog::backdrop{background:rgba(0,0,0,.35)}
dialog form,dialog .body{padding:22px}
dialog h2{margin-bottom:14px}
dialog .foot{display:flex;justify-content:flex-end;gap:10px;margin-top:20px}
.secret{font-family:var(--mono);font-size:18px;background:var(--fill-2);border-radius:8px;padding:12px 14px;letter-spacing:.04em;user-select:all;word-break:break-all;color:var(--label)}
fieldset{border:0}
fieldset legend{font-size:13px;font-weight:600;color:var(--label-2);margin:14px 0 6px}

/* ---------- sign-in ---------- */
.gate{min-height:100vh;display:grid;place-items:center;padding:20px}
.gate .card{width:min(400px,100%);padding:28px}
.gate .brand{padding:0 0 18px}
.gate h1{font-size:24px;margin-bottom:6px}
.gate form{margin-top:18px}
.gate .btn{width:100%;margin-top:18px;min-height:40px}

.toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);background:var(--label);color:var(--bg);padding:10px 18px;border-radius:999px;font-size:14px;z-index:99;box-shadow:0 8px 24px rgba(0,0,0,.25)}

@media (prefers-reduced-motion: no-preference){
  .seg button,.btn,.side a.nav,.chart .bar i{transition:background-color .15s ease, box-shadow .15s ease, filter .15s ease}
}

@media (max-width:1100px){.cols{grid-template-columns:1fr 1fr}.grid2{grid-template-columns:1fr}}

/* Compact width: sidebar becomes a tab bar (HIG: tab bars for compact environments). */
@media (max-width:820px){
  .shell,.shell.collapsed{grid-template-columns:1fr}
  .side,.sidebar-toggle{display:none}
  .toolbar{padding:8px 14px}
  .main{padding:16px 16px 96px}
  .tabbar{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:40;background:var(--bar);
    -webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px);
    border-top:1px solid var(--sep);padding:6px 4px calc(6px + env(safe-area-inset-bottom))}
  .tabbar a{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;min-height:44px;justify-content:center;font-size:10.5px;font-weight:500;color:var(--label-3);text-decoration:none}
  .tabbar a svg{width:22px;height:22px}
  .tabbar a.on{color:var(--accent)}
  .person{grid-template-columns:1fr}
  .person .actions{flex-direction:row;flex-wrap:wrap}
  .cols,.fgrid{grid-template-columns:1fr}
  .head .seg{width:100%}
  h1{font-size:26px}
}
