/* Mamba Admin — self-hosted stylesheet (CSP-safe: no @import/CDN/remote fonts).
   Covers the custom component classes used by Phase 0/1 templates AND the Tailwind
   utility classes used by the Phase 3-6 templates, unified into one light theme. */

:root {
  --bg: #f4f6f9;
  --fg: #1f2733;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --card: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --radius: 10px;
  --red: #dc2626;
  --amber-bg: #fff7ed;
  --amber-bd: #fed7aa;
  --amber-fg: #9a3412;
  --ok-bg: #ecfdf5;
  --ok-bd: #a7f3d0;
  --ok-fg: #047857;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 16px; }
h2 { font-size: 17px; font-weight: 650; margin: 0 0 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em;
  background: #f3f4f6; padding: 1px 5px; border-radius: 5px; }

/* ---- layout: topbar + nav + main ---- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 22px; background: var(--card);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 800; letter-spacing: .2px; font-size: 16px; white-space: nowrap; }
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 14px; }
.admin-nav a {
  color: var(--muted); font-weight: 600; padding: 6px 10px; border-radius: 8px;
  white-space: nowrap; transition: background .12s, color .12s;
}
.admin-nav a:hover { color: var(--fg); background: #eef2ff; text-decoration: none; }
.admin-nav a.is-active { color: var(--accent); background: #eef2ff; }
.admin-nav a.is-active:hover { color: var(--accent); }
.admin-nav__sep { width: 1px; align-self: stretch; margin: 2px 6px; background: var(--border); }
main { max-width: 1160px; margin: 0 auto; padding: 26px 22px 60px; }

/* narrow screens: let wide tables scroll instead of overflowing the viewport */
@media (max-width: 760px) {
  main { padding: 18px 14px 48px; }
  .card, .chart-block { padding: 16px; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .topbar { padding: 10px 14px; gap: 12px; }
}

/* ---- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.chart-block {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.chart-block canvas { max-width: 100%; }

/* ---- KPI grid ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 0 0 8px; }
.kpi-value { font-size: 26px; font-weight: 750; line-height: 1.1; }
.kpi-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---- callouts ---- */
.banner, .warn { border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; border: 1px solid var(--border); background: #f9fafb; }
.banner-warn, .warn { background: var(--amber-bg); border-color: var(--amber-bd); color: var(--amber-fg); }
.flash { background: var(--ok-bg); border: 1px solid var(--ok-bd); color: var(--ok-fg); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.error { color: var(--red); font-size: 13px; margin: 8px 0 0; }
.note { font-size: 12px; color: var(--muted); margin: 6px 0; }
.muted { color: var(--muted); }
.inactive, tr.inactive td { color: #9aa3b2; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; font-weight: 650; color: var(--muted); border-bottom: 2px solid var(--border); padding: 8px 10px; white-space: nowrap; }
tbody td { border-bottom: 1px solid var(--border); padding: 8px 10px; vertical-align: top; }
tbody tr:nth-child(even) td { background: #fcfcfd; }
tbody tr:hover td { background: #fafbff; }
/* right-align numeric columns: add class="num" to numeric <td>/<th> */
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* empty-state row */
td.empty-state { text-align: center; color: var(--muted); padding: 28px 10px; }

/* ---- forms ---- */
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--fg); font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { min-height: 110px; resize: vertical; }
button, .btn {
  display: inline-block; width: auto; padding: 9px 16px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--fg); font: inherit; font-weight: 600;
  cursor: pointer; transition: background .12s, border-color .12s;
}
button:hover, .btn:hover { background: #f3f4f6; text-decoration: none; }
.btn { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn:hover { background: #1d4fd8; }
/* destructive actions (Заблокировать / Отозвать / Удалить / Выключить) */
.btn-danger {
  background: #fff; color: var(--red); border-color: #f3c2c2;
}
.btn-danger:hover { background: #fee2e2; border-color: var(--red); color: var(--red); }
form.space-y-3 button[type=submit], .login-card button { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
form.space-y-3 button[type=submit]:hover, .login-card button:hover { background: #1d4fd8; }

/* ---- login ---- */
.login-wrap { min-height: calc(100vh - 58px); display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; margin-bottom: 0; }
.login-card button { width: 100%; margin-top: 14px; }

/* ---- broadcast preview bubble ---- */
.tg-bubble { background: #eef3fb; border: 1px solid #dbe6f5; border-radius: 14px; padding: 12px 14px; max-width: 28rem; }
.tg-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.tg-button { display: inline-block; margin-top: 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; color: var(--accent); font-size: 14px; }

/* =========================================================================
   Tailwind utility subset actually used by the templates (default values).
   ========================================================================= */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-end { align-items: flex-end; }
.inline-block { display: inline-block; }
.block { display: block; }
.gap-2 { gap: .5rem; }
.space-y-3 > * + * { margin-top: .75rem; }

.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }

.p-3 { padding: .75rem; }
.px-2 { padding-left: .5rem; padding-right: .5rem; }
.px-3 { padding-left: .75rem; padding-right: .75rem; }
.py-1 { padding-top: .25rem; padding-bottom: .25rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }

.border { border: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-t-2 { border-top: 2px solid var(--border); }
.border-collapse { border-collapse: collapse; }
.rounded { border-radius: 8px; }

.text-xs { font-size: 12px; line-height: 1.4; }
.text-sm { font-size: 14px; line-height: 1.45; }
.text-xl { font-size: 20px; line-height: 1.3; }
.font-semibold { font-weight: 600; }
.text-left { text-align: left; }
.underline { text-decoration: underline; }
.text-red-600 { color: var(--red); }
.text-gray-500 { color: var(--muted); }
.text-gray-400 { color: #9ca3af; }

.bg-gray-50 { background: #f9fafb; }
.bg-gray-100 { background: #f3f4f6; }

/* utility-styled inputs/buttons (e.g. `border rounded px-2 py-1`) shouldn't be forced full-width */
input.px-2, input.px-3, select.px-2, select.px-3, button.px-2, button.px-3 { width: auto; }
