/* Общий стиль панели: нейтральная палитра и компоненты в духе shadcn/ui, без сборки.
   Тема задаётся атрибутом data-theme у <html>; по умолчанию светлая. */
:root {
  color-scheme: light;
  --page: #fafafa; --surface: #ffffff; --ink: #0a0a0a; --ink2: #525252; --muted: #737373;
  --border: #e5e5e5; --grid: #ededed; --axis: #d4d4d4; --wash: #f5f5f5;
  --primary: #171717; --primary-ink: #fafafa; --ring: rgba(10, 10, 10, .22);
  --danger: #dc2626; --ok: #15803d; --ok-bg: #f0fdf4; --warn: #b45309; --warn-bg: #fffbeb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05); --pop: 0 10px 30px rgba(0, 0, 0, .14);
  --radius: 10px;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0a0a0a; --surface: #171717; --ink: #fafafa; --ink2: #d4d4d4; --muted: #a1a1a1;
  --border: #2e2e2e; --grid: #262626; --axis: #404040; --wash: #262626;
  --primary: #e5e5e5; --primary-ink: #171717; --ring: rgba(250, 250, 250, .3);
  --danger: #f87171; --ok: #4ade80; --ok-bg: #0f2a1a; --warn: #fbbf24; --warn-bg: #2a2110;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --pop: 0 10px 30px rgba(0, 0, 0, .6);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink);
       font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-underline-offset: 3px; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.muted { color: var(--muted); }
.sub { color: var(--ink2); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- каркас ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent);
          backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 1480px; margin: 0 auto; padding: 0 16px; height: 54px; display: flex; align-items: center; gap: 18px; }
.brand { font-weight: 700; letter-spacing: -.01em; text-decoration: none; white-space: nowrap; display: flex;
         align-items: center; gap: 8px; }
.brand i { width: 22px; height: 22px; border-radius: 6px; background: var(--primary); display: grid; place-items: center;
           color: var(--primary-ink); font: 700 11px/1 ui-sans-serif, system-ui, sans-serif; font-style: normal; }
.tabs { display: flex; gap: 2px; flex: 1; min-width: 0; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--ink2); text-decoration: none; font-weight: 500;
          white-space: nowrap; }
.tabs a:hover { background: var(--wash); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--wash); color: var(--ink); }
.who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.who .name { color: var(--ink2); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { max-width: 1480px; margin: 0 auto; padding: 20px 16px 56px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; }
.page-head .grow { flex: 1 1 260px; min-width: 0; }
.page-head .acts { display: flex; flex-wrap: wrap; gap: 8px; }
#status { color: var(--ink2); margin-top: 2px; }
#status.warn { color: var(--danger); font-weight: 500; }

@media (max-width: 720px) {
  /* Телефон: разделы уходят во вторую строку шапки и делят её поровну. */
  .topbar-in { height: auto; flex-wrap: wrap; gap: 0 10px; padding: 0 12px; }
  .brand { height: 46px; }
  .who { margin-left: auto; }
  .who .name { display: none; }
  .tabs { order: 3; flex: 1 1 100%; padding-bottom: 8px; }
  .tabs a { flex: 1; text-align: center; padding: 7px 4px; }
  main { padding: 14px 12px 40px; }
  h1 { font-size: 20px; }
}

/* ---------- кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
       font: inherit; font-weight: 500; color: var(--primary-ink); background: var(--primary); border: 1px solid transparent;
       border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow);
       transition: opacity .12s, background .12s; }
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.outline { color: var(--ink); background: var(--surface); border-color: var(--border); }
.btn.outline:hover { opacity: 1; background: var(--wash); }
.btn.ghost { color: var(--ink2); background: none; box-shadow: none; }
.btn.ghost:hover { opacity: 1; background: var(--wash); color: var(--ink); }
.btn.danger { color: #fff; background: var(--danger); }
.btn.outline.danger { color: var(--danger); background: var(--surface); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.icon { width: 34px; padding: 0; }

.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 11px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
textarea.input { height: auto; padding: 9px 11px; line-height: 1.45; resize: vertical; min-height: 140px; }
.input::placeholder { color: var(--muted); }
.input:focus-visible { outline: 2px solid var(--ring); outline-offset: 0; border-color: var(--ink2); }
select.input { width: auto; padding-right: 28px; }
input[type="date"].input { width: auto; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; max-width: 100%; }
.field > span, .label { font-size: 12px; font-weight: 500; color: var(--ink2); }
.help { font-size: 12px; color: var(--muted); }

/* Переключатель из нескольких значений (как Tabs в shadcn). */
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; padding: 3px; gap: 2px; background: var(--wash);
       border-radius: 9px; }
.seg button { height: 28px; padding: 0 10px; font: inherit; font-size: 13px; font-weight: 500; color: var(--ink2);
              background: none; border: 0; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.seg button:disabled { opacity: .4; cursor: default; }

.switch { position: relative; width: 40px; height: 22px; flex: none; border: 0; border-radius: 999px;
          background: var(--axis); cursor: pointer; transition: background .15s; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
                 background: var(--surface); box-shadow: var(--shadow); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* ---------- карточки, плитки, значки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 16px 18px 0; }
.card-head h2 + p { margin-top: 3px; color: var(--ink2); font-size: 13px; }
.card-body { padding: 16px 18px 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { padding: 12px 14px; min-width: 0; }
.tile .label { display: block; }
.tile .value { font-size: 24px; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile .note { font-size: 12px; color: var(--ink2); min-height: 1.5em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
         font-size: 12px; font-weight: 500; color: var(--ink2); background: var(--wash); white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 11px 14px; margin-bottom: 14px;
          border: 1px solid var(--border); border-radius: var(--radius); background: var(--warn-bg); }
.notice p { flex: 1 1 260px; }
.empty { padding: 56px 16px; text-align: center; color: var(--ink2); }

/* ---------- таблица ---------- */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface); }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--wash) 60%, var(--surface)); }
td small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
td.none { color: var(--muted); }

/* ---------- окно и всплывающие сообщения ---------- */
dialog { width: min(560px, calc(100vw - 24px)); padding: 0; color: var(--ink); background: var(--surface);
         border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--pop); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
dialog .acts { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px;
          max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 11px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
         box-shadow: var(--pop); font-size: 13px; }
.toast.bad { border-color: var(--danger); }
@media (max-width: 720px) { #toasts { left: 12px; right: 12px; max-width: none; } }
