:root {
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #94a3b8;
  --sidebar-active: #10b981;
  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: #d1fae5;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
}

body.app-body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 268px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  color: #fff;
  text-decoration: none;
}

.sidebar-brand img,
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
}

.sidebar-brand span {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.sidebar-nav {
  padding: 16px 12px;
  overflow: auto;
  flex: 1;
}

.nav-section {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 10px 12px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 4px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(16, 185, 129, .12);
  color: #fff;
}

.sidebar-nav a.active {
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-footer button,
.sidebar-footer .logout-btn {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
}

.sidebar-footer button:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.main {
  flex: 1;
  min-width: 0;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-content {
  padding: 24px;
}

.page-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--muted);
  margin-bottom: 20px;
}

.card-soft {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 20px;
  height: 100%;
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: .9rem;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  margin-top: 6px;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-primary,
.btn-success {
  --bs-btn-bg: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-hover);
  --bs-btn-hover-border-color: var(--primary-hover);
}

.btn-brand {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-weight: 600;
}

.btn-brand:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-sent { background: #d1fae5; color: #065f46; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #e2e8f0; color: #475569; }
.badge-muted { background: #f1f5f9; color: #475569; }

.table-wrap {
  overflow-x: auto;
}

.table thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.password-toggle:hover,
.password-toggle:focus {
  color: var(--text);
  background: #f8fafc;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.file-preview img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.bulk-toolbar {
  border-bottom: 1px solid transparent;
}

.auth-page {
  min-height: 100vh;
  background: radial-gradient(circle at top, #d1fae5 0%, #f8fafc 42%, #e2e8f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .12);
  padding: 36px 32px;
}

.install-page {
  min-height: 100vh;
  background: #0f172a;
  color: #fff;
}

.install-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.install-card {
  background: #fff;
  color: var(--text);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.step-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.step-pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #cbd5e1;
}

.step-pill.active {
  background: var(--primary);
  color: #fff;
}

.req-ok { color: #059669; }
.req-fail { color: #dc2626; }

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-toggle {
  display: none;
  border: 0;
  background: #f1f5f9;
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    z-index: 25;
  }
}
