:root {
  --bg: #0b0f17;
  --bg2: #0f1420;
  --panel: #131a28;
  --panel2: #182134;
  --panel3: #1e2940;
  --line: #24304a;
  --line2: #2e3c5c;
  --text: #e6ebf5;
  --muted: #8a96b0;
  --dim: #5d6984;
  --accent: #6c7cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(108, 124, 255, .14);
  --cyan-soft: rgba(34, 211, 238, .12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .13);
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, .13);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --grad: linear-gradient(135deg, #6c7cff 0%, #22d3ee 100%);
  --mail-bg: #ffffff;
  --mail-text: #1f2937;
  --radius: 12px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f5fa;
  --bg2: #eef1f8;
  --panel: #ffffff;
  --panel2: #f6f8fc;
  --panel3: #edf1f9;
  --line: #e1e6f0;
  --line2: #cfd7e6;
  --text: #121a2b;
  --muted: #5e6a82;
  --dim: #8c97ad;
  --accent: #4f5ff0;
  --accent-2: #0891b2;
  --accent-soft: rgba(79, 95, 240, .10);
  --cyan-soft: rgba(8, 145, 178, .10);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, .10);
  --warn: #b45309;
  --warn-soft: rgba(217, 119, 6, .12);
  --err: #dc2626;
  --err-soft: rgba(220, 38, 38, .09);
  --shadow: 0 10px 30px rgba(20, 30, 60, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.num { font-variant-numeric: tabular-nums; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.login-hero {
  position: relative; overflow: hidden; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% -10%, rgba(108,124,255,.35), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, rgba(34,211,238,.25), transparent 60%), var(--bg2);
  border-right: 1px solid var(--line);
}
.login-hero .grid-bg {
  position: absolute; inset: 0; opacity: .25; pointer-events: none;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 40px 40px; mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; position: relative; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 6px 20px rgba(108,124,255,.45); }
.login-hero h1 { font-size: 44px; line-height: 1.08; letter-spacing: -.03em; margin: 0 0 16px; max-width: 560px; position: relative; }
.login-hero p { color: var(--muted); font-size: 16px; max-width: 520px; position: relative; }
.flow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; position: relative; }
.flow .node { padding: 8px 12px; border: 1px solid var(--line2); border-radius: 10px; background: color-mix(in srgb, var(--panel) 70%, transparent); font-size: 13px; display: flex; gap: 8px; align-items: center; backdrop-filter: blur(6px); }
.flow .arrow { color: var(--dim); align-self: center; }
.login-form { display: grid; place-items: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; }
.ldap-steps { margin: 18px 0 0; display: grid; gap: 8px; }
.ldap-step { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); padding: 8px 12px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.ldap-step.ok { color: var(--text); }
.ldap-step.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.ldap-step.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.ldap-step.err .dot { background: var(--err); }
.ldap-step.run .dot { background: var(--accent); animation: pulse 1s infinite; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--accent-soft); } }
.demo-accounts { margin-top: 22px; border: 1px dashed var(--line2); border-radius: 12px; padding: 12px; }
.demo-accounts .acc { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-radius: 8px; cursor: pointer; }
.demo-accounts .acc:hover { background: var(--panel2); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line); background: var(--bg2);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
}
.side .brand { padding: 4px 8px 18px; font-size: 16px; }
.side .brand .logo { width: 30px; height: 30px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); padding: 14px 10px 6px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--muted); cursor: pointer; border: 1px solid transparent; background: none; text-align: left; width: 100%; }
.nav:hover { color: var(--text); background: var(--panel); }
.nav.active { color: var(--text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.nav.active svg { color: var(--accent); }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding-top: 12px; }
.sync-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12px; color: var(--muted); background: var(--panel); }
.sync-card .row { display: flex; align-items: center; gap: 8px; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: live 2s infinite; flex: none; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.6); } 70% { box-shadow: 0 0 0 7px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.crumbs { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.crumbs b { color: var(--text); font-weight: 600; }
.topbar .sp { flex: 1; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); }
.user-chip .meta { line-height: 1.2; font-size: 12px; padding-right: 6px; }
.content { padding: 28px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .sp { flex: 1; }

/* ---------- Primitives ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-h .sp { flex: 1; }
.card-b { padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.sp { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; font-weight: 500; white-space: nowrap; transition: .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(108,124,255,.3); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel2); }
.btn.danger { color: var(--err); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.sm { width: 30px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .lbl { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line2); background: var(--bg2); outline: none; width: 100%; transition: .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--dim); }
.input-icon .input { padding-left: 36px; }
.hint { font-size: 12px; color: var(--dim); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }
.badge.cyan { background: var(--cyan-soft); color: var(--accent-2); }

.chk { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.chk input { display: none; }
.chk .box { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line2); display: grid; place-items: center; transition: .12s; flex: none; background: var(--bg2); }
.chk input:checked + .box { background: var(--accent); border-color: var(--accent); }
.chk input:checked + .box::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.box.part { background: var(--accent); border-color: var(--accent); }
.box.part::after { content: ""; width: 8px; height: 2px; background: #fff; border-radius: 2px; }

.switch { position: relative; width: 38px; height: 22px; flex: none; display: inline-block; cursor: pointer; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line2); transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--panel3); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--panel2); }
.tbl-wrap { overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }

.kpi { padding: 18px; }
.kpi .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.kpi .l { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .d { font-size: 12px; margin-top: 4px; }
.kpi .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--dim); margin-bottom: 8px; }

.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); font-size: 13px; }
.callout.info { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); }
.callout.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-soft); }
.callout.ok { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: var(--ok-soft); }
.callout.err { border-color: color-mix(in srgb, var(--err) 35%, var(--line)); background: var(--err-soft); }
.callout svg { margin-top: 1px; }
.callout.info svg { color: var(--accent); } .callout.warn svg { color: var(--warn); } .callout.ok svg { color: var(--ok); } .callout.err svg { color: var(--err); }

/* ---------- Wizard ---------- */
.wiz { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.steps { position: sticky; top: 80px; padding: 10px; }
.step { display: flex; gap: 12px; padding: 10px; border-radius: 10px; cursor: pointer; position: relative; }
.step:hover { background: var(--panel2); }
.step .n { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; background: var(--bg2); z-index: 1; }
.step .t { font-weight: 600; font-size: 13.5px; }
.step .s { font-size: 12px; color: var(--dim); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step.on { background: var(--accent-soft); }
.step.on .n { border-color: var(--accent); color: var(--accent); }
.step.done .n { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.skip { opacity: .45; }
.step:not(:last-child)::after { content: ""; position: absolute; left: 23px; top: 40px; bottom: -8px; width: 1.5px; background: var(--line); }
.wiz-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel); border-radius: 0 0 var(--radius) var(--radius); z-index: 5; }

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.type-card { position: relative; padding: 16px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--panel2); cursor: pointer; transition: .15s; }
.type-card:hover { border-color: var(--line2); transform: translateY(-1px); }
.type-card.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); }
.type-card .ti { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 12px; }
.type-card h4 { margin: 0 0 4px; font-size: 15px; }
.type-card p { margin: 0; font-size: 12.5px; color: var(--muted); }
.type-card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.type-card .radio { position: absolute; right: 14px; top: 14px; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line2); }
.type-card.on .radio { border: 5px solid var(--accent); }

.tree { font-size: 13px; }
.tree .tn { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.tree .tn:hover { background: var(--panel2); }
.tree .tn .tw { width: 18px; height: 18px; display: grid; place-items: center; color: var(--dim); transition: .15s; flex: none; }
.tree .tn .tw.open { transform: rotate(90deg); }
.tree .kids { margin-left: 22px; border-left: 1px dashed var(--line); padding-left: 6px; }
.tree .lvl { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; letter-spacing: .03em; flex: none; }
.lvl.dd { background: rgba(168,85,247,.16); color: #c084fc; }
.lvl.tm { background: var(--cyan-soft); color: var(--accent-2); }
.lvl.sv { background: var(--warn-soft); color: var(--warn); }
.lvl.st { background: var(--panel3); color: var(--muted); }
:root[data-theme="light"] .lvl.dd { color: #7e22ce; }
.tree .cnt { margin-left: auto; color: var(--dim); font-size: 12px; white-space: nowrap; }
.tree .who { color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.sel-list { max-height: 520px; overflow: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--panel3); font-size: 12.5px; }
.pill button { border: 0; background: none; cursor: pointer; color: var(--dim); display: grid; place-items: center; padding: 0; }

/* Dropzone & doc grid */
.drop { border: 1.5px dashed var(--line2); border-radius: 14px; padding: 34px; text-align: center; cursor: pointer; transition: .15s; background: var(--panel2); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .ic { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px; display: grid; place-items: center; background: var(--grad); color: #fff; }
.file-chip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); }
.file-chip .fi { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; background: rgba(16,185,129,.15); color: #10b981; font-weight: 800; font-size: 11px; }
.col-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.col-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg2); cursor: pointer; font-size: 12.5px; color: var(--dim); text-decoration: line-through; transition: .12s; }
.col-chip.on { color: var(--text); text-decoration: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--line2)); background: var(--accent-soft); }
.col-chip.key { border-color: var(--accent-2); background: var(--cyan-soft); color: var(--accent-2); text-decoration: none; }
.docgrid { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.docgrid table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; width: max-content; min-width: 100%; }
.docgrid th, .docgrid td { padding: 7px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); white-space: nowrap; }
.docgrid th { position: sticky; top: 0; background: var(--panel2); z-index: 2; cursor: pointer; text-align: left; font-weight: 600; user-select: none; }
.docgrid th .hcell { display: flex; align-items: center; gap: 6px; }
.docgrid th.rn, .docgrid td.rn { position: sticky; left: 0; background: var(--panel2); color: var(--dim); text-align: right; z-index: 1; cursor: default; font-size: 11px; }
.docgrid th.rn { z-index: 3; }
.docgrid th.off, .docgrid td.off { opacity: .28; background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--line) 60%, transparent) 6px 7px); }
.docgrid th.keyc { background: color-mix(in srgb, var(--accent-2) 18%, var(--panel2)); color: var(--accent-2); }
.docgrid td.keyc { background: var(--cyan-soft); font-weight: 600; }
.docgrid tr.hl td:not(.rn) { background: color-mix(in srgb, var(--accent) 13%, transparent); }
.docgrid tr.hl td.keyc { background: color-mix(in srgb, var(--accent-2) 25%, transparent); }
.docgrid tr.fade td:not(.rn) { opacity: .3; }
.docgrid tr.unm td.keyc { color: var(--err); }
.docgrid tr.total td { font-weight: 700; background: var(--panel3); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stat-strip > div { padding: 12px 14px; border-right: 1px solid var(--line); background: var(--panel2); }
.stat-strip > div:last-child { border-right: 0; }
.stat-strip .v { font-size: 20px; font-weight: 700; }
.stat-strip .l { font-size: 12px; color: var(--muted); }

.filter-row { display: grid; grid-template-columns: 1.2fr .8fr 1.2fr auto; gap: 8px; align-items: center; }

/* CC */
.cc-card { display: flex; gap: 14px; padding: 16px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--panel2); cursor: pointer; transition: .15s; align-items: flex-start; }
.cc-card.on { border-color: var(--accent); background: var(--accent-soft); }
.cc-card .lvl { font-size: 12px; padding: 4px 8px; }
.org-diagram { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 18px; }
.org-node { padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--line2); background: var(--bg2); text-align: center; min-width: 120px; font-size: 12px; transition: .2s; }
.org-node b { display: block; font-size: 13px; }
.org-node.on { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.org-node.store { border-color: var(--accent-2); }
.org-link { width: 28px; height: 2px; background: var(--line2); }

/* Email preview */
.mail-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.mail-list { max-height: 680px; overflow: auto; }
.mail-item { padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.mail-item:hover { background: var(--panel2); }
.mail-item.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.mail-item .ttl { font-weight: 600; font-size: 13px; }
.mail-item .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail { background: var(--mail-bg); color: var(--mail-text); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.mail-bar { background: #f3f4f8; border-bottom: 1px solid #e5e7eb; padding: 10px 16px; display: flex; align-items: center; gap: 8px; color: #6b7280; font-size: 12px; }
.mail-bar .dots i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.mail-head { padding: 18px 22px 12px; border-bottom: 1px solid #eef0f4; }
.mail-head .subj { font-size: 19px; font-weight: 600; color: #111827; margin-bottom: 12px; letter-spacing: -.01em; }
.mail-head .hrow { display: grid; grid-template-columns: 56px 1fr; font-size: 13px; padding: 2px 0; color: #374151; }
.mail-head .hrow span:first-child { color: #9ca3af; }
.addr { display: inline-flex; align-items: center; gap: 4px; background: #eef2ff; color: #3730a3; border-radius: 6px; padding: 1px 7px; margin: 1px 4px 1px 0; font-size: 12.5px; }
.addr.cc-sv { background: #fef3c7; color: #92400e; }
.addr.cc-tm { background: #cffafe; color: #155e75; }
.addr.cc-dd { background: #f3e8ff; color: #6b21a8; }
.mail-body { padding: 20px 22px 24px; font-size: 14px; line-height: 1.65; color: #1f2937; }
.mail-body p { margin: 0 0 10px; }
.mail-body table { border-collapse: collapse; font-size: 12.5px; margin: 10px 0; }
.mail-body th { background: #f3f4f6; text-align: left; }
.mail-body th, .mail-body td { border: 1px solid #e5e7eb; padding: 6px 9px; white-space: nowrap; }
.mail-body .var { background: #fef9c3; border-radius: 3px; padding: 0 2px; }
.attach { display: inline-flex; align-items: center; gap: 10px; border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px 12px; background: #f9fafb; font-size: 13px; cursor: pointer; color: #111827; margin: 0 8px 8px 0; }
.attach:hover { border-color: #6c7cff; }
.attach .x { width: 30px; height: 30px; border-radius: 7px; background: #10b981; color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 800; }
.attach-row { padding: 0 22px 16px; border-bottom: 1px solid #eef0f4; }
.prio { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: #b91c1c; background: #fee2e2; padding: 2px 8px; border-radius: 6px; margin-left: 8px; vertical-align: middle; }

/* Editor */
.editor-tools { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px; border: 1px solid var(--line2); border-bottom: 0; border-radius: 9px 9px 0 0; background: var(--panel2); }
.editor-tools + textarea { border-radius: 0 0 9px 9px; }
.var-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; background: var(--bg2); border: 1px solid var(--line2); cursor: pointer; font-size: 12px; font-family: "JetBrains Mono", monospace; color: var(--accent-2); }
.var-chip:hover { border-color: var(--accent-2); }

/* Send progress */
.send-wrap { max-width: 980px; margin: 0 auto; }
.ring { width: 150px; height: 150px; position: relative; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .c b { font-size: 30px; letter-spacing: -.02em; }
.log { height: 300px; overflow: auto; background: #070a10; color: #a9b4c9; border-radius: 10px; padding: 12px 14px; font: 12px/1.7 "JetBrains Mono", monospace; border: 1px solid var(--line); }
.log .ok { color: #34d399; } .log .w { color: #fbbf24; } .log .e { color: #f87171; } .log .a { color: #818cf8; } .log .c { color: #22d3ee; }
.bar { height: 8px; border-radius: 999px; background: var(--panel3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width .2s; }

/* Charts */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b i { width: 100%; max-width: 26px; border-radius: 4px 4px 2px 2px; background: var(--accent); display: block; min-height: 2px; transition: .2s; }
.bars .b:hover i { background: var(--accent-2); }
.bars .b span { font-size: 10.5px; color: var(--dim); }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 28px; }
.spark i { width: 4px; background: var(--accent-2); border-radius: 1px; opacity: .8; }

/* Modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(5, 8, 15, .6); backdrop-filter: blur(3px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { width: 100%; max-width: 640px; max-height: calc(100vh - 40px); overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; box-shadow: var(--shadow); animation: pop .18s; }
.modal.wide { max-width: 980px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.modal-h h3 { margin: 0; font-size: 16px; }
.modal-b { padding: 20px; }
.modal-f { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--panel3); border: 1px solid var(--line2); box-shadow: var(--shadow); min-width: 280px; max-width: 420px; animation: pop .2s; font-size: 13px; }
.toast.ok svg { color: var(--ok); } .toast.err svg { color: var(--err); } .toast.info svg { color: var(--accent); }

.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 13px; }
.kv > span:nth-child(odd) { color: var(--muted); }
pre.code { margin: 0; background: #070a10; color: #c3cde0; border-radius: 10px; padding: 12px 14px; font: 12px/1.6 "JetBrains Mono", monospace; overflow: auto; border: 1px solid var(--line); }
pre.code .k { color: #818cf8; } pre.code .s { color: #34d399; } pre.code .n { color: #fbbf24; }
.swatch { width: 22px; height: 22px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.swatch.on { border-color: var(--text); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

@media (max-width: 1180px) {
  .wiz { grid-template-columns: 1fr; }
  .steps { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .step::after { display: none; }
  .step .s { display: none; }
  .split, .mail-layout { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .nav-label, .side-foot { display: none; }
  .side .nav { width: auto; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .user-chip .meta { display: none; }
}

/* ---------- v2: адаптив и новые блоки ---------- */
.shell { grid-template-columns: 248px minmax(0, 1fr); }
.wiz > * { min-width: 0; }
.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dash-row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.dash-row > :nth-child(3) { grid-column: 1 / -1; }
.click-row { cursor: pointer; }
.click-row:hover { background: var(--panel2); }
.cc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.cc-card > div { min-width: 0; }
.addr-rows { display: flex; flex-direction: column; gap: 6px; }
.addr-line { display: grid; grid-template-columns: 90px 44px minmax(0, 1fr) minmax(0, 1.2fr); gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); transition: .2s; }
.addr-line .lvl { text-align: center; }
.addr-line.on { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.addr-line.off { opacity: .45; }
.addr-line.off b { text-decoration: line-through; }
.radio-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; }
.radio-row.on { border-color: var(--accent); background: var(--accent-soft); }
.radio-row .rdot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line2); flex: none; margin-top: 2px; }
.radio-row.on .rdot { border: 5px solid var(--accent); }
.seg button[disabled] { opacity: .4; cursor: not-allowed; }
.sched-list { display: flex; flex-direction: column; gap: 14px; }
.sched.paused { opacity: .7; }
.sched-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; padding: 14px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; }
.sched-grid .lbl { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.feed { max-height: 420px; overflow: auto; }
.feed .list-row { padding: 9px 18px; font-size: 13px; }
details.card > summary { list-style: none; border-bottom: 0; }
details.card[open] > summary { border-bottom: 1px solid var(--line); }
details.card > summary::-webkit-details-marker { display: none; }
.legend i { border: 1px solid var(--line2); }
.wiz-foot { box-shadow: 0 -8px 20px -12px rgba(0,0,0,.35); }
.modal .grid.g2 > * { min-width: 0; }
@media (max-width: 1280px) {
  .sched-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip > div:nth-child(2) { border-right: 0; }
  .stat-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 1180px) {
  .wiz { grid-template-columns: minmax(0, 1fr); }
  .dash-row { grid-template-columns: minmax(0, 1fr); }
  .addr-line { grid-template-columns: 80px 40px minmax(0, 1fr); }
  .addr-line > :last-child { grid-column: 3; }
  .split[style] { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 1000px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .content { padding: 20px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sched-grid { grid-template-columns: minmax(0, 1fr); }
}
td.nowrap, .nowrap { white-space: nowrap; }
.addr-line { grid-template-columns: 90px 76px minmax(0, 1fr) minmax(0, 1.2fr); }
.addr-line .lvl { display: inline-block; }
@media (max-width: 1180px) { .addr-line { grid-template-columns: 80px 70px minmax(0, 1fr); } }
@media (max-width: 1180px) {
  .steps { flex-wrap: nowrap; }
  .step { flex: none; align-items: center; }
  .step .t { white-space: nowrap; }
  .step:not(.on) .t { display: none; }
}

/* ---------- v3: выравнивание и вход ---------- */
.content { margin: 0 auto; max-width: 1560px; }
.type-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.login-hero { padding: 48px 56px; gap: 32px; }
.hero-steps { display: grid; gap: 10px; margin-top: 28px; max-width: 460px; position: relative; }
.hero-step { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line2); background: color-mix(in srgb, var(--panel) 70%, transparent); backdrop-filter: blur(6px); font-size: 14px; }
.hero-step svg { color: var(--accent-2); }
.hs-n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.demo-accounts .acc { gap: 12px; border: 1px solid transparent; }
.demo-accounts .acc.on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.bars .b { position: relative; }
.bars .b em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--muted); }
.bars .b.zero i { background: var(--line2); }
@media (max-height: 760px) { .login-hero h1 { font-size: 36px; } .hero-steps { margin-top: 18px; gap: 8px; } }
@media (max-width: 860px) {
  .side { flex-wrap: nowrap; overflow-x: auto; padding: 10px 12px; gap: 6px; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { padding: 0 8px 0 0; flex: none; }
  .side .brand { font-size: 0; gap: 0; }
  .side .nav { flex: none; white-space: nowrap; padding: 8px 10px; }
  .side .nav .badge { margin-left: 4px; }
  .topbar { position: static; }
  .crumbs > :not(b) { display: none; }
  .page-head h1 { font-size: 22px; }
  .login-form { padding: 24px 16px; }
}
@media (max-width: 860px) {
  .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; } .kpi .v { font-size: 22px; } .kpi .d { display: none; }
}
.pg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; max-height: 640px; overflow: auto; padding: 2px; }
.pg { border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg2); overflow: hidden; transition: .15s; }
.pg.hl { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pg-none { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.pg-unknown { border-color: color-mix(in srgb, var(--err) 50%, var(--line)); }
.pg-img { position: relative; cursor: pointer; background: #fff; aspect-ratio: 210 / 297; overflow: hidden; }
.pg-img img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.pg-none .pg-img img, .pg-unknown .pg-img img { opacity: .55; }
.pg-cnt { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.pg-b { padding: 8px; }
.fs-tree .fs-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.fs-tree .fs-row:hover { background: var(--panel2); }
.fs-tree .fs-row.on { background: var(--accent-soft); }
.dlv { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.dlv-row { display: grid; grid-template-columns: minmax(200px, 260px) auto minmax(0, 1fr); gap: 16px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--panel2); }
.dlv-row:last-child { border-bottom: 0; }
.dlv-row.off .dlv-who { opacity: .5; }
.dlv-who { display: flex; gap: 10px; align-items: center; }
.dlv-who .lvl { min-width: 34px; text-align: center; }
.dlv-hint { font-size: 12.5px; color: var(--muted); }
.seg.wrap { flex-wrap: wrap; }
@media (max-width: 1280px) { .dlv-row { grid-template-columns: minmax(0, 1fr); gap: 8px; } }
/* согласование */
.stages { display: flex; flex-direction: column; gap: 8px; }
.stage { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); }
.stage-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--warn-soft); color: var(--warn); flex: none; }
.stage.approved .stage-n { background: var(--ok-soft); color: var(--ok); }
.stage.rejected .stage-n { background: var(--err-soft); color: var(--err); }
.rule-list { display: flex; flex-direction: column; gap: 10px; }
.rule.paused { opacity: .6; }
.rule-grid { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; }
.rule-n { width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.rule-cols { display: grid; grid-template-columns: 1.3fr 1.2fr .9fr; gap: 16px; font-size: 13px; }
.rule-cols .lbl { margin-bottom: 2px; }
.rule-act { display: flex; align-items: center; gap: 6px; }
svg.rot90 { transform: rotate(90deg); }
.form-sec { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--panel2); }
.form-sec-h { font-weight: 600; margin-bottom: 12px; display: flex; gap: 8px; align-items: baseline; }
.chk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
@media (max-width: 1000px) { .rule-cols { grid-template-columns: 1fr; gap: 8px; } .rule-grid { grid-template-columns: 36px minmax(0, 1fr); } .rule-act { grid-column: 2; } }
.attach { max-width: 100%; }
.attach > span:nth-child(2) { min-width: 0; overflow: hidden; }
.attach b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* v4: единые макеты карточек и форм */
.dlv-row { grid-template-columns: 250px minmax(0, 1fr); align-items: start; }
.dlv-ctl { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dlv-who { padding-top: 4px; }
@media (max-width: 1100px) { .dlv-row { grid-template-columns: minmax(0, 1fr); } }
.tcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tcard { display: flex; flex-direction: column; padding: 18px; gap: 12px; }
.tcard.paused { opacity: .6; }
.tcard-h { display: flex; align-items: center; gap: 12px; }
.tcard-h .ti { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.tcard-d { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; min-height: 38px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tcard-kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 12.5px; padding: 12px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.tcard-kv dt { color: var(--muted); }
.tcard-kv dd { margin: 0; min-width: 0; }
.tcard-f { display: flex; align-items: center; margin-top: auto; padding-top: 4px; }
.form-line { display: grid; grid-template-columns: 44px minmax(0, 1fr) 240px; gap: 10px; align-items: center; }
.form-line .lvl { text-align: center; }
.type-card { display: flex; flex-direction: column; }
.type-card .tags { margin-top: auto; padding-top: 10px; }
.kv > span { min-width: 0; overflow-wrap: anywhere; }
.modal .kv { grid-template-columns: 130px minmax(0, 1fr); }
@media (max-width: 700px) { .form-line { grid-template-columns: 44px minmax(0, 1fr); } .form-line > :last-child { grid-column: 1 / -1; } .chk-grid { grid-template-columns: 1fr; } }
