:root {
  --bg: #0b0f17;
  --bg-2: #111826;
  --bg-3: #1a2334;
  --line: #243049;
  --text: #e7ecf3;
  --muted: #97a3b6;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14px;
  height: 100%;
}
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }

button, .btn {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  transition: all .15s ease;
}
button:hover, .btn:hover { border-color: var(--primary); }
button.primary, .btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
button.primary:hover, .btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}

label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12.5px; }

.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 200px; }

/* ---- AUTH PAGE ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top left, rgba(99,102,241,.15), transparent 50%),
              radial-gradient(circle at bottom right, rgba(34,197,94,.08), transparent 50%),
              var(--bg);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p.sub { margin: 0 0 22px; color: var(--muted); }

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 18px;
  margin-bottom: 18px;
}
.brand-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), #22d3ee);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700;
}

.error-msg { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.success-msg { background: rgba(34,197,94,.12); color: #86efac; border: 1px solid rgba(34,197,94,.3); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

/* ---- LAYOUT ---- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex; flex-direction: column;
}
.sidebar .brand { padding: 0 8px 18px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  color: var(--muted);
  border-radius: var(--radius);
  font-weight: 500;
}
.nav a:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(99,102,241,.16); color: var(--primary-2); }
.nav .icn { width: 18px; display: inline-flex; }

.user-card { padding: 12px; background: var(--bg-3); border-radius: var(--radius); }
.user-card .who { font-weight: 600; }
.user-card .role { color: var(--muted); font-size: 12px; }

.main { padding: 26px 30px; overflow: auto; }
.page-title { font-size: 22px; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }

/* ---- CARDS / GRID ---- */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.card .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.section { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 20px; }
.section h2 { margin: 0 0 14px; font-size: 16px; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.ok { background: rgba(34,197,94,.15); color: #86efac; }
.badge.bad { background: rgba(239,68,68,.15); color: #fca5a5; }
.badge.warn { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge.info { background: rgba(99,102,241,.15); color: var(--primary-2); }

table { width: 100%; border-collapse: collapse; }
table th, table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table tr:hover td { background: rgba(255,255,255,.02); }

.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding: 8px 0; }
.bar-chart .bar {
  flex: 1; min-width: 4px; background: var(--primary); border-radius: 3px 3px 0 0;
  position: relative; transition: opacity .15s;
}
.bar-chart .bar:hover { opacity: .8; }
.bar-chart .bar.failed { background: var(--danger); }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.chart-legend .l-sent::before { background: var(--primary); }
.chart-legend .l-fail::before { background: var(--danger); }

.pill {
  display: inline-block; background: var(--bg-3); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 6px; font-size: 12px; color: var(--muted); margin: 2px;
}

.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 14px; }
.plan {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 22px;
  position: relative;
}
.plan.current { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.plan .plan-name { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.plan .plan-price { color: var(--muted); margin-bottom: 14px; }
.plan .plan-limit { font-size: 28px; font-weight: 800; }
.plan .plan-limit small { font-size: 13px; color: var(--muted); font-weight: 500; }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.2); border-top-color: var(--primary-2);
  border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.help { font-size: 12px; color: var(--muted); margin-top: 6px; }

.progress {
  position: relative; height: 14px; background: var(--bg-3);
  border-radius: 4px; margin-top: 6px; overflow: hidden;
  border: 1px solid var(--line); font-size: 10px;
}
.progress-bar {
  position: absolute; left:0; top:0; bottom:0;
  background: linear-gradient(90deg, var(--primary), #22d3ee);
  transition: width .3s ease;
}
.progress span {
  position: absolute; left:0; right:0; text-align:center;
  line-height: 14px; color: #fff; font-weight:600;
  text-shadow: 0 0 3px rgba(0,0,0,.6);
}

.tabbar {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  margin-bottom: 18px; padding: 0 4px;
}
.tabbar .tab {
  padding: 9px 16px; color: var(--muted);
  border-bottom: 2px solid transparent;
  font-weight: 500; border-radius: 6px 6px 0 0;
}
.tabbar .tab:hover { background: var(--bg-3); text-decoration: none; color: var(--text); }
.tabbar .tab.active { color: var(--primary-2); border-bottom-color: var(--primary); }

.placeholder-help { background: var(--bg-3); padding: 10px 12px; border-radius: 8px; font-size: 12.5px; }
.placeholder-help code { background: var(--bg); padding: 1px 6px; border-radius: 4px; color: var(--primary-2); }

.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.right { margin-left: auto; }
.muted { color: var(--muted); }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
