/* AliHapp HQ — command-center UI. Dark glass, live status rings, glowing org chart. RTL first. */
@font-face { font-family: "Vazirmatn"; src: url("vazirmatn.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #060a16;
  --bg2: #0b1124;
  --glass: rgba(255, 255, 255, .045);
  --glass2: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .09);
  --line2: rgba(255, 255, 255, .16);
  --fg: #e9edf8;
  --muted: #8f99b5;
  --dim: #5d6785;
  --indigo: #7c8cff;
  --violet: #b17cff;
  --teal: #2ee6c5;
  --green: #4ade80;
  --amber: #ffb547;
  --red: #ff5d73;
  --gold: #ffd479;
  --radius: 18px;
  --shadow: 0 20px 50px -24px rgba(0, 0, 0, .8);
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--fg); font: 15px/1.75 "Vazirmatn", Tahoma, system-ui, sans-serif;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(124, 140, 255, .18), transparent 60%),
    radial-gradient(700px 500px at 0% 10%, rgba(46, 230, 197, .10), transparent 60%),
    radial-gradient(800px 600px at 50% 120%, rgba(177, 124, 255, .12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
body::before { /* faint blueprint grid */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 75%);
}
a { color: inherit; text-decoration: none; }
svg { width: 1.15em; height: 1.15em; flex: none; }
h1, h2, h3 { margin: 0; line-height: 1.4; }
p { margin: 0; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.9 "Vazirmatn", Tahoma, sans-serif; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
::selection { background: rgba(124, 140, 255, .35); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; padding: 12px clamp(14px, 3vw, 32px);
  background: rgba(6, 10, 22, .72); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .bt { display: grid; line-height: 1.25; }
.brand b { font-weight: 800; letter-spacing: .2px; }
.brand small { color: var(--muted); font-size: 11.5px; }
.logo {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--indigo), var(--violet)); box-shadow: 0 8px 24px -8px var(--indigo), inset 0 1px 0 rgba(255,255,255,.3);
}
.logo.big { width: 64px; height: 64px; border-radius: 20px; font-size: 28px; margin: 0 auto 6px; }
.nav { display: flex; gap: 4px; margin-inline-start: auto; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; color: var(--muted);
  transition: color .2s, background .2s;
}
.nav a:hover { color: var(--fg); background: var(--glass); }
.nav a.on { color: var(--fg); background: var(--glass2); box-shadow: inset 0 0 0 1px var(--line); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: inline-grid; place-items: center; font: 700 11.5px/1 "Vazirmatn";
  color: #fff; background: linear-gradient(135deg, var(--red), #ff8a5c); box-shadow: 0 0 0 3px rgba(255, 93, 115, .18); font-style: normal;
}
.live { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--dim); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.live.on { color: var(--green); }
.live.on i { background: var(--green); box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); animation: ping 2s infinite; }
.logout button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 10px; display: grid; }
.logout button:hover { color: var(--red); background: var(--glass); }

/* ---------- page ---------- */
main { position: relative; z-index: 1; }
.page { max-width: 1440px; margin: 0 auto; padding: 26px clamp(14px, 3vw, 32px) 90px; animation: rise .5s var(--ease) both; }
.bare { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.back { display: inline-flex; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.back:hover { color: var(--fg); }

.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.hero h1 {
  font-size: clamp(26px, 3.4vw, 40px); font-weight: 900; letter-spacing: -.3px;
  background: linear-gradient(90deg, #fff, #c9d2ff 60%, var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--muted); max-width: 620px; margin-top: 6px; }
.hero.small h1 { font-size: clamp(22px, 2.6vw, 30px); }
.kpis { display: flex; flex-wrap: wrap; gap: 10px; }
.kpi {
  min-width: 108px; padding: 12px 16px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line);
  display: grid; gap: 2px; position: relative; overflow: hidden; transition: transform .25s var(--ease), border-color .25s;
}
.kpi::after { content: ""; position: absolute; inset: auto -20% -60% auto; width: 80px; height: 80px; border-radius: 50%; background: var(--indigo); filter: blur(30px); opacity: .25; }
.kpi b { font-size: 26px; font-weight: 900; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: 12.5px; }
.kpi.run::after { background: var(--teal); } .kpi.bad::after { background: var(--red); } .kpi.plan::after { background: var(--violet); } .kpi.alert::after { background: var(--amber); }
.kpi.alert:hover { transform: translateY(-2px); border-color: var(--line2); }

/* ---------- org chart ---------- */
/* the chart is scaled down by app.js to always fit its box (never a horizontal scroll) */
.org-wrap { display: flex; justify-content: center; overflow: hidden; padding: 8px 0 26px; }
.org { flex: none; width: max-content; transform-origin: top center; }
.tree, .tree ul { direction: ltr; display: flex; justify-content: center; margin: 0; padding: 26px 0 0; position: relative; }
.tree { padding-top: 0; }
.tree li { list-style: none; position: relative; padding: 26px 9px 0; display: flex; flex-direction: column; align-items: center; }
.tree li::before, .tree li::after { content: ""; position: absolute; top: 0; width: 50%; height: 26px; border-top: 2px solid rgba(124, 140, 255, .32); }
.tree li::before { right: 50%; }
.tree li::after { left: 50%; border-left: 2px solid rgba(124, 140, 255, .32); }
.tree li:only-child::before, .tree li:only-child::after { display: none; }
.tree li:only-child { padding-top: 0; }
/* children run right-to-left (row-reverse) so the chart reads like Persian; the first child is the rightmost */
.tree ul { flex-direction: row-reverse; }
.tree li:first-child::after, .tree li:last-child::before { border: 0 none; }
.tree li:first-child::before { border-right: 2px solid rgba(124, 140, 255, .32); border-radius: 0 12px 0 0; }
.tree li:last-child::after { border-radius: 12px 0 0 0; }
.tree ul ul::before, .tree > li > ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 26px; border-left: 2px solid rgba(124, 140, 255, .32); }
.tree > li { padding-top: 0; }
.tree > li::before, .tree > li::after { display: none; }

.card {
  direction: rtl; position: relative; width: 236px; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center;
  padding: 14px 15px; border-radius: var(--radius); background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .3s var(--ease), border-color .3s, box-shadow .3s;
}
.card:hover { transform: translateY(-4px); border-color: rgba(124, 140, 255, .45); box-shadow: 0 26px 60px -26px rgba(124, 140, 255, .55); }
.card .nm { display: grid; line-height: 1.45; min-width: 0; }
.card .nm b { font-weight: 800; font-size: 14.5px; }
.card .nm small { color: var(--muted); font-size: 12px; }
.card .pill { grid-column: 1 / -1; justify-self: start; }
.card .meta { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11.8px; border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 2px; }
.card .meta > span { display: inline-flex; align-items: center; gap: 5px; }
.card .meta b { color: var(--fg); }
.card .sched { grid-column: 1 / -1; font-size: 11.5px; color: var(--dim); }
.ic {
  position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; font-size: 20px; color: #fff;
  background: linear-gradient(135deg, #3b4675, #252d50); box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}
.ic.big { width: 72px; height: 72px; border-radius: 22px; font-size: 32px; }
/* kinds */
.k-person .ic { background: linear-gradient(135deg, var(--gold), #f08a4b); box-shadow: 0 10px 26px -10px var(--gold); }
.k-person { border-color: rgba(255, 212, 121, .35); }
.k-assistant .ic { background: linear-gradient(135deg, var(--indigo), var(--violet)); box-shadow: 0 10px 26px -10px var(--violet); }
.k-assistant { border-color: rgba(177, 124, 255, .4); background: linear-gradient(180deg, rgba(177,124,255,.14), rgba(124,140,255,.05)); }
.k-department { width: 210px; padding: 12px 14px; background: linear-gradient(180deg, rgba(124,140,255,.10), rgba(255,255,255,.02)); }
.k-department::before { content: ""; position: absolute; inset: 0 18px auto; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--indigo), transparent); }
.k-department .ic { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, #2c3a6e, #1d2547); color: #b9c3ff; }
.k-agent .ic { background: linear-gradient(135deg, #1fb8a0, #2a64d8); }
.k-service .ic { background: linear-gradient(135deg, #3c4566, #262d4a); color: #c9d2ff; }
.card.s-planned { border-style: dashed; border-color: rgba(177, 124, 255, .45); background: rgba(177, 124, 255, .05); }
.card.s-planned .ic { filter: grayscale(.6); opacity: .75; }
/* running: rotating ring around the icon */
.s-running .ic::after {
  content: ""; position: absolute; inset: -4px; border-radius: 17px; padding: 2px;
  background: conic-gradient(from 0deg, var(--teal), transparent 40%, transparent 60%, var(--teal));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin 1.6s linear infinite;
}
.s-error .ic, .s-offline .ic { box-shadow: 0 0 0 2px rgba(255, 93, 115, .55), 0 10px 26px -10px var(--red); }
.card.s-error, .card.s-offline { border-color: rgba(255, 93, 115, .45); }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 11px; border-radius: 99px; font-size: 11.8px; font-weight: 700; background: var(--glass2); color: var(--muted); border: 1px solid var(--line); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.big { font-size: 13px; padding: 4px 14px; }
.pill.s-running { color: var(--teal); background: rgba(46, 230, 197, .1); border-color: rgba(46, 230, 197, .3); }
.pill.s-running::before { animation: ping 1.6s infinite; box-shadow: 0 0 0 0 rgba(46, 230, 197, .7); }
.pill.s-idle, .pill.s-online { color: var(--green); background: rgba(74, 222, 128, .08); border-color: rgba(74, 222, 128, .25); }
.pill.s-paused { color: var(--amber); background: rgba(255, 181, 71, .1); border-color: rgba(255, 181, 71, .3); }
.pill.s-error, .pill.s-offline { color: var(--red); background: rgba(255, 93, 115, .1); border-color: rgba(255, 93, 115, .35); }
.pill.s-planned { color: var(--violet); background: rgba(177, 124, 255, .08); border-color: rgba(177, 124, 255, .3); border-style: dashed; }
.pill.s-unknown { color: var(--dim); }

/* departments list their agents in a column under them, so the whole company fits a desktop screen */
.tree li.kind-department > ul { flex-direction: column; align-items: center; gap: 12px; padding-top: 18px; }
.tree li.kind-department > ul::before { height: calc(100% - 40px); z-index: -1; }
.tree li.kind-department > ul > li { padding: 0; }
.tree li.kind-department > ul > li::before, .tree li.kind-department > ul > li::after { display: none; }
.tree li.kind-department > ul > li > a { width: 224px; }

/* ---------- panels ---------- */
.panel { background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.025)); border: 1px solid var(--line); border-radius: 22px; padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.ph h2 { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 800; }
.ph h2 svg { color: var(--indigo); }
.ph a, .ph time { color: var(--muted); font-size: 12.5px; }
.ph a:hover { color: var(--fg); }
.cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 18px; align-items: start; }
.col { min-width: 0; }

/* ---------- timeline ---------- */
.feed { list-style: none; margin: 0; padding: 0 0 0 0; position: relative; }
.feed::before { content: ""; position: absolute; top: 6px; bottom: 6px; right: 8px; width: 2px; background: linear-gradient(var(--line2), transparent); border-radius: 2px; }
.ev { position: relative; display: flex; gap: 14px; padding: 10px 0; align-items: flex-start; }
.ev .dot { position: relative; z-index: 1; flex: none; width: 18px; height: 18px; margin-top: 4px; border-radius: 50%; background: var(--bg2); border: 2px solid var(--indigo); box-shadow: 0 0 0 4px var(--bg); }
.ev.l-success .dot { border-color: var(--green); } .ev.l-warning .dot { border-color: var(--amber); } .ev.l-critical .dot { border-color: var(--red); background: var(--red); }
.ev .evb { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 14px; background: var(--glass); border: 1px solid transparent; transition: border-color .2s, background .2s; }
.ev:hover .evb { border-color: var(--line); background: var(--glass2); }
.ev.l-critical .evb { background: rgba(255, 93, 115, .07); border-color: rgba(255, 93, 115, .25); }
.ev.l-warning .evb { background: rgba(255, 181, 71, .06); }
.evm { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.evm .who { color: #c9d2ff; font-weight: 700; }
.evm .ty { padding: 0 8px; border-radius: 99px; background: rgba(255,255,255,.05); }
.evm time { margin-inline-start: auto; color: var(--dim); }
.evt { margin-top: 3px; font-weight: 600; }
.ev details { margin-top: 6px; }
.ev summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.ev pre { margin-top: 8px; padding: 12px; border-radius: 12px; background: rgba(0,0,0,.25); color: #cfd6ee; max-height: 360px; overflow: auto; }
.ev.fresh .evb { animation: flash 2.2s var(--ease); }
.alerts .ev form { align-self: center; }
.empty { list-style: none; color: var(--dim); text-align: center; padding: 26px 0; }
.more { text-align: center; margin-top: 12px; }

/* ---------- agent page ---------- */
.agent-head {
  position: relative; overflow: hidden; padding: 26px clamp(18px, 3vw, 30px); border-radius: 26px; margin-bottom: 18px; border: 1px solid var(--line);
  background: radial-gradient(500px 220px at 90% -20%, rgba(124, 140, 255, .28), transparent 70%), radial-gradient(400px 240px at 0% 120%, rgba(46, 230, 197, .14), transparent 70%), linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
}
.agent-head.k-person { background: radial-gradient(500px 220px at 90% -20%, rgba(255, 212, 121, .25), transparent 70%), linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); }
.agent-head.k-assistant { background: radial-gradient(520px 240px at 90% -20%, rgba(177, 124, 255, .32), transparent 70%), linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); }
.ah { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.aht { flex: 1; min-width: 200px; }
.aht h1 { font-size: clamp(22px, 3vw, 32px); font-weight: 900; }
.aht p { color: var(--muted); }
.desc { margin-top: 14px; color: #cdd4ec; max-width: 820px; }
.facts { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.facts div { padding: 8px 14px; border-radius: 14px; background: rgba(0,0,0,.2); border: 1px solid var(--line); }
.facts dt { font-size: 11.5px; color: var(--dim); }
.facts dd { margin: 0; font-weight: 700; font-size: 13.5px; }
.facts a { color: #c9d2ff; }
.detail { margin-top: 12px; color: var(--muted); font-size: 13px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.flash { margin-top: 14px; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; border: 1px solid var(--line); }
.flash.ok { background: rgba(74, 222, 128, .08); border-color: rgba(74, 222, 128, .3); color: #b6f5cb; }
.flash.err { background: rgba(255, 93, 115, .08); border-color: rgba(255, 93, 115, .35); color: #ffc2cb; }
.flash.plan { background: rgba(177, 124, 255, .08); border-color: rgba(177, 124, 255, .3); color: #dcc7ff; }
.cancan { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cancan h3 { font-size: 13.5px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.cancan h3::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.cancan .yes::before { background: var(--green); } .cancan .no::before { background: var(--red); }
.cancan ul { margin: 0; padding: 0 18px 0 0; color: #cdd4ec; font-size: 13.5px; }
.cancan li { margin: 3px 0; }
.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.kid { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); transition: border-color .2s, transform .2s; }
.kid:hover { border-color: var(--line2); transform: translateY(-2px); }
.kid .ic { width: 36px; height: 36px; border-radius: 11px; font-size: 16px; }
.kid b { display: block; font-size: 13.5px; } .kid small { color: var(--muted); font-size: 11.5px; }
.report { padding: 14px 16px; border-radius: 14px; background: rgba(0,0,0,.22); border: 1px solid var(--line); color: #dbe1f5; max-height: 520px; overflow: auto; }
.file + .file { margin-top: 10px; }
.file details { border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,.16); }
.file summary { cursor: pointer; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.file summary small { color: var(--dim); font-size: 12px; }
.file textarea { display: block; width: calc(100% - 24px); margin: 0 12px 12px; min-height: 280px; resize: vertical; padding: 12px; border-radius: 12px; border: 1px solid var(--line2); background: #070b18; color: #dfe5f7; font: 13px/1.8 ui-monospace, Menlo, Consolas, "Vazirmatn", monospace; }
.file .btn { margin: 0 12px 12px; }
.cmds { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cmds li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 12px; border-radius: 12px; background: var(--glass); font-size: 13px; }
.cmds .st { padding: 0 8px; border-radius: 99px; font-size: 11.5px; background: rgba(255,255,255,.06); color: var(--muted); }
.cmds .c-done .st { color: var(--green); } .cmds .c-failed .st { color: var(--red); } .cmds .c-sent .st { color: var(--teal); }
.cmds time { margin-inline-start: auto; color: var(--dim); font-size: 12px; }
.cmds details { flex-basis: 100%; } .cmds pre { padding: 10px; border-radius: 10px; background: rgba(0,0,0,.25); font-size: 12px; }

/* ---------- buttons, forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 13px; border: 0; cursor: pointer;
  font: 700 14px/1 "Vazirmatn", Tahoma, sans-serif; color: #fff; background: linear-gradient(135deg, var(--indigo), #5b6bff);
  box-shadow: 0 10px 24px -12px var(--indigo), inset 0 1px 0 rgba(255,255,255,.25); transition: transform .2s var(--ease), box-shadow .2s, filter .2s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn.small { padding: 7px 12px; font-size: 12.5px; border-radius: 11px; }
.btn.wide { width: 100%; padding: 13px; }
.btn.ghost { background: var(--glass2); box-shadow: inset 0 0 0 1px var(--line2); color: var(--fg); }
.btn.danger { background: linear-gradient(135deg, var(--red), #e8486b); box-shadow: 0 10px 24px -12px var(--red); }
.btn.a-run { background: linear-gradient(135deg, #18c7a8, #1f8fd6); box-shadow: 0 10px 24px -12px var(--teal); }
.btn.a-pause { background: linear-gradient(135deg, #f0a43a, #e07a2c); box-shadow: 0 10px 24px -12px var(--amber); }
.btn.a-resume { background: linear-gradient(135deg, #34c76f, #1e9e5a); box-shadow: 0 10px 24px -12px var(--green); }
.btn.a-restart { background: linear-gradient(135deg, var(--violet), var(--indigo)); }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.form input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(0,0,0,.25); color: var(--fg); font: 15px "Vazirmatn", Tahoma, sans-serif; transition: border-color .2s, box-shadow .2s; }
.form input:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(124, 140, 255, .18); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chips a { padding: 6px 14px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); color: var(--muted); font-size: 13px; transition: all .2s; }
.chips a:hover { color: var(--fg); border-color: var(--line2); }
.chips a.on { color: #fff; background: linear-gradient(135deg, rgba(124,140,255,.35), rgba(177,124,255,.25)); border-color: rgba(124,140,255,.5); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: start; color: var(--dim); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: top; }
.tbl small { color: var(--dim); }

/* ---------- auth ---------- */
.auth { width: min(420px, 100%); text-align: center; padding: 34px 28px; border-radius: 28px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.03)); box-shadow: 0 40px 90px -40px rgba(124, 140, 255, .55); backdrop-filter: blur(16px); animation: rise .6s var(--ease) both; }
.auth.wide { width: min(560px, 100%); }
.auth h1 { font-size: 22px; font-weight: 900; margin: 6px 0; }
.auth .form { text-align: start; margin-top: 18px; }
.auth .flash { text-align: start; }
.steps { list-style: none; padding: 0; margin: 18px 0 0; text-align: start; display: grid; gap: 16px; }
.steps > li { padding: 16px; border-radius: 18px; background: rgba(0,0,0,.2); border: 1px solid var(--line); }
.steps b { display: block; margin-bottom: 6px; }
.qr { display: block; margin: 12px auto; border-radius: 14px; background: #fff; padding: 8px; }
.secret { display: block; text-align: center; padding: 10px; border-radius: 12px; background: rgba(0,0,0,.3); letter-spacing: 1px; font-size: 13px; color: #c9d2ff; margin-top: 6px; }

/* ---------- modal + toasts ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(3, 6, 14, .6); backdrop-filter: blur(6px); animation: fade .2s both; }
.modal .box { width: min(400px, 100%); padding: 24px; border-radius: 22px; background: linear-gradient(180deg, #141b34, #0d1328); border: 1px solid var(--line2); box-shadow: 0 30px 80px -20px rgba(0,0,0,.9); animation: pop .3s var(--ease) both; }
.modal h3 { font-size: 17px; margin-bottom: 8px; }
.modal p { color: var(--muted); font-size: 14px; }
.modal .acts { display: flex; gap: 10px; justify-content: flex-start; margin-top: 18px; }
.toasts { position: fixed; z-index: 50; left: 18px; bottom: 18px; display: grid; gap: 10px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; border-radius: 16px; background: rgba(16, 22, 44, .92); border: 1px solid var(--line2); box-shadow: 0 20px 50px -20px #000; backdrop-filter: blur(12px); font-size: 13.5px; animation: slidein .45s var(--ease) both; }
.toast b { color: #c9d2ff; }
.toast.l-critical { border-color: rgba(255, 93, 115, .5); } .toast.l-warning { border-color: rgba(255, 181, 71, .45); } .toast.l-success { border-color: rgba(74, 222, 128, .4); }
.toast.out { animation: slideout .4s var(--ease) both; }

/* ---------- motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.35); } 70% { box-shadow: 0 0 0 9px rgba(255,255,255,0); } 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } }
@keyframes flash { 0% { background: rgba(124, 140, 255, .28); border-color: rgba(124, 140, 255, .6); } 100% { } }
@keyframes slidein { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes slideout { to { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- responsive ---------- */
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } .cancan { grid-template-columns: 1fr; } }
@media (max-width: 1100px) { /* vertical company tree instead of a wide chart */
  .org-wrap { display: block; overflow: visible; margin: 0; padding: 0 0 10px; height: auto !important; }
  .org { width: auto; padding: 0; transform: none !important; }
  .tree, .tree ul { display: block; direction: rtl; padding: 0; }
  .tree ul { margin: 10px 22px 0 0; padding-right: 16px; border-right: 2px solid rgba(124, 140, 255, .25); }
  .tree li, .tree > li { display: block; padding: 10px 0 0; position: relative; }
  .tree li::before, .tree li::after, .tree ul::before, .tree ul ul::before, .tree > li > ul::before, .tree li.kind-department > ul::before { display: none; }
  .tree ul > li::before { display: block; content: ""; position: absolute; top: 40px; right: -16px; left: auto; width: 14px; height: 0; border: 0; border-top: 2px solid rgba(124, 140, 255, .25); border-radius: 0; }
  .tree li.kind-department > ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
  .tree li.kind-department > ul > li { padding: 0; }
  .tree li.kind-department > ul > li::before { display: none; }
  .card, .k-department, .tree li.kind-department > ul > li > a { width: 100%; max-width: 560px; }
}
@media (max-width: 760px) {
  .top { gap: 10px; backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(6, 10, 22, .96); } /* a filter would trap the fixed bottom nav inside the header */
  .brand small, .live span { display: none; }
  .nav { position: fixed; inset: auto 0 0 0; z-index: 40; justify-content: space-around; gap: 0; margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(8, 12, 26, .9); backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 10px; }
  .nav a svg { width: 22px; height: 22px; }
  .nav .badge { position: absolute; top: 0; left: 8px; transform: scale(.85); }
  .live { margin-inline-start: auto; }
  .tree ul { margin: 8px 8px 0 0; padding-right: 10px; }
  .tree ul > li::before { right: -10px; width: 8px; }
  .tree li.kind-department > ul { grid-template-columns: minmax(0, 1fr); }
  .card { width: 100%; }
  .kpi { min-width: calc(50% - 5px); flex: 1; }
  .toasts { bottom: 84px; }
  .page { padding-bottom: 110px; }
}
