/* Интерфейс кабинета. Одна таблица стилей, без препроцессоров и сборки —
   как и остальной фронтенд, она едет внутри бинарника api. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #a16207;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --surface: #1e2126;
    --border: #2e333b;
    --text: #e8eaed;
    --muted: #9aa3af;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --ok: #4ade80;
    --ok-bg: #14351f;
    --warn: #fbbf24;
    --warn-bg: #3a2e0c;
    --bad: #f87171;
    --bad-bg: #3d1717;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* ------------------------------------------------------------- шапка */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand span { color: var(--accent); }

.topbar nav { display: flex; gap: 4px; flex: 1; }

.topbar nav a {
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
}
.topbar nav a:hover { background: var(--bg); color: var(--text); }
.topbar nav a.active { background: var(--bg); color: var(--text); font-weight: 600; }

.topbar .user { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.topbar .balance { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }

/* ------------------------------------------------------- типографика */

h1 { font-size: 22px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 16px; margin: 0 0 12px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.back { font-size: 13px; color: var(--muted); text-decoration: none; display: block; margin-bottom: 4px; }
.back:hover { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.negative { color: var(--bad); }
.error-text { color: var(--bad); }
code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; }

/* ------------------------------------------------------------ блоки */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
}
.empty p { margin: 4px 0; }

.banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.error { background: var(--bad-bg); color: var(--bad); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }

/* -------------------------------------------------------- показатели */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tile .label { font-size: 12px; color: var(--muted); }
.tile .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile .sub { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------ таблицы */

.grid { width: 100%; border-collapse: collapse; }

.grid th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.grid td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--bg); }

.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid.compact td, .grid.compact th { padding: 8px 10px; }
.grid a { color: var(--accent); text-decoration: none; }
.grid a:hover { text-decoration: underline; }

.grid .actions { text-align: right; white-space: nowrap; }
.grid .actions form { display: inline; }

.thumb img { max-width: 56px; max-height: 56px; border-radius: 4px; display: block; }

/* Полоса освоения бюджета. Ширина приходит инлайновым стилем из шаблона —
   это единственный способ передать вычисленное значение без JS. */
.bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.bar span { display: block; height: 100%; background: var(--accent); }

/* ------------------------------------------------------------- статусы */

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.status.bad { background: var(--bad-bg); color: var(--bad); }
.status.muted { background: var(--bg); color: var(--muted); }

.tag {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--muted);
}

/* --------------------------------------------------------------- формы */

label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 500; }
label small { display: block; font-weight: 400; margin-top: 4px; }

label.check {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 400;
  margin-bottom: 8px;
}
label.check input { width: auto; margin: 0; }

input, select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}
input:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; }

.row { display: flex; gap: 16px; }
.row > label { flex: 1; }
@media (max-width: 700px) { .row { flex-direction: column; gap: 0; } }

.inline { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.inline input { width: 6em; margin: 0; }

.inline-form { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.inline-form input { margin: 0; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 0 0 14px;
}
legend { font-size: 12px; color: var(--muted); padding: 0 6px; }

.filters {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filters label { margin-bottom: 0; }
.filters button { margin-bottom: 1px; }

/* -------------------------------------------------------------- кнопки */

button, .button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { background: var(--bg); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

button.wide { width: 100%; }

button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 4px 6px;
}
button.link:hover { background: var(--bg); text-decoration: underline; }
button.link.danger { color: var(--bad); }

/* ----------------------------------------------------------- диалоги */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
  width: calc(100% - 32px);
  background: var(--surface);
  color: var(--text);
}
dialog.wide-dialog { max-width: 760px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin-bottom: 16px; }

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
}

/* ------------------------------------------------------------ вход */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}
.login { max-width: 360px; width: 100%; }
.login h1 { font-size: 24px; margin-bottom: 2px; }
.login h1 span { color: var(--accent); }
.login p { margin: 0 0 20px; }

.balance-big {
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
