/* ============================================================
   WCG v2 — Design System
   Mobile-first, premium dark/light
   ============================================================ */

:root {
  --bg:       #0a0e17;
  --bg2:      #111827;
  --bg3:      #1a2235;
  --bg4:      #212d42;
  --border:   rgba(255,255,255,0.08);
  --border2:  rgba(255,255,255,0.14);
  --text:     #f1f5f9;
  --muted:    #94a3b8;
  --muted2:   #64748b;

  --accent:   #6366f1;
  --accent2:  #818cf8;
  --accent-bg: rgba(99,102,241,0.12);

  --green:    #10b981;
  --green-bg: rgba(16,185,129,0.1);
  --red:      #ef4444;
  --red-bg:   rgba(239,68,68,0.1);
  --amber:    #f59e0b;
  --amber-bg: rgba(245,158,11,0.1);
  --blue:     #3b82f6;
  --blue-bg:  rgba(59,130,246,0.1);

  --radius:   12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:     'SF Mono', 'Fira Code', monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:       #f8fafc;
    --bg2:      #ffffff;
    --bg3:      #f1f5f9;
    --bg4:      #e2e8f0;
    --border:   rgba(0,0,0,0.07);
    --border2:  rgba(0,0,0,0.12);
    --text:     #0f172a;
    --muted:    #475569;
    --muted2:   #94a3b8;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---- LAYOUT ---- */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 50;
  transition: transform .3s ease;
}
.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.sidebar-brand .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-brand .logo-text { font-size: 15px; font-weight: 600; color: var(--text); }
.sidebar-brand .logo-sub { font-size: 11px; color: var(--muted); }

.sidebar-nav { padding: 12px 8px; flex: 1; overflow-y: auto; }
.nav-section { margin-bottom: 20px; }
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted2);
  padding: 0 12px;
  margin-bottom: 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  transition: all .15s;
  position: relative;
}
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--accent-bg); color: var(--accent2); font-weight: 500; }
.nav-link .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .7; }
.nav-link.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  text-decoration: none;
  transition: background .15s;
}
.user-card:hover { background: var(--bg4); }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main content */
.main {
  margin-left: 260px;
  flex: 1;
  padding: 28px;
  max-width: 1100px;
  width: 100%;
}
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; }
.page-header p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Mobile nav toggle */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  align-items: center;
  justify-content: space-between;
  z-index: 40;
}
.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all .3s;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 49;
}

/* ---- CARDS ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

/* ---- STATS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat-green .stat-value { color: var(--green); }
.stat-red .stat-value { color: var(--red); }
.stat-blue .stat-value { color: var(--blue); }
.stat-amber .stat-value { color: var(--amber); }
.stat-accent .stat-value { color: var(--accent2); }

/* ---- SMTP BOX ---- */
.smtp-credentials {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.smtp-row {
  display: flex;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.smtp-row:last-child { border-bottom: none; }
.smtp-key {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  min-width: 110px;
  flex-shrink: 0;
}
.smtp-val {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--amber);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.smtp-val.green { color: var(--green); }
.copy-btn {
  background: var(--bg4);
  border: 1px solid var(--border2);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent2); }
.copy-btn.copied { border-color: var(--green); color: var(--green); }

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .3px;
}
.form-label span.req { color: var(--red); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .15s;
  appearance: none;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.form-control::placeholder { color: var(--muted2); }
.form-control.mono { font-family: var(--mono); font-size: 13px; letter-spacing: .3px; }
.form-hint { font-size: 11px; color: var(--muted2); margin-top: 5px; line-height: 1.5; }
.form-hint.warn { color: var(--amber); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.input-group { position: relative; }
.input-group .form-control { padding-right: 44px; }
.input-group-addon {
  position: absolute; right: 1px; top: 1px; bottom: 1px;
  padding: 0 12px;
  background: var(--bg4);
  border-left: 1px solid var(--border2);
  border-radius: 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px) 0;
  display: flex; align-items: center;
  font-size: 12px; color: var(--muted);
  white-space: nowrap;
}
.input-prefix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg3);
}
.input-prefix-text {
  padding: 10px 12px;
  background: var(--bg4);
  border-right: 1px solid var(--border2);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.input-prefix input {
  border: none;
  background: transparent;
  flex: 1;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--mono);
}
.input-prefix input:focus { outline: none; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
  font-family: var(--font);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4f46e5; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--bg4); border-color: var(--border2); }
.btn-outline { background: transparent; color: var(--accent2); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent-bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-full { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-accent { background: var(--accent-bg); color: var(--accent2); }
.badge-gray { background: var(--bg4); color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.tbl td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--bg3); }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--green-bg); border: 1px solid rgba(16,185,129,.25); color: var(--green); }
.alert-danger { background: var(--red-bg); border: 1px solid rgba(239,68,68,.25); color: var(--red); }
.alert-warning { background: var(--amber-bg); border: 1px solid rgba(245,158,11,.25); color: var(--amber); }
.alert-info { background: var(--blue-bg); border: 1px solid rgba(59,130,246,.25); color: var(--blue); }

/* ---- AUTH PAGES ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo-icon {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 12px;
}
.auth-logo h1 { font-size: 20px; font-weight: 700; }
.auth-logo p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted2);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-link { text-align: center; margin-top: 20px; font-size: 13px; color: var(--muted); }
.auth-link a { color: var(--accent2); text-decoration: none; font-weight: 500; }
.auth-link a:hover { text-decoration: underline; }

/* Step indicator */
.steps {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
  gap: 0;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  background: var(--bg4);
  color: var(--muted);
  border: 1.5px solid var(--border2);
}
.step.active .step-num { background: var(--accent); color: #fff; border-color: var(--accent); }
.step.done .step-num { background: var(--green); color: #fff; border-color: var(--green); }
.step-label { font-size: 12px; color: var(--muted); }
.step.active .step-label { color: var(--text); font-weight: 500; }
.step-line { flex: 1; height: 1px; background: var(--border); margin: 0 4px; }

/* Password strength */
.pw-strength { margin-top: 6px; }
.pw-bar { height: 3px; border-radius: 2px; background: var(--bg4); overflow: hidden; }
.pw-fill { height: 100%; border-radius: 2px; transition: width .3s, background .3s; }
.pw-text { font-size: 11px; margin-top: 4px; }

/* Camera setup card */
.camera-setup {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.camera-setup-header {
  padding: 14px 18px;
  background: var(--accent-bg);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent2);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-icon {
  width: 56px; height: 56px;
  background: var(--bg3);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 16px;
}
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--muted); max-width: 300px; margin: 0 auto 20px; }

/* Misc */
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--muted); }
.text-mono { font-family: var(--mono); font-size: 12px; }
.text-sm { font-size: 12px; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.gap-8 { gap: 8px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .sidebar-overlay.active { display: block; }
  .mobile-header { display: flex; }
  .main { margin-left: 0; padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-card { padding: 28px 20px; }
  .tbl th:nth-child(n+4), .tbl td:nth-child(n+4) { display: none; }
}
