/* AI M2Devel — операционный дашборд. Тёмный control-center, editorial-типографика. */
:root {
  --bg: oklch(17% 0.02 265);
  --bg-2: oklch(21% 0.025 265);
  --surface: oklch(24% 0.03 265);
  --surface-2: oklch(28% 0.035 265);
  --line: oklch(34% 0.03 265);
  --text: oklch(96% 0.01 265);
  --muted: oklch(70% 0.02 265);
  --accent: oklch(72% 0.17 250);
  --ok: oklch(74% 0.16 150);
  --warn: oklch(80% 0.15 85);
  --crit: oklch(67% 0.2 25);
  --r: 14px;
  --space: clamp(1rem, 0.6rem + 1.2vw, 1.6rem);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  display: grid; grid-template-columns: 248px 1fr; min-height: 100vh;
}

/* ── Sidebar ── */
.rail {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--line); padding: 1.4rem 1rem;
  display: flex; flex-direction: column; gap: 1.6rem; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 .4rem; }
.brand-mark {
  font-weight: 800; background: var(--accent); color: oklch(20% 0.03 265);
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; letter-spacing: -.5px;
}
.brand-text { font-weight: 650; letter-spacing: .2px; }
#nav { display: flex; flex-direction: column; gap: .25rem; }
.nav-item {
  text-align: left; background: transparent; border: 0; color: var(--muted);
  font: inherit; font-size: .95rem; padding: .6rem .7rem; border-radius: 10px; cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.is-active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.rail-foot { margin-top: auto; font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: .5rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px oklch(74% 0.16 150 / .15); }
.dot.bad { background: var(--crit); }

/* ── Stage ── */
.stage { padding: var(--space) clamp(1rem, 0.5rem + 2vw, 2.4rem); }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 1.4rem; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem); font-weight: 700; letter-spacing: -.5px; }
.muted { color: var(--muted); font-size: .9rem; }
.btn {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: .55rem .9rem; border-radius: 10px; font: inherit; cursor: pointer; transition: all .2s var(--ease);
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.loading { color: var(--muted); padding: 3rem; text-align: center; }
.topbar-actions { display: flex; align-items: center; gap: .8rem; }
.role-pick { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: .4rem; }
.role-pick select {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  font: inherit; padding: .45rem .6rem; border-radius: 9px; cursor: pointer;
}
.nav-item.hidden { display: none; }

/* AI-директор */
.headline { font-size: 1.15rem; font-weight: 650; margin-bottom: 1.1rem; line-height: 1.4; }
.brief { display: flex; flex-direction: column; gap: .55rem; }
.brief-item {
  display: flex; gap: .8rem; align-items: flex-start; padding: .8rem .95rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; border-left-width: 4px;
}
.brief-item.critical { border-left-color: var(--crit); }
.brief-item.high { border-left-color: var(--warn); }
.brief-item.info { border-left-color: var(--accent); }
.brief-item .cat { color: var(--muted); font-size: .73rem; text-transform: uppercase; letter-spacing: .4px; }
.brief-item .txt { font-size: .95rem; }
.pf-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: .3rem; max-width: 220px; }
.pf-bar > span { display: block; height: 100%; background: var(--accent); }
.pf-bar.over > span { background: var(--crit); }

/* ── KPI ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .3rem; transition: transform .2s var(--ease);
}
.kpi:hover { transform: translateY(-2px); border-color: var(--line); }
.kpi .val { font-size: 2rem; font-weight: 750; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.kpi .lbl { color: var(--muted); font-size: .82rem; }
.kpi.alert .val { color: var(--warn); }
.kpi.crit .val { color: var(--crit); }

/* ── Panels / grid ── */
.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.1rem; margin-top: 1.2rem; }
@media (max-width: 980px) { body { grid-template-columns: 1fr; } .rail { position: static; height: auto; } .cols { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.2rem; }
.panel h2 { font-size: 1rem; font-weight: 650; margin-bottom: .9rem; display: flex; justify-content: space-between; align-items: center; }
.panel h2 .count { color: var(--muted); font-weight: 500; font-size: .85rem; }

/* ── Feed / list ── */
.feed { display: flex; flex-direction: column; gap: .1rem; }
.feed-item { padding: .65rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .t { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: .78rem; text-transform: uppercase;
     letter-spacing: .4px; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); }
tr:hover td { background: var(--surface-2); }
.tag { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.tag.low { background: oklch(74% 0.16 150 / .16); color: var(--ok); }
.tag.medium { background: oklch(80% 0.15 85 / .16); color: var(--warn); }
.tag.high, .tag.critical { background: oklch(67% 0.2 25 / .16); color: var(--crit); }
.tag.neutral { background: var(--surface-2); color: var(--muted); }

/* ── Cards grid (agents/objects) ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem;
  cursor: pointer; transition: all .2s var(--ease);
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .title { font-weight: 650; margin-bottom: .25rem; }
.card .sub { color: var(--muted); font-size: .82rem; }
.card .row { display: flex; gap: 1rem; margin-top: .7rem; font-size: .85rem; }
.card .row b { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 1.4rem 0; }
.pill-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }

/* Формы */
.form { display: flex; flex-direction: column; gap: .7rem; }
.form label { font-size: .82rem; color: var(--muted); display: flex; flex-direction: column; gap: .3rem; }
.form input, .form select, .form textarea {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  font: inherit; padding: .55rem .7rem; border-radius: 9px; width: 100%;
}
.form textarea { min-height: 90px; resize: vertical; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.btn.primary { background: var(--accent); color: oklch(20% 0.03 265); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.note { font-size: .82rem; padding: .55rem .7rem; border-radius: 9px; margin-top: .5rem; }
.note.ok { background: oklch(74% 0.16 150 / .14); color: var(--ok); }
.note.err { background: oklch(67% 0.2 25 / .14); color: var(--crit); }
.row-actions { display: flex; gap: .5rem; align-items: center; }
input[type="file"] { padding: .4rem; }

/* Режим входа: только форма, без меню и шапки */
body.login-mode { display: block; }
body.login-mode .rail,
body.login-mode .topbar { display: none; }
body.login-mode .stage { padding: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
body.login-mode .view { width: 100%; display: flex; justify-content: center; }
.login-card { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; margin-bottom: 1rem; letter-spacing: .2px; }
.login-brand .brand-mark {
  width: 30px; height: 30px; font-size: .9rem; border-radius: 8px;
  background: var(--accent); color: oklch(20% 0.03 265); display: grid; place-items: center; font-weight: 800;
}
