/* Creatium ID — стиль Graphite (AI/ui.md). Цвета только через токены. */
:root {
  --bg: #0e0f13; --panel: #16181d; --panel2: #1c1f26; --line: #262a33; --line2: #323743;
  --text: #e7e9ee; --muted: #8a90a0; --faint: #5b6070; --accent: #7c6cff; --accent2: #9a8eff;
  --ok: #3ecf8e; --warn: #f5a524; --bad: #f2555a; --idle: #5b6070;
  --r: 10px; --r-sm: 6px; --gap: 14px; --pad: 16px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.55 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ── Кнопки и поля */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid transparent; background: var(--accent); color: #fff;
  font: 500 13.5px Inter, system-ui, sans-serif; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--accent2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; border-color: var(--line2); color: var(--text); }
.btn.ghost:hover { background: var(--panel2); }
.btn.quiet { background: transparent; color: var(--muted); padding: 0 8px; }
.btn.quiet:hover { color: var(--text); background: var(--panel2); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 14.5px; }

label.field { display: grid; gap: 6px; }
label.field > span { font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  width: 100%; height: 36px; padding: 0 11px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: 14px Inter, system-ui, sans-serif; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 70px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ── Верхняя панель */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .in { max-width: 1120px; margin: 0 auto; height: 56px; padding: 0 16px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; letter-spacing: -.01em; }
.brand img { width: 26px; height: 26px; border-radius: 6px; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 6px 10px; border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--panel2); }
.nav a.on { color: var(--text); background: var(--panel); }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; text-decoration: none; }
.who:hover { color: var(--text); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line2); color: var(--text); font-weight: 600; font-size: 12px; text-transform: uppercase; }

/* ── Раскладка страниц приложения */
.page { max-width: 1120px; margin: 0 auto; padding: 28px 16px 64px; }
.page.narrow { max-width: 760px; }
.head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head h1 { font-size: 22px; letter-spacing: -.015em; margin: 0; font-weight: 650; }
.head p { margin: 4px 0 0; color: var(--muted); }
.head .actions { margin-left: auto; display: flex; gap: 8px; }
h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 30px 0 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.panel.pad { padding: 18px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ── Сервисы */
.svc { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--gap); }
.tile { position: relative; display: flex; gap: 12px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; transition: border-color .12s, background .12s, transform .12s; }
a.tile:hover { border-color: var(--line2); background: color-mix(in srgb, var(--panel2) 70%, var(--panel)); }
.tile img { width: 40px; height: 40px; border-radius: 8px; flex: none; }
.tile .t { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tile .d { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tile.off { opacity: .45; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font: 500 11.5px var(--mono); background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.badge.view { color: #a7b0c4; }
.badge.download { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, var(--line)); }
.badge.upload { color: var(--accent2); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.badge.manage { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.badge.admin { color: var(--warn); }
.badge.off { color: var(--bad); }

/* ── Списки и таблицы */
.list { display: grid; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.list > .item:first-child { border-top: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--idle)); flex: none; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--panel2); }
tbody tr.sel td { background: color-mix(in srgb, var(--accent) 9%, var(--panel)); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ── Уровни доступа: сегментированный переключатель */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button { height: 26px; padding: 0 9px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font: 500 12px Inter, sans-serif; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.seg button.on[data-v=none] { color: var(--muted); }
.seg button.on[data-v=download] { color: var(--ok); }
.seg button.on[data-v=upload] { color: var(--accent2); }
.seg button.on[data-v=manage] { color: var(--warn); }

/* ── Вкладки */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { height: 38px; padding: 0 14px; border: 0; background: none; color: var(--muted); font: 500 14px Inter, sans-serif; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* ── Админка: список + карточка */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.side { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
.side .sec { padding: 16px 18px; border-top: 1px solid var(--line); }
.side .sec:first-child { border-top: 0; }
.side h3 { margin: 0 0 12px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.grant { display: grid; gap: 6px; padding: 7px 0; }
.grant .n { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.grant .seg { display: flex; }
.grant .seg button { flex: 1; padding: 0 4px; }
.grant img { width: 20px; height: 20px; border-radius: 4px; }
.grant.off .n { color: var(--faint); }

/* ── Уведомления, баннеры, модальные окна */
.note { padding: 11px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); color: var(--muted); }
.note.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); color: var(--text); background: color-mix(in srgb, var(--warn) 7%, var(--panel)); }
.note.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); color: var(--text); background: color-mix(in srgb, var(--bad) 8%, var(--panel)); }
.err { color: var(--bad); font-size: 13px; min-height: 20px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line2); box-shadow: 0 10px 30px #0008; transition: .18s; z-index: 50; }
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }
dialog { border: 1px solid var(--line2); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 30px 80px #000a; }
dialog::backdrop { background: #05060899; backdrop-filter: blur(2px); }
dialog .dh { padding: 18px 20px 4px; font-weight: 600; font-size: 16px; }
dialog .db { padding: 10px 20px 4px; display: grid; gap: 12px; }
dialog .df { padding: 16px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.secret { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg); border: 1px dashed var(--line2); border-radius: var(--r-sm); font: 500 15px var(--mono); letter-spacing: .02em; word-break: break-all; }
.secret code { flex: 1; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .hide-sm { display: none; }
  .top .in { gap: 10px; }
  .nav a { padding: 6px 7px; font-size: 13.5px; }
  .top .right { gap: 4px; }
}
