:root {
  --bg: #15130f;
  --panel: #1e1b16;
  --panel-2: #26221b;
  --line: #3a342a;
  --text: #f1ebe0;
  --muted: #a99f8f;
  --gold: #b9853a;
  --gold-2: #d6a75c;
  --green: #6fbf8a;
  --red: #e07a6a;
  --blue: #7fa8d8;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 Montserrat, system-ui, -apple-system, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--gold-2); }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; margin: 8px 0 0; }

/* Бренд */
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; letter-spacing: .18em; font-size: 14px; }
.brand small { color: var(--muted); font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--text); color: var(--bg);
  display: grid; place-items: center; font: 700 22px Georgia, serif; }

/* Вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; display: grid; gap: 14px; }
.auth-card h1 { margin: 8px 0 0; font-size: 22px; }
.auth-card p { margin: 0; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; }
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: transparent; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 0; padding: 11px 16px;
  background: var(--gold); color: #fff; font-weight: 600; }
button:hover { background: var(--gold-2); }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; color: var(--muted); padding: 4px; font-weight: 500; }
button.link:hover { color: var(--text); }
button.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }

/* Шапка */
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center;
  padding: 12px 20px; background: rgba(21,19,15,.95); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px); flex-wrap: wrap; }
#tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
#tabs button { background: none; color: var(--muted); padding: 8px 12px; white-space: nowrap; font-weight: 500; }
#tabs button.active { background: var(--panel-2); color: var(--text); }
.who { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }
h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 15px; margin: 22px 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

/* Плитки */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tile .v { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 13px; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Таблицы */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar input { max-width: 320px; }
.toolbar select { max-width: 240px; }
.count { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  background: var(--panel-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub { color: var(--muted); font-size: 12px; }

/* Метки */
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); margin: 0 4px 4px 0; white-space: nowrap; }
.tag.gold { color: var(--gold-2); border-color: #5a4423; }
.tag.green { color: var(--green); border-color: #2f5a3d; }
.tag.red { color: var(--red); border-color: #5d3029; }
.tag.blue { color: var(--blue); border-color: #2d4560; }

.note { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 12px 14px; margin: 12px 0; color: var(--muted); }
.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 20px; }

@media (max-width: 720px) {
  .top { padding: 10px 12px; }
  main { padding: 14px 12px; }
  .who { width: 100%; justify-content: space-between; }
  .tile .v { font-size: 22px; }
}

/* Полосы в таблице по месяцам */
.barcell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.barcell .num { white-space: nowrap; font-size: 13px; }
.bar { flex: 1; height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar span { display: block; height: 100%; border-radius: 4px; }
.bar.gold span { background: var(--gold); }
.bar.green span { background: var(--green); }
input[type="date"] { color-scheme: dark; }

/* Раскрывающиеся блоки и галочки */
details.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; }
details.box summary { cursor: pointer; color: var(--text); font-weight: 600; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 14px; margin-top: 8px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 13px; }
label.check input { width: auto; }

/* Ручной доступ */
.grant-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; max-width: 640px; }
.grant-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.results { display: flex; flex-wrap: wrap; gap: 6px; }
.results button { padding: 6px 10px; font-weight: 500; }
td.actions { white-space: nowrap; }
td.actions button { padding: 6px 10px; font-size: 13px; margin: 0 4px 4px 0; }
button.danger { color: var(--red); }
@media (max-width: 720px) { .grant-form .row2 { grid-template-columns: 1fr; } td.actions { white-space: normal; } }

/* Письма */
.mailbox { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; }
.mailbox .toolbar { margin: 0; }
pre.msg { white-space: pre-wrap; word-break: break-word; margin: 0; font: 13px/1.5 Montserrat, system-ui, sans-serif; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
