:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --line: #e3e7ec;
    --text: #232b35;
    --muted: #7a8794;
    --accent: #2066b0;
    --accent-soft: #eaf2fb;
    --green: #1c8c3b;
    --red: #c0392b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 13px/1.45 "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

.empty { padding: 48px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ шапка */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.tabs { display: flex; gap: 4px; margin-bottom: 10px; }

.tab {
    border: 0;
    background: transparent;
    padding: 7px 14px;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
}

.tab.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.filters label { display: flex; align-items: center; gap: 5px; color: var(--muted); }

input[type="date"], select, input[type="text"] {
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 5px 7px;
    font-size: 13px;
    color: var(--text);
    background: #fff;
}

.btn {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 5px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .9; color: #fff; }

/* ------------------------------------------------------------ вкладки */
.view { display: none; padding: 16px; }
.view.is-active { display: block; }

/* ------------------------------------------------------------ таблица */
.report { overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }

table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; }

table.grid th, table.grid td {
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: 7px 9px;
    text-align: center;
    white-space: nowrap;
}

table.grid thead th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    font-weight: 600;
    color: var(--muted);
    z-index: 5;
}

table.grid thead th.metric { min-width: 120px; }

table.grid td.name, table.grid th.name {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--card);
    z-index: 6;
    font-weight: 600;
    min-width: 200px;
}

table.grid thead th.name { z-index: 8; background: #f8fafc; }

table.grid tbody tr:hover td { background: #fafcff; }
table.grid tbody tr:hover td.name { background: #f2f7fd; }

tr.total td { background: #f4f8fd !important; font-weight: 700; border-top: 2px solid var(--accent); }

.val-day { color: var(--accent); font-weight: 600; }
.val-sep { color: #c8d0d8; margin: 0 3px; }
.val-period { color: var(--text); }
.val-zero { color: #c2cad3; font-weight: 400; }

.hint { color: var(--muted); font-size: 12px; padding: 8px 4px; }

/* ------------------------------------------------------------ настройки */
.settings { max-width: 1000px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 14px;
}

.card h2 { margin: 0 0 4px; font-size: 15px; }
.card p.desc { margin: 0 0 14px; color: var(--muted); font-size: 12px; }

.row { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; flex-wrap: wrap; }
.row > div { flex: 1 1 260px; min-width: 240px; }
.row label.cap { display: block; font-weight: 600; margin-bottom: 4px; }
.row .sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

select.wide, input.wide { width: 100%; }
select[multiple] { height: 120px; }

.actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }

/* ------------------------------------------------------------ прочее */
.loader {
    position: fixed; inset: 0; background: rgba(255,255,255,.75);
    display: flex; align-items: center; justify-content: center; gap: 12px;
    z-index: 50; color: var(--muted);
}

.spinner {
    width: 22px; height: 22px; border: 3px solid var(--line);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
    position: fixed; right: 18px; bottom: 18px; z-index: 60;
    background: #232b35; color: #fff; padding: 10px 16px; border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,.18); max-width: 420px;
}

.toast.err { background: var(--red); }
.hidden { display: none !important; }
