/* Финпанель. Цвета и размеры по макету docs/design/spc-001. */
:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --fg: #16202e;
  --muted: #667085;
  --line: #e4e7ec;
  --soft: #f7f8fa;
  --side: #14213a;
  --side-fg: #d6dbe4;
  --side-muted: #8592a8;
  --side-active: #22314d;
  --accent: #0f766e;
  --accent-soft: #e6f4f1;
  --ok-bg: #e7f6ec; --ok: #1e7b43;
  --warn-bg: #fdf1dc; --warn: #a15c07;
  --err-bg: #fde8e7; --err: #b42318;
  --info-bg: #e8eefc; --info: #2f55c5;
  --radius: 10px;
  --agent-width: 0px; /* N8: место под панель агента; 360px, когда она включена */
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }

/* Каркас: меню · экран · агент */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr) var(--agent-width); min-height: 100vh; }
.side { background: var(--side); color: var(--side-fg); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; border-bottom: 1px solid #ffffff14; }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.brand b { display: block; color: #fff; }
.brand small { color: var(--side-muted); }
.nav { flex: 1; padding-top: 8px; }
.nav h6 { margin: 18px 10px 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); font-weight: 600; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 8px; color: var(--side-fg); text-decoration: none; }
.nav a:hover { background: #ffffff0d; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav a.soon { color: var(--side-muted); pointer-events: none; }
.nav a.soon::after { content: "soon"; font-size: 11px; opacity: .7; }
.me { display: flex; gap: 10px; align-items: center; padding: 14px 8px 0; border-top: 1px solid #ffffff14; }
.me .who { flex: 1; min-width: 0; }
.me b { display: block; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { color: var(--side-muted); }
.me button { background: none; border: 0; color: var(--side-muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.me button:hover { color: #fff; background: #ffffff14; }

.main { min-width: 0; }
.top { height: 64px; display: flex; align-items: center; padding: 0 32px; background: var(--card); border-bottom: 1px solid var(--line); color: var(--muted); }
.top b { color: var(--fg); }
.page { padding: 32px; max-width: 1400px; }
.agent { border-left: 1px solid var(--line); background: var(--card); }
.agent[hidden] { display: none; }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.group td { background: var(--soft); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 10px 16px; }

.person { display: flex; gap: 12px; align-items: center; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #e9edf3; color: #344054; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.side .avatar { background: #ffffff1f; color: #fff; }
.person small { display: block; color: var(--muted); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.mute { background: var(--soft); color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9ced6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.link.danger { color: var(--err); }
.link:hover { text-decoration: underline; }

select.field, input.field { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); min-width: 0; }
select.field:disabled { background: var(--soft); color: var(--muted); }
select.access { padding: 5px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); font-size: 14px; }
select.access[data-v="full"] { background: var(--accent-soft); border-color: #a7d7cf; color: var(--accent); font-weight: 600; }
select.access[data-v="scoped"], select.access[data-v="read"] { background: #f1f7f6; border-color: #cfe5e1; }
select.access[data-v="none"] { color: var(--muted); }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px #0f172a40; }
dialog::backdrop { background: #0f172a66; }
dialog form { padding: 24px; }
dialog h2 { margin: 0 0 16px; font-size: 20px; }
dialog label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
dialog .field { width: 100%; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.copy { display: flex; gap: 8px; margin-top: 8px; }
.copy input { flex: 1; font-size: 13px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--fg); color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: 0 8px 24px #0003; z-index: 10; max-width: calc(100vw - 32px); }
.toast.err { background: var(--err); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.top .sep { margin: 0 8px; }
h2.section { font-size: 18px; margin: 8px 0 12px; }
.gap-left { margin-left: 6px; }
.nowrap { white-space: nowrap; }
.error { color: var(--err); }
.agent-tag { font-size: 12px; color: var(--info); font-weight: 600; }

/* Вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--side); }
.auth main { width: 100%; max-width: 380px; background: var(--card); border-radius: 14px; padding: 32px; }
.auth .brand { border: 0; padding: 0 0 20px; }
.auth .brand b { color: var(--fg); }
.auth .brand small { color: var(--muted); }
.auth h1 { font-size: 22px; margin-bottom: 16px; }
.auth label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 4px; }
.auth input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; }
.auth input:focus, .field:focus, .access:focus { outline: 2px solid #0f766e55; border-color: var(--accent); }
.auth .btn { width: 100%; justify-content: center; margin-top: 22px; padding: 11px; }
.auth .err { color: var(--err); min-height: 1.5em; margin: 12px 0 0; font-size: 14px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px 16px; }
  .nav { display: none; }
  .side.open .nav { display: block; }
  .brand { border: 0; padding: 0; }
  .menu-btn { display: inline-flex !important; }
  .me { padding-top: 10px; }
  .top { padding: 0 16px; }
  .page { padding: 20px 16px; }
  .head { flex-direction: column; }
  .agent { display: none; }
}
.menu-btn { display: none; margin-left: auto; background: none; border: 1px solid #ffffff2a; color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
