/* ── Design tokens (from wireframe) ─────────────────────────────────────────── */
:root {
  --bg:           #F4F5F7;
  --white:        #FFFFFF;
  --surface:      #FFFFFF;
  --surface-hover:#F9FAFB;
  --border:       #E2E5EB;
  --border-light: #EEF0F4;
  --border-focus: #3B6CFF;
  --text:         #1A1D26;
  --text-secondary:#4B5166;
  --text-muted:   #7C8298;
  --text-dim:     #A0A6B8;
  --accent:       #3B6CFF;
  --accent-hover: #2B57E0;
  --accent-light: #EBF0FF;
  --accent-text:  #2B4ACF;
  --green:        #16A34A;
  --green-light:  #ECFDF3;
  --green-border: #BBF7D0;
  --yellow:       #CA8A04;
  --yellow-light: #FEFCE8;
  --yellow-border:#FEF08A;
  --red:          #DC2626;
  --red-light:    #FEF2F2;
  --red-border:   #FECACA;
  --gray-light:   #F4F5F7;
  --gray-border:  #D1D5DB;
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.05);
  --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
  --radius:       8px;
  --radius-lg:    12px;
  --font:         'Outfit', sans-serif;
  --mono:         'JetBrains Mono', monospace;
  --sidebar-w:    236px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100; padding: 20px 0;
  overflow-y: auto;
  /* Transition always present so it fires when .open is toggled */
  transition: transform 0.25s ease;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px; margin-bottom: 28px;
  color: var(--accent);
}
.sidebar-logo span {
  font: 700 17px var(--font); color: var(--text); letter-spacing: -0.4px;
}

.sidebar-section {
  font: 600 10.5px var(--font); color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 0 20px; margin: 20px 0 6px;
}

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; font: 500 13.5px var(--font);
  color: var(--text-secondary);
  transition: background 0.1s, color 0.1s;
  border: none; background: none;
  width: 100%; text-align: left;
  text-decoration: none;
}
.sidebar-link:hover { color: var(--text); background: var(--surface-hover); }
.sidebar-link.active { color: var(--accent-text); background: var(--accent-light); font-weight: 600; }
.sidebar-link svg { width: 17px; height: 17px; flex-shrink: 0; color: inherit; opacity: 0.7; }
.sidebar-link.active svg { opacity: 1; }

.sidebar-badge {
  margin-left: auto; font: 600 11px var(--font);
  min-width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; padding: 0 6px;
}

.sidebar-bottom {
  margin-top: auto; padding: 16px 20px;
  border-top: 1px solid var(--border-light);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; }

.avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-light); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font: 600 12px var(--font); color: var(--accent-text);
}
.avatar-lg {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-light); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font: 700 18px var(--font); color: var(--accent-text);
}

/* ── Main content ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 32px 36px;
  max-width: calc(var(--sidebar-w) + 960px);
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 28px; flex-wrap: wrap;
}
.page-title { font: 700 24px var(--font); color: var(--text); letter-spacing: -0.5px; }
.page-subtitle { font: 400 14px var(--font); color: var(--text-muted); margin-top: 3px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.back-link {
  display: inline-flex; align-items: center; gap: 5px;
  font: 500 13px var(--font); color: var(--text-muted);
  transition: color 0.1s;
}
.back-link:hover { color: var(--text); }

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.stat-card-success { border-color: var(--green-border);  background: var(--green-light); }
.stat-card-warning { border-color: var(--yellow-border); background: var(--yellow-light); }
.stat-card-danger  { border-color: var(--red-border);    background: var(--red-light); }
.stat-value { font: 700 32px var(--font); color: var(--text); letter-spacing: -1px; }
.stat-label { font: 500 13px var(--font); color: var(--text-muted); margin-top: 4px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 24px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
}
.card-title { font: 600 15px var(--font); color: var(--text); }
.card-body { padding: 20px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 16px; text-align: left;
  font: 600 11.5px var(--font); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
}
.table td {
  padding: 13px 16px;
  font: 400 14px var(--font); color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-hover); }

.td-name { font-weight: 500; color: var(--text); }
.td-muted { color: var(--text-muted); }
.td-role  { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.td-actions { white-space: nowrap; text-align: right; }

.worker-link { color: var(--accent-text); font-weight: 600; }
.worker-link:hover { text-decoration: underline; }

.link-action {
  font: 500 13px var(--font); color: var(--accent-text);
  background: none; border: none; padding: 0; margin-left: 14px;
  cursor: pointer;
}
.link-action:hover { text-decoration: underline; }
.link-danger { color: var(--red) !important; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font: 600 12px var(--font); border-radius: 6px;
  padding: 3px 9px; white-space: nowrap;
}
.badge-green  { background: var(--green-light);  color: var(--green);  border: 1px solid var(--green-border); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); border: 1px solid var(--yellow-border); }
.badge-red    { background: var(--red-light);    color: var(--red);    border: 1px solid var(--red-border); }
.badge-gray   { background: var(--gray-light);   color: var(--text-muted); border: 1px solid var(--gray-border); }
.badge-purple { background: #f3e8ff; color: #6d28d9; border: 1px solid #ddd6fe; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: 600 13.5px var(--font); border-radius: var(--radius);
  padding: 9px 18px; border: 1px solid transparent;
  cursor: pointer; transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

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

.btn-secondary {
  background: var(--white); color: var(--text); border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-ghost {
  background: transparent; color: var(--text-muted); border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn-ghost.btn-danger:hover { color: var(--red); }

.btn-block { width: 100%; justify-content: center; }
.btn-sm    { padding: 6px 14px; font-size: 13px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-stack { display: flex; flex-direction: column; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-label {
  font: 500 13.5px var(--font); color: var(--text-secondary);
}
.required { color: var(--red); }

.form-input {
  padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font: 400 14px var(--font);
  color: var(--text); background: var(--white);
  transition: border-color 0.12s, box-shadow 0.12s;
  outline: none; width: 100%;
}
.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,108,255,0.12);
}
.form-input:disabled { background: var(--surface-hover); color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237C8298' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 36px; }

.form-hint { font: 400 12.5px var(--font); color: var(--text-muted); }

.form-actions { display: flex; align-items: center; gap: 10px; padding-top: 4px; }

.checkbox-label {
  display: flex; align-items: center; gap: 10px;
  font: 500 14px var(--font); color: var(--text); cursor: pointer;
}
.checkbox-label input[type=checkbox] {
  width: 16px; height: 16px; accent-color: var(--accent);
}

.mono { font-family: var(--mono); font-size: 13px; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font: 500 14px var(--font); margin-bottom: 20px;
  border: 1px solid transparent;
}
.alert-success { background: var(--green-light); color: var(--green); border-color: var(--green-border); }
.alert-error   { background: var(--red-light);   color: var(--red);   border-color: var(--red-border); }
.alert-warning { background: var(--yellow-light); color: var(--yellow); border-color: var(--yellow-border); }

/* ── Empty states ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 64px 24px; text-align: center;
}
.empty-title { font: 600 16px var(--font); color: var(--text); margin-bottom: 8px; }
.empty-desc  { font: 400 14px var(--font); color: var(--text-muted); max-width: 340px; }

/* ── Text utilities ──────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }

/* ── Plan/upgrade grid ───────────────────────────────────────────────────── */
.plan-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; max-width: 640px; margin-bottom: 24px;
}
.plan-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px 24px;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  position: relative;
}
.plan-card-featured { border-color: var(--accent); border-width: 2px; }
.plan-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  font: 600 11px var(--font); padding: 3px 12px; border-radius: 20px;
}
.plan-name   { font: 700 18px var(--font); color: var(--text); margin-bottom: 8px; }
.plan-price  { font: 800 36px var(--font); color: var(--text); letter-spacing: -1px; }
.plan-period { font: 400 15px var(--font); color: var(--text-muted); }
.plan-features { list-style: none; margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.plan-feature {
  display: flex; align-items: center; gap: 9px;
  font: 400 14px var(--font); color: var(--text-secondary);
}
.plan-feature::before { content: ''; display: inline-block; width: 16px; height: 16px; flex-shrink: 0; background-size: contain; background-repeat: no-repeat; }
.plan-feature-yes { color: var(--text); }
.plan-feature-yes::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2316A34A' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E"); }
.plan-feature-no  { color: var(--text-muted); }
.plan-feature-no::before  { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A0A6B8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E"); }

/* ── Export list ─────────────────────────────────────────────────────────── */
.export-list { list-style: none; display: flex; flex-direction: column; gap: 0; }
.export-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0; border-bottom: 1px solid var(--border-light); gap: 12px;
}
.export-item:last-child { border-bottom: none; }
.export-item-info { display: flex; align-items: center; gap: 14px; }

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; background: var(--bg);
}
.auth-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 40px; width: 100%; max-width: 420px;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 32px;
}
.auth-logo-text { font: 700 20px var(--font); color: var(--text); letter-spacing: -0.4px; }
.auth-title { font: 700 22px var(--font); color: var(--text); margin-bottom: 8px; }
.auth-subtitle { font: 400 14px var(--font); color: var(--text-muted); margin-bottom: 28px; line-height: 1.6; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-footer { font: 400 12.5px var(--font); color: var(--text-dim); margin-top: 20px; }

/* ── Mobile hamburger button ─────────────────────────────────────────────── */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 200;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px;
  box-shadow: var(--shadow); align-items: center; justify-content: center;
  color: var(--text);
}

/* Sidebar slide-in backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 500;
}

/* Close button inside sidebar — mobile only */
.sidebar-close-btn {
  display: none;
  position: absolute; top: 14px; right: 14px;
  background: none; border: none;
  cursor: pointer; padding: 6px;
  color: var(--text-muted);
  border-radius: var(--radius);
  line-height: 0;
}
.sidebar-close-btn:hover { background: var(--surface-hover); color: var(--text); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-menu-btn  { display: flex; }
  .sidebar          { transform: translateX(-100%); z-index: 600; }
  .sidebar-close-btn { display: block; }
  .main-content     { margin-left: 0; padding: 60px 16px 20px; }
  .stat-grid       { grid-template-columns: 1fr 1fr; }
  .plan-grid       { grid-template-columns: 1fr; }
  .form-row-2      { grid-template-columns: 1fr; }
  .page-header     { flex-direction: column; }
  .table th:nth-child(3),
  .table td:nth-child(3) { display: none; }
}
