:root {
  --bg: #f4f6f9;
  --panel: #fff;
  --ink: #1b1f24;
  --dim: #6b7480;
  --line: #e3e7ed;
  --brand: #2f8fff;
  --green: #28a745;
  --red: #dc3545;
  --yellow: #ffc107;
  --radius: 10px;
}
* { box-sizing: border-box; }
/* Атрибут hidden должен побеждать любые display из правил ниже (иначе .modal висит поверх страницы) */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--brand); }

/* ---------- каркас ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 56px;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.logo { font-weight: 700; font-size: 18px; }
.logo span { color: var(--brand); }
.burger { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; }

.sidebar {
  position: fixed; top: 56px; left: 0; bottom: 0; width: 210px; padding: 16px 0;
  background: #fff; border-right: 1px solid var(--line); overflow-y: auto;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: block; padding: 10px 20px; color: var(--ink); text-decoration: none; border-left: 3px solid transparent;
}
.sidebar a:hover { background: #f7f9fc; }
.sidebar a.active { color: var(--brand); border-left-color: var(--brand); background: #f0f7ff; font-weight: 600; }
.sidebar-overlay { display: none; }

.content { margin-left: 210px; padding: 20px; }
.tab { display: none; }
.tab.active { display: block; }

.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; margin: 0; }
.page-header .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- элементы ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn:hover { background: #f7f9fc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #1b7ae8; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 8px; font-size: 12px; }

input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  width: 100%;
}
select, .topbar select { width: auto; }
textarea { resize: vertical; }
.inp-sm { padding: 3px 6px; width: 90px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; }
.panel h3 { margin: 0 0 12px; font-size: 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card-value { font-size: 22px; font-weight: 700; }
.card-label { color: var(--dim); font-size: 12px; margin-top: 4px; }
.card-green .card-value { color: var(--green); }
.card-red .card-value { color: var(--red); }
.card-blue .card-value { color: var(--brand); }
.card-yellow .card-value { color: #b8860b; }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; height: 320px; }
.chart-box h3 { margin: 0 0 10px; font-size: 15px; }
.chart-box canvas { max-height: 250px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
.tbl tbody tr:hover { background: #f9fbfd; }
.tbl .empty { color: var(--dim); text-align: center; padding: 24px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: var(--dim); font-size: 12px; }
.badge-active { background: #e7f8ec; color: #1d7a34; }
.badge-planned { background: #eef4ff; color: #2f6ad9; }
.badge-rejected, .badge-blocked, .badge-error { background: #fdecee; color: #b3202f; }
.badge-old, .badge-archived, .badge-removed { background: #f1f2f4; color: #64707d; }
.badge-win { background: #e7f8ec; color: #1d7a34; }
.badge-lose { background: #fdecee; color: #b3202f; }
.badge-wait { background: #fff6e0; color: #8a6100; }

.hint { color: var(--dim); font-size: 13px; }
.dim { color: var(--dim); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--dim); }
.err-cell { color: var(--red); cursor: help; }
code { background: #f1f3f7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
pre { background: #10151c; color: #d6e2f0; padding: 14px; border-radius: 8px; overflow: auto; max-height: 460px; font-size: 12px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); }
.form-grid label.wide { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- модалка, тост, логин ---------- */
.modal { position: fixed; inset: 0; background: rgba(16, 21, 28, .45); z-index: 50; display: flex; padding: 20px; overflow: auto; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 20px; margin: auto; width: min(760px, 100%); }
.modal-box h3 { margin: 0 0 14px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 80px);
  background: #10151c; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0;
  transition: .25s; z-index: 60; max-width: 90vw;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast-error { background: var(--red); }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; width: min(340px, 92vw); display: flex; flex-direction: column; gap: 12px;
}
.login-box .err { color: var(--red); font-size: 13px; }

@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .burger { display: block; margin-left: auto; }
  .topbar-right { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: .2s; z-index: 40; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-overlay { display: block; position: fixed; inset: 56px 0 0; background: rgba(0,0,0,.3); z-index: 35; }
  .content { margin-left: 0; }
  .tbl { font-size: 12px; }
}
