:root {
  --sb-w: 220px;
  --sb-bg: #1c2b3a;
  --sb-text: #94a3b8;
  --sb-active: #0d6efd;
  --sb-border: rgba(255,255,255,.08);
  --blue: #0d6efd;
  --red: #dc3545;
  --green: #16a34a;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

body.has-sidebar { padding-left: var(--sb-w); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sb-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid var(--sb-border);
  text-decoration: none;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 13.5px;
  transition: background .15s, color .15s;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
}

.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-item.active { background: var(--sb-active); color: #fff; }

.sidebar-logout {
  margin: 8px;
  margin-top: auto;
  color: #f87171;
}
.sidebar-logout:hover { background: rgba(248,113,113,.12); color: #fca5a5; }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.content-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-weight: 600; font-size: 15px; }

.content-main { padding: 24px; flex: 1; }
.auth-main { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ── Page head ───────────────────────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-head h1 { font-size: 20px; font-weight: 700; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn-primary    { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-outline    { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: #94a3b8; }
.btn-outline-warn   { background: transparent; color: #d97706; border-color: #fde68a; }
.btn-outline-danger { background: transparent; color: var(--red); border-color: #fca5a5; }
.btn-sm  { padding: 5px 10px; font-size: 12.5px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Client cards ────────────────────────────────────────────────────────── */

.client-list { display: flex; flex-direction: column; gap: 12px; }

.client-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.client-card--inactive { opacity: .6; }

.client-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.client-card__name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.client-card__actions { display: flex; gap: 6px; flex-wrap: wrap; }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot--on  { background: #22c55e; box-shadow: 0 0 0 2px #dcfce7; }
.status-dot--off { background: #94a3b8; }

.client-card__meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.meta-value { font-size: 13px; font-weight: 500; }

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge--ok    { background: #dcfce7; color: #15803d; }
.status-badge--error { background: #fee2e2; color: #b91c1c; }
.status-badge--idle  { background: #f1f5f9; color: #475569; }

/* ── Payment status ──────────────────────────────────────────────────────── */

.client-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.paid-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.paid-badge--ok      { background: #dcfce7; color: #15803d; }
.paid-badge--expired { background: #fee2e2; color: #b91c1c; }
.paid-badge--none    { background: #f1f5f9; color: #64748b; }

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-state__icon { font-size: 2.5rem; }
.empty-state__text { font-size: 16px; color: var(--muted); }

/* ── Auth ────────────────────────────────────────────────────────────────── */

.auth-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.auth-logo {
  width: 64px; height: 64px;
  background: var(--sb-bg);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.auth-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.auth-sub   { color: var(--muted); font-size: 13px; margin-bottom: 28px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.form-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 680px;
}

.form-section { margin-bottom: 28px; }
.form-section__title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.field { margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s;
}
.field-input:focus { outline: none; border-color: var(--blue); }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.req { color: var(--red); }

.field--switch { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.field--switch .field-label { margin: 0; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.switch__slider::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.switch input:checked + .switch__slider { background: var(--blue); }
.switch input:checked + .switch__slider::before { transform: translateX(20px); }

.form-actions { display: flex; gap: 10px; padding-top: 8px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  body.has-sidebar { padding-left: 0; }
  .sidebar { display: none; }
  .fields-row { grid-template-columns: 1fr; }
  .client-card__header { flex-direction: column; align-items: flex-start; }
}
