/*
 * SAN Account / SAN Control Deck – "SAN OS" design.
 * Dark glass surfaces over a soft aurora, amber brand accent, cyan for interaction.
 * Colours are tokens on :root; light mode redefines them.
 */
:root {
  --bg: #050a14;
  --bg-2: #0a1324;
  --glass: rgba(255, 255, 255, .045);
  --glass-2: rgba(255, 255, 255, .075);
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --text: #e8eef8;
  --muted: #8b9ab3;
  --brand: #f5a524;           /* SAN amber */
  --brand-2: #ff7a3d;
  --cyan: #38d6f5;
  --violet: #8b6cff;
  --ok: #34d399; --bad: #fb7185; --warn: #fbbf24;
  --glow-a: rgba(56, 214, 245, .18);
  --glow-b: rgba(139, 108, 255, .16);
  --glow-c: rgba(245, 165, 36, .10);
  --grid: rgba(255, 255, 255, .025);
  --radius: 18px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --focus: 0 0 0 3px rgba(56, 214, 245, .45);
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef2f8; --bg-2: #e3e9f3; --glass: rgba(255, 255, 255, .72); --glass-2: rgba(255, 255, 255, .9);
    --line: rgba(15, 30, 60, .10); --line-2: rgba(15, 30, 60, .18); --text: #0d1a2e; --muted: #5b6b84;
    --glow-a: rgba(56, 180, 245, .22); --glow-b: rgba(139, 108, 255, .14); --glow-c: rgba(245, 165, 36, .16);
    --grid: rgba(15, 30, 60, .04); --shadow: 0 10px 30px rgba(15, 30, 60, .10); --cyan: #0891b2; --ok: #059669; --bad: #e11d48;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef2f8; --bg-2: #e3e9f3; --glass: rgba(255, 255, 255, .72); --glass-2: rgba(255, 255, 255, .9);
  --line: rgba(15, 30, 60, .10); --line-2: rgba(15, 30, 60, .18); --text: #0d1a2e; --muted: #5b6b84;
  --glow-a: rgba(56, 180, 245, .22); --glow-b: rgba(139, 108, 255, .14); --glow-c: rgba(245, 165, 36, .16);
  --grid: rgba(15, 30, 60, .04); --shadow: 0 10px 30px rgba(15, 30, 60, .10); --cyan: #0891b2; --ok: #059669; --bad: #e11d48;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  color: var(--text); min-height: 100vh;
  font: 15px/1.55 "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background:
    radial-gradient(900px 600px at 8% -10%, var(--glow-a), transparent 60%),
    radial-gradient(800px 600px at 105% 10%, var(--glow-b), transparent 60%),
    radial-gradient(700px 500px at 50% 120%, var(--glow-c), transparent 60%),
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--bg);
  background-attachment: fixed;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 700; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
button, .btn, input, select, textarea { font: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 10px; }
::selection { background: rgba(56, 214, 245, .3); }

.eyebrow { font: 600 .72rem/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); }
.grad { background: linear-gradient(90deg, var(--brand), var(--brand-2) 40%, var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; text-decoration: none; }
.topbar .logo img { width: 32px; height: 32px; border-radius: 9px; box-shadow: 0 0 24px rgba(245, 165, 36, .25); }
.topbar .logo small { font: 600 .68rem/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); margin-left: 6px; }
.topbar .spacer { flex: 1; }
.topbar .user { font: .82rem var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }

/* ---------------------------------------------------------------- buttons, inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--glass); color: var(--text); cursor: pointer; text-decoration: none;
  font-weight: 600; white-space: nowrap; transition: border-color .15s, background .15s, transform .15s, box-shadow .15s;
}
.btn:hover { background: var(--glass-2); border-color: var(--cyan); }
.btn:active { transform: translateY(1px); }
.btn.primary, .btn.accent {
  border: 0; color: #1a0e00; background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 24px rgba(245, 122, 36, .30);
}
.btn.primary:hover, .btn.accent:hover { filter: brightness(1.08); box-shadow: 0 8px 30px rgba(245, 122, 36, .42); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { padding: 6px 11px; font-size: .84rem; border-radius: 10px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn[disabled] { opacity: .5; cursor: default; }

input[type=email], input[type=text], input[type=search], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--bg) 55%, transparent); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: var(--focus); outline: none; }
textarea { min-height: 70px; resize: vertical; }
label { font-weight: 600; font-size: .9rem; }

/* ---------------------------------------------------------------- surfaces */
.card {
  position: relative; background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; backdrop-filter: blur(16px) saturate(1.3); box-shadow: var(--shadow);
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 32px 16px 64px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font: 600 .7rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.pill.ok::before, .pill.bad::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.admin { color: #1a0e00; border: 0; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }

/* ---------------------------------------------------------------- login */
.login { width: 100%; max-width: 420px; padding: 32px; }
.login .brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.login .brand img { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 0 40px rgba(245, 165, 36, .35); }
.login .brand b { font-size: 1.35rem; display: block; }
.login form { display: grid; gap: 12px; }
.code-input { font: 700 1.9rem var(--mono) !important; letter-spacing: .55em; text-align: center; padding-left: .55em !important; }
.msg { min-height: 1.4em; font-size: .9rem; margin: 12px 0 0; }
.msg.err { color: var(--bad); } .msg.ok { color: var(--ok); }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 0; }
.linkbtn:hover { color: var(--cyan); }

/* ---------------------------------------------------------------- home */
.hello { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.hello h1 { margin-top: 6px; }
.group { margin-bottom: 30px; }
.group-title { display: flex; align-items: center; gap: 12px; font: 600 .74rem/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.group-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.app {
  display: flex; flex-direction: column; gap: 14px; min-height: 178px; text-decoration: none; overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.app::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: linear-gradient(135deg, var(--cyan), var(--violet) 50%, var(--brand));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.app::after {
  content: ""; position: absolute; width: 180px; height: 180px; right: -60px; top: -60px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--glow-a), transparent 70%); opacity: 0; transition: opacity .25s;
}
.app:hover { transform: translateY(-4px); box-shadow: 0 18px 50px rgba(0, 0, 0, .45); }
.app:hover::before, .app:hover::after { opacity: 1; }
.app .ico {
  width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center;
  background: linear-gradient(145deg, #12233d, #0b1628); border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 8px 24px rgba(0, 0, 0, .35);
}
.app .ico svg { width: 26px; height: 26px; }
.app h3 { display: flex; gap: 8px; align-items: center; font-size: 1.08rem; margin: 0 0 4px; }
.app .go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font: 600 .78rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--cyan); }
.app.off { opacity: .55; }
.section { margin-top: 40px; }
.list { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--glass); backdrop-filter: blur(12px); }
.row .grow { flex: 1; min-width: 0; }
.row .grow > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.install { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 8px; }

/* ---------------------------------------------------------------- deck layout */
.deck-layout { display: grid; grid-template-columns: 236px 1fr; min-height: calc(100vh - 64px); }
.side {
  position: sticky; top: 64px; align-self: start; height: calc(100vh - 64px); overflow: auto;
  padding: 18px 12px; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 60%, transparent); backdrop-filter: blur(16px);
}
.side button {
  text-align: left; background: none; border: 1px solid transparent; padding: 10px 12px; border-radius: 12px; color: var(--muted);
  cursor: pointer; font-weight: 600; display: flex; gap: 10px; align-items: center; transition: color .15s, background .15s, border-color .15s;
}
.side button:hover { color: var(--text); background: var(--glass); }
.side button.on { color: var(--text); background: var(--glass-2); border-color: var(--line-2); box-shadow: inset 3px 0 0 var(--brand); }
.side .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.side .lbl { font: 600 .66rem/1 var(--mono); text-transform: uppercase; letter-spacing: .16em; color: var(--muted); padding: 8px 12px 4px; opacity: .8; }
.main { padding: 28px; min-width: 0; }
.main > h1 { margin-bottom: 6px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin: 20px 0 28px; }
.kpi { overflow: hidden; }
.kpi .v { font: 700 2.1rem/1.1 var(--mono); letter-spacing: -.02em; }
.kpi .k { color: var(--muted); font: 600 .7rem/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; margin-top: 6px; }
.kpi::after { content: ""; position: absolute; left: 20px; right: 20px; bottom: 0; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--cyan), var(--violet)); opacity: .7; }
.appgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.appcard h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.appcard dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 12px 0 0; font-size: .9rem; }
.appcard dt { color: var(--muted); } .appcard dd { margin: 0; font-family: var(--mono); text-align: right; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 18px 0; }
.toolbar input, .toolbar select { width: auto; min-width: 220px; flex: 1; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; font: .8rem var(--mono); }

/* Data as cards instead of tables */
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.dl-item { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.dl-item .dl-title { font-weight: 700; word-break: break-word; }
.dl-fields { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: .86rem; margin: 0; }
.dl-fields dt { color: var(--muted); font: 600 .68rem/1.9 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.dl-fields dd { margin: 0; text-align: right; word-break: break-word; }
.dl-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

/* Timeline (activity) */
.timeline { position: relative; display: grid; gap: 4px; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--cyan), var(--violet), transparent); opacity: .5; }
.tl { position: relative; display: flex; gap: 14px; align-items: baseline; padding: 10px 14px; border-radius: 12px; }
.tl:hover { background: var(--glass); }
.tl::before { content: ""; position: absolute; left: -21px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.tl.warn::before { border-color: var(--bad); box-shadow: 0 0 10px var(--bad); }
.tl.admin::before { border-color: var(--brand); box-shadow: 0 0 10px var(--brand); }
.tl time { font: .74rem var(--mono); color: var(--muted); white-space: nowrap; min-width: 112px; }
.tl .what { flex: 1; min-width: 0; }
.tl .what b { font-weight: 600; }
.tl .meta { color: var(--muted); font-size: .84rem; }

/* People */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.person { display: flex; flex-direction: column; gap: 14px; }
.person-head { display: flex; gap: 12px; align-items: center; }
.person-head .who { flex: 1; min-width: 0; }
.person-head .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-head .who span { font: .78rem var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font: 700 .95rem var(--mono);
  color: #fff; background: linear-gradient(135deg, var(--cyan), var(--violet)); box-shadow: 0 0 20px var(--glow-a);
}
.avatar.admin { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #1a0e00; box-shadow: 0 0 20px rgba(245, 165, 36, .35); }
.person-meta { display: flex; gap: 14px; flex-wrap: wrap; font: .74rem var(--mono); color: var(--muted); }

/* Access chips: click cycles Standard → Erlaubt → Gesperrt */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 99px; cursor: pointer; font-size: .82rem; font-weight: 600;
  border: 1px solid var(--line-2); background: transparent; color: var(--muted); transition: all .15s;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .5; }
.chip:hover { border-color: var(--cyan); color: var(--text); }
.chip.yes { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.chip.yes::before { opacity: 1; box-shadow: 0 0 8px currentColor; }
.chip.no { color: var(--muted); text-decoration: line-through; opacity: .75; }
.chip.forced { box-shadow: inset 0 0 0 1px currentColor; }
.chip.forced.no { color: var(--bad); opacity: 1; background: color-mix(in srgb, var(--bad) 8%, transparent); }
.chip[disabled] { cursor: default; }
.chip small { font: 600 .62rem var(--mono); letter-spacing: .08em; text-transform: uppercase; opacity: .8; text-decoration: none; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .84rem; margin: 6px 0 4px; align-items: center; }

/* Forms */
.form { display: grid; gap: 16px; max-width: 820px; }
.field { display: grid; gap: 6px; }
.field .hint { color: var(--muted); font-size: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { appearance: none; width: 40px; height: 22px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.switch input:checked::after { transform: translateX(18px); }

/* Dialog */
dialog {
  border: 1px solid var(--line-2); border-radius: 22px; background: color-mix(in srgb, var(--bg-2) 94%, transparent); color: var(--text);
  padding: 0; width: min(780px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
dialog::backdrop { background: rgba(2, 6, 14, .6); backdrop-filter: blur(4px); }
dialog .hd { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
dialog .bd { padding: 18px 22px 22px; max-height: 72vh; overflow: auto; display: grid; gap: 14px; }
dialog h3 { margin: 6px 0 0; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50; padding: 12px 18px; border-radius: 14px;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent); border: 1px solid var(--line-2); box-shadow: var(--shadow);
}

/* utilities (no inline styles: CSP style-src 'self') */
.m0 { margin: 0; } .mt { margin-top: 14px; } .mb { margin-bottom: 16px; }
.small-text { font-size: .85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.between { display: flex; justify-content: space-between; gap: 8px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .app:hover { transform: none; } }

@media (max-width: 860px) {
  .deck-layout { grid-template-columns: 1fr; }
  .side { top: 64px; height: auto; z-index: 5; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .side .sep, .side .lbl { display: none; }
  .side button { white-space: nowrap; }
  .main { padding: 18px 16px; }
  .topbar .user { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .tl { flex-direction: column; gap: 2px; }
  .tl time { min-width: 0; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .logo span { display: none; }
  .people, .dl { grid-template-columns: 1fr; }
}
