:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e7edf4;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent-hover: #5ba3ff;
  --danger: #f85149;
  --ok: #3fb950;
  --radius: 10px;
  --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; }
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
}

.sidebar h2 {
  margin: 0 1rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar nav a {
  display: block;
  padding: 0.65rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(61, 139, 253, 0.08); color: var(--accent-hover); text-decoration: none; }
.sidebar nav a.active { border-left-color: var(--accent); background: rgba(61, 139, 253, 0.12); color: var(--accent-hover); }

.main {
  padding: 1.75rem 2rem 3rem;
  max-width: 1100px;
}

.main h1 { margin: 0 0 1rem; font-size: 1.5rem; font-weight: 650; }
.main h2 { margin: 1.5rem 0 0.75rem; font-size: 1.1rem; }

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

.muted { color: var(--muted); font-size: 0.9rem; }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }

label { display: block; margin-top: 0.85rem; font-weight: 600; font-size: 0.9rem; }
input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  max-width: 100%;
  padding: 0.55rem 0.75rem;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 100px; resize: vertical; }

button, .btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  margin-top: 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.secondary { background: var(--border); color: var(--text); }
button:hover { filter: brightness(1.08); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.data th,
table.data td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}
table.data th { background: rgba(0,0,0,0.2); color: var(--muted); font-weight: 600; }
table.data tr:hover td { background: rgba(61, 139, 253, 0.06); }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 6px; font-size: 0.75rem; background: var(--border); }
.flash-ok { color: var(--ok); margin-bottom: 1rem; }
.flash-err { color: var(--danger); margin-bottom: 1rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.stat .num { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat .lbl { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }

.pager { margin-top: 1rem; display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.login-wrap { max-width: 400px; margin: 3rem auto; padding: 0 1rem; }
.login-wrap h1 { font-size: 1.35rem; }

.mono { font-family: ui-monospace, monospace; font-size: 0.8rem; word-break: break-all; }
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dashboard */
.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.dashboard-header h1 { margin: 0; font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; }
.dashboard-header .sub { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.95rem; }
.dashboard-header .pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background: rgba(61, 139, 253, 0.12);
  border: 1px solid rgba(61, 139, 253, 0.35);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--accent-hover);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  position: relative;
  background: linear-gradient(145deg, var(--surface) 0%, rgba(26, 35, 50, 0.92) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem 1.25rem;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-accent, var(--accent));
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-card.kpi-blue { --kpi-accent: #3d8bfd; }
.kpi-card.kpi-green { --kpi-accent: #3fb950; }
.kpi-card.kpi-amber { --kpi-accent: #d29922; }
.kpi-card.kpi-violet { --kpi-accent: #a371f7; }
.kpi-card.kpi-cyan { --kpi-accent: #39c5cf; }
.kpi-card.kpi-rose { --kpi-accent: #f778ba; }

.kpi-card .kpi-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  background: rgba(61, 139, 253, 0.12);
}
.kpi-card.kpi-green .kpi-icon { background: rgba(63, 185, 80, 0.15); }
.kpi-card.kpi-amber .kpi-icon { background: rgba(210, 153, 34, 0.15); }
.kpi-card.kpi-violet .kpi-icon { background: rgba(163, 113, 247, 0.15); }
.kpi-card.kpi-cyan .kpi-icon { background: rgba(57, 197, 207, 0.15); }
.kpi-card.kpi-rose .kpi-icon { background: rgba(247, 120, 186, 0.15); }

.kpi-card .kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}
.kpi-card .kpi-label {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.kpi-card .kpi-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.9;
  line-height: 1.35;
}

.dashboard-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 2rem 0 0.85rem;
}
.dashboard-section-title:first-child { margin-top: 0; }

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

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-card .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
}
.panel-card .panel-head a { font-size: 0.85rem; font-weight: 600; }
.panel-card table.data { margin: 0; font-size: 0.82rem; }
.panel-card table.data th,
.panel-card table.data td { border-left: none; border-right: none; }
.panel-card table.data tr:last-child td { border-bottom: none; }

.main { max-width: 1200px; }

/* Subscribers / filters */
.subscribers-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.subscribers-header h1 { margin: 0; font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; }
.subscribers-header .sub { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.95rem; }

.filter-card {
  background: linear-gradient(145deg, var(--surface) 0%, rgba(26, 35, 50, 0.95) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.filter-card .filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 1rem 1.25rem;
  align-items: end;
}
@media (max-width: 900px) {
  .filter-card .filter-grid { grid-template-columns: 1fr; }
}
.filter-card label { margin-top: 0; }
.filter-card .filter-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-card button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-top: 0;
}
.filter-card button.secondary:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}
a.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
}
a.btn.secondary:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  text-decoration: none;
}

.subscribers-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}
.subscribers-meta .stat-inline {
  font-size: 0.9rem;
  color: var(--muted);
}
.subscribers-meta .stat-inline strong {
  color: var(--text);
  font-weight: 700;
}
.per-page-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.per-page-wrap select {
  width: auto;
  min-width: 4.5rem;
  margin-top: 0;
  padding: 0.4rem 0.65rem;
}

.table-wrap-pro {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.table-wrap-pro table.data {
  margin: 0;
  font-size: 0.8rem;
}
.table-wrap-pro table.data thead th {
  background: rgba(0, 0, 0, 0.35);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  padding: 0.65rem 0.75rem;
  white-space: nowrap;
}
.table-wrap-pro table.data tbody td {
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
}
.table-wrap-pro table.data tbody tr:hover td {
  background: rgba(61, 139, 253, 0.06);
}
.table-wrap-pro .col-id { width: 56px; }
.table-wrap-pro .col-narrow { max-width: 100px; }

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}
.pagination a {
  background: rgba(61, 139, 253, 0.1);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.pagination a:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  text-decoration: none;
}
.pagination .page-current {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  cursor: default;
}
.pagination .page-ellipsis {
  color: var(--muted);
  min-width: 1.5rem;
  border: none;
  background: transparent;
}
.pagination .page-nav { font-weight: 700; }
.pagination a.page-disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* History */
.history-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.history-header h1 { margin: 0; font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; }
.history-header .sub { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.95rem; }

.history-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.history-kpi {
  background: linear-gradient(145deg, var(--surface) 0%, rgba(26, 35, 50, 0.92) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  border-top: 3px solid var(--hkpi-accent, var(--accent));
}
.history-kpi.hkpi-blue { --hkpi-accent: #3d8bfd; }
.history-kpi.hkpi-green { --hkpi-accent: #3fb950; }
.history-kpi.hkpi-rose { --hkpi-accent: #f85149; }
.history-kpi.hkpi-amber { --hkpi-accent: #d29922; }

.history-kpi .hkpi-val {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.history-kpi .hkpi-lbl {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-top: 0.25rem;
}

.badge-mode-single {
  background: rgba(61, 139, 253, 0.18);
  color: #79b8ff;
  border: 1px solid rgba(61, 139, 253, 0.35);
}
.badge-mode-bulk {
  background: rgba(163, 113, 247, 0.15);
  color: #d2a8ff;
  border: 1px solid rgba(163, 113, 247, 0.35);
}
.badge-mode-all {
  background: rgba(210, 153, 34, 0.15);
  color: #e3b341;
  border: 1px solid rgba(210, 153, 34, 0.35);
}

.stat-num-ok { color: var(--ok); font-weight: 700; }
.stat-num-fail { color: var(--danger); font-weight: 700; }

/* Compose — tabbed push forms */
.compose-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.compose-header h1 { margin: 0; font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; }
.compose-header .sub { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.95rem; }

.compose-shell {
  background: linear-gradient(145deg, var(--surface) 0%, rgba(26, 35, 50, 0.96) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.compose-tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  padding: 0.35rem 0.5rem 0;
}

.compose-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.75rem 1.15rem;
  margin: 0;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  transition: color 0.15s, background 0.15s;
}
.compose-tab:hover {
  color: var(--text);
  background: rgba(61, 139, 253, 0.08);
}
.compose-tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 1px solid var(--surface);
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
  box-shadow: 0 -2px 0 var(--accent) inset;
}

.compose-panel {
  display: none;
  padding: 1.5rem 1.5rem 1.75rem;
}
.compose-panel.active {
  display: block;
}

.compose-panel .panel-intro {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: rgba(61, 139, 253, 0.08);
  border: 1px solid rgba(61, 139, 253, 0.22);
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}
.compose-panel.panel-danger .panel-intro {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.25);
  color: #e6c8c7;
}

.compose-panel label { margin-top: 0.85rem; }
.compose-panel label:first-of-type { margin-top: 0; }

.compose-actions {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.compose-actions button[type="submit"] {
  margin-top: 0;
  min-width: 8rem;
}
.compose-actions .hint-inline {
  font-size: 0.8rem;
  color: var(--muted);
}
