/* ============================================================
   SVOUNK ADMIN — Design System
   Tema: Dark puro com preto e branco
   Escala de espaçamento: 8px base
   Tipografia: Sora + JetBrains Mono
============================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Tokens ──────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:          #000000;
  --surface-1:   #0a0a0a;
  --surface-2:   #111111;
  --surface-3:   #1a1a1a;
  --surface-4:   #222222;

  /* Borders */
  --border:       rgba(255,255,255,0.08);
  --border-md:    rgba(255,255,255,0.14);
  --border-lg:    rgba(255,255,255,0.22);

  /* Text */
  --text-primary:   #ffffff;
  --text-secondary: #aaaaaa;
  --text-muted:     #555555;
  --text-disabled:  #333333;

  /* Accent — White */
  --accent:        #ffffff;
  --accent-dim:    rgba(255,255,255,0.08);
  --accent-glow:   rgba(255,255,255,0.15);

  /* Status (greyscale versions) */
  --success:      #c8ffee;
  --success-bg:   rgba(200,255,238,0.08);
  --warning:      #fff0c0;
  --warning-bg:   rgba(255,240,192,0.08);
  --danger:       #ffc0cc;
  --danger-bg:    rgba(255,192,204,0.08);
  --info:         #c0e0ff;
  --info-bg:      rgba(192,224,255,0.08);

  /* Typography */
  --font-sans: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:   0.6875rem;  /* 11px */
  --text-sm:   0.8125rem;  /* 13px */
  --text-base: 0.9375rem;  /* 15px */
  --text-lg:   1.0625rem;  /* 17px */
  --text-xl:   1.1875rem;  /* 19px */
  --text-2xl:  1.4375rem;  /* 23px */
  --text-3xl:  1.75rem;    /* 28px */
  --text-4xl:  2.25rem;    /* 36px */

  /* Spacing (8px) */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Radius */
  --r-sm:   5px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-xl:   18px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.8);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.8);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.9);
  --shadow-wb: 0 0 0 1px var(--border);

  /* Transitions */
  --ease:    cubic-bezier(0.16,1,0.3,1);
  --fast:    130ms;
  --base:    220ms;
  --slow:    380ms;

  /* Layout */
  --sidebar-w: 256px;
  --topbar-h:  60px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface-1); }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-md); }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: all var(--base) var(--ease);
  position: relative; overflow: hidden;
  outline-offset: 2px;
}
.btn:focus-visible { outline: 2px solid var(--accent); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--text-primary);
  color: var(--bg);
}
.btn-primary:hover { background: #e0e0e0; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(255,255,255,0.12); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface-3);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-md); background: var(--surface-4); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-2); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255,192,204,0.2);
}
.btn-danger:hover { background: rgba(255,192,204,0.15); }

.btn-sm  { padding: calc(var(--sp-2) - 2px) var(--sp-3); font-size: var(--text-xs); }
.btn-lg  { padding: var(--sp-3) var(--sp-6); font-size: var(--text-base); }
.btn-xl  { padding: var(--sp-4) var(--sp-8); font-size: var(--text-lg); }
.btn-full { width: 100%; }
.btn-icon { padding: var(--sp-2); aspect-ratio: 1; border-radius: var(--r-md); }
.btn-circle { padding: var(--sp-2); aspect-ratio: 1; border-radius: 50%; }

/* ═══════════════════════════════════════════════════════════
   FORM ELEMENTS
═══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: var(--sp-5); }

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: border-color var(--fast), box-shadow var(--fast);
  outline: none;
  -webkit-appearance: none;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus {
  border-color: var(--border-lg);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control.is-error { border-color: var(--danger); }
.form-control.is-error:focus { box-shadow: 0 0 0 3px rgba(255,192,204,0.1); }
.form-control.is-success { border-color: var(--success); }

.form-control-icon-wrap { position: relative; }
.form-control-icon-wrap .form-control { padding-left: calc(var(--sp-4) + 22px); }
.form-control-icon {
  position: absolute; left: var(--sp-3); top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); width: 16px; height: 16px; pointer-events: none;
}
.form-control-append {
  position: absolute; right: var(--sp-3); top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); cursor: pointer;
  transition: color var(--fast);
}
.form-control-append:hover { color: var(--text-primary); }

.form-error {
  font-size: var(--text-xs); color: var(--danger);
  margin-top: var(--sp-1); display: none;
}
.form-error.show { display: block; }

.form-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--sp-1); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
select.form-control option { background: var(--surface-3); }

textarea.form-control { resize: vertical; min-height: 90px; }

/* Checkbox / Radio */
.check-label {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--text-sm); color: var(--text-secondary);
  cursor: pointer;
}
.check-label input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ═══════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════ */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-hover { transition: border-color var(--base), box-shadow var(--base); }
.card-hover:hover { border-color: var(--border-md); box-shadow: var(--shadow-md); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-3);
}
.card-body   { padding: var(--sp-5) var(--sp-6); }
.card-footer {
  padding: var(--sp-3) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.card-title    { font-size: var(--text-base); font-weight: 600; }
.card-subtitle { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════
   BADGES / CHIPS / TAGS
═══════════════════════════════════════════════════════════ */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 600;
}
.chip::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.chip-success { color: var(--success); background: var(--success-bg); }
.chip-warning { color: var(--warning); background: var(--warning-bg); }
.chip-danger  { color: var(--danger);  background: var(--danger-bg); }
.chip-info    { color: var(--info);    background: var(--info-bg); }
.chip-muted   { color: var(--text-secondary); background: var(--surface-3); }
.chip-white   { color: var(--bg); background: var(--text-primary); }

.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 500;
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-full);
  font-size: 10px; font-weight: 700;
  background: var(--text-primary);
  color: var(--bg);
}

/* ═══════════════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table thead th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
}
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--text-secondary); }
.data-table thead th.sort-asc::after  { content: ' ↑'; }
.data-table thead th.sort-desc::after { content: ' ↓'; }

.data-table tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--fast); }
.data-table tbody tr:hover td { background: var(--surface-2); }

/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: var(--sp-4);
  backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border-md);
  border-radius: var(--r-xl);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp var(--base) var(--ease) both;
}
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1000px; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: var(--text-lg); font-weight: 700; }
.modal-body  { padding: var(--sp-6); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: var(--sp-6); right: var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-3);
  z-index: 2000; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm); max-width: 340px;
  pointer-events: all;
  animation: slideToast var(--base) var(--ease) both;
}
@keyframes slideToast {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }

/* ═══════════════════════════════════════════════════════════
   PROGRESS
═══════════════════════════════════════════════════════════ */
.progress {
  height: 4px; background: var(--surface-4);
  border-radius: var(--r-full); overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--text-primary);
  border-radius: var(--r-full);
  transition: width var(--slow) var(--ease);
}

/* ═══════════════════════════════════════════════════════════
   STAT CARDS
═══════════════════════════════════════════════════════════ */
.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6);
  position: relative; overflow: hidden;
  transition: border-color var(--base), transform var(--base);
}
.stat-card:hover { border-color: var(--border-md); transform: translateY(-2px); }
.stat-card::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 1px; background: linear-gradient(90deg, transparent, var(--border-md), transparent);
}

.stat-icon {
  width: 40px; height: 40px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: 800; letter-spacing: -1px;
  margin: var(--sp-3) 0 var(--sp-1);
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: var(--text-xs); color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.8px; }
.stat-change { font-size: var(--text-xs); font-weight: 700; padding: 2px 7px; border-radius: var(--r-full); }
.stat-change.up   { color: var(--success); background: var(--success-bg); }
.stat-change.down { color: var(--danger);  background: var(--danger-bg); }

/* ═══════════════════════════════════════════════════════════
   LAYOUT — Sidebar + Main
═══════════════════════════════════════════════════════════ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 200;
  transition: transform var(--slow) var(--ease);
}

.sidebar-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.logo-mark {
  width: 34px; height: 34px;
  background: var(--text-primary);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  color: var(--bg);
  flex-shrink: 0; overflow: hidden;
}
.logo-mark img { width: 100%; height: 100%; object-fit: cover; }

.logo-text { font-weight: 700; font-size: var(--text-base); letter-spacing: -0.3px; }
.logo-sub  { font-size: 10px; color: var(--text-muted); margin-top: 1px; text-transform: uppercase; letter-spacing: 1px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-3); }

.nav-section-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-2); margin-top: var(--sp-4);
}
.nav-section-label:first-child { margin-top: 0; }

.nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm); font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--fast);
  margin-bottom: 2px;
  text-decoration: none;
  position: relative;
}
.nav-link:hover  { background: var(--surface-2); color: var(--text-primary); }
.nav-link.active { background: var(--accent-dim); color: var(--text-primary); }
.nav-link.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; background: var(--text-primary);
  border-radius: 0 3px 3px 0;
}
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: var(--r-full);
  background: var(--surface-4); color: var(--text-secondary);
}

.sidebar-foot {
  padding: var(--sp-3) var(--sp-3);
  border-top: 1px solid var(--border);
}
.user-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md); cursor: pointer;
  transition: background var(--fast);
}
.user-row:hover { background: var(--surface-2); }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--surface-4);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--text-sm);
  flex-shrink: 0; overflow: hidden; border: 1px solid var(--border);
}
.user-name { font-size: var(--text-sm); font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* Main */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 var(--sp-6); gap: var(--sp-3);
  position: sticky; top: 0; z-index: 100;
}

.topbar-hamburger {
  display: none; padding: var(--sp-2);
  color: var(--text-secondary); border-radius: var(--r-sm);
  transition: all var(--fast);
}
.topbar-hamburger:hover { color: var(--text-primary); background: var(--surface-2); }

.topbar-search {
  flex: 1; max-width: 360px; position: relative;
}
.topbar-search input {
  width: 100%;
  padding: var(--sp-2) var(--sp-4) var(--sp-2) calc(var(--sp-4) + 20px);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-primary); font-size: var(--text-sm); outline: none;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.topbar-search input:focus { border-color: var(--border-lg); box-shadow: 0 0 0 3px var(--accent-dim); }
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search-ic {
  position: absolute; left: var(--sp-3); top: 50%; transform: translateY(-50%);
  color: var(--text-muted); width: 14px; height: 14px; pointer-events: none;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

.topbar-ic-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  transition: all var(--fast); position: relative;
}
.topbar-ic-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.notif-dot {
  position: absolute; top: 5px; right: 5px;
  width: 6px; height: 6px;
  background: var(--text-primary); border-radius: 50%;
  border: 1.5px solid var(--surface-1);
}

.page-wrap { flex: 1; padding: var(--sp-8); max-width: 1380px; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: var(--sp-8); gap: var(--sp-4); flex-wrap: wrap;
}
.page-title    { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -0.5px; }
.page-subtitle { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--sp-1); }
.page-actions  { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }

/* ═══════════════════════════════════════════════════════════
   GRID HELPERS
═══════════════════════════════════════════════════════════ */
.grid-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-5); margin-bottom: var(--sp-6); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--sp-5); }
.grid-span-2 { grid-column: span 2; }

/* ═══════════════════════════════════════════════════════════
   CHART (canvas-based, JS fills)
═══════════════════════════════════════════════════════════ */
.chart-wrap { position: relative; }
.chart-empty {
  display: flex; align-items: center; justify-content: center;
  height: 200px; color: var(--text-muted); font-size: var(--text-sm);
}

/* ═══════════════════════════════════════════════════════════
   SPREADSHEET ENGINE
═══════════════════════════════════════════════════════════ */
.sheet-toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.sheet-sep { width: 1px; height: 20px; background: var(--border); margin: 0 var(--sp-2); }
.tb-btn {
  padding: 3px 8px; border-radius: var(--r-sm);
  font-size: var(--text-xs); font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--fast); min-width: 28px; text-align: center;
}
.tb-btn:hover  { color: var(--text-primary); background: var(--surface-3); }
.tb-btn.active { color: var(--text-primary); background: var(--surface-4); }

.formula-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.cell-ref-box {
  font-family: var(--font-mono); font-size: var(--text-xs);
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 2px 8px;
  min-width: 50px; text-align: center; color: var(--text-secondary);
}
.formula-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text-primary);
}
.formula-input::placeholder { color: var(--text-muted); }

.sheet-grid { overflow: auto; max-height: 520px; }
.sheet-table { border-collapse: collapse; font-family: var(--font-mono); font-size: var(--text-xs); min-width: 100%; }
.sheet-table th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2);
  padding: 3px 8px; text-align: center;
  font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  min-width: 96px; user-select: none; white-space: nowrap;
}
.sheet-table th.row-header { position: sticky; left: 0; z-index: 4; width: 42px; min-width: 42px; }
.sheet-table td {
  border: 1px solid var(--border);
  padding: 0; position: relative;
}
.sheet-table td.row-num {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface-2); text-align: center;
  padding: 2px 6px; color: var(--text-muted); font-size: 10px;
  user-select: none; border-right: 1px solid var(--border-md);
}
.sheet-cell {
  display: block; width: 100%; height: 26px;
  padding: 0 6px; background: transparent; border: none; outline: none;
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text-primary); white-space: nowrap;
}
.sheet-cell:focus { background: var(--surface-3); box-shadow: inset 0 0 0 2px var(--border-lg); z-index: 1; position: relative; }
td.cell-selected { background: rgba(255,255,255,0.05) !important; }
td.cell-selected .sheet-cell { box-shadow: inset 0 0 0 2px var(--border-lg); }

/* ═══════════════════════════════════════════════════════════
   KANBAN
═══════════════════════════════════════════════════════════ */
.kanban-board { display: flex; gap: var(--sp-4); overflow-x: auto; padding-bottom: var(--sp-2); }
.kanban-col {
  min-width: 272px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.kanban-col-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.col-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.col-title { font-size: var(--text-sm); font-weight: 600; flex: 1; }
.col-count {
  font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: var(--r-full);
  background: var(--surface-4); color: var(--text-muted);
}
.kanban-cards { padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); min-height: 60px; }

.k-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-4);
  cursor: grab; transition: all var(--fast);
}
.k-card:hover { border-color: var(--border-md); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.k-card-title { font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--sp-2); line-height: 1.4; }
.k-card-desc  { font-size: var(--text-xs); color: var(--text-secondary); margin-bottom: var(--sp-3); line-height: 1.5; }
.k-card-foot  { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }

/* ═══════════════════════════════════════════════════════════
   CALENDAR
═══════════════════════════════════════════════════════════ */
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.cal-head { text-align: center; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); padding: var(--sp-2); }
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm); border-radius: var(--r-md);
  cursor: pointer; transition: background var(--fast);
  color: var(--text-secondary); position: relative;
}
.cal-day:hover { background: var(--surface-2); color: var(--text-primary); }
.cal-day.today { background: var(--text-primary) !important; color: var(--bg) !important; font-weight: 700; }
.cal-day.other { opacity: 0.25; }
.cal-day.has-event::after {
  content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--text-secondary);
}
.cal-day.today.has-event::after { background: var(--bg); }

/* ═══════════════════════════════════════════════════════════
   UPLOAD ZONE
═══════════════════════════════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg); padding: var(--sp-10);
  text-align: center; cursor: pointer;
  transition: all var(--base); color: var(--text-muted);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--border-lg); background: var(--accent-dim); color: var(--text-secondary);
}
.upload-zone-icon { margin: 0 auto var(--sp-4); width: 40px; height: 40px; }
.upload-zone-text { font-size: var(--text-sm); }
.upload-zone-hint { font-size: var(--text-xs); margin-top: var(--sp-1); }

/* ═══════════════════════════════════════════════════════════
   TABS
═══════════════════════════════════════════════════════════ */
.tabs-nav {
  display: flex; gap: 2px;
  background: var(--surface-2); padding: 3px;
  border-radius: var(--r-lg); border: 1px solid var(--border);
  width: fit-content; margin-bottom: var(--sp-6);
}
.tab-btn {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm); font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--fast); cursor: pointer;
}
.tab-btn:hover  { color: var(--text-primary); }
.tab-btn.active { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6); position: relative; overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 70% at 20% 30%, rgba(255,255,255,0.03) 0%, transparent 60%),
              var(--bg);
}
.login-bg::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px),
                    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 20%, transparent 75%);
  opacity: 0.6;
}
.login-card {
  position: relative; width: 100%; max-width: 420px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: var(--sp-10) var(--sp-8);
  box-shadow: var(--shadow-lg);
  animation: fadeUp var(--slow) var(--ease) both;
}

/* ═══════════════════════════════════════════════════════════
   AVATAR GROUP
═══════════════════════════════════════════════════════════ */
.avatar-group { display: flex; }
.av-sm {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  border: 2px solid var(--surface-1);
  background: var(--surface-4); color: var(--text-secondary);
  margin-left: -7px; flex-shrink: 0;
}
.av-sm:first-child { margin-left: 0; }

/* ═══════════════════════════════════════════════════════════
   DIVIDER
═══════════════════════════════════════════════════════════ */
.divider {
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--text-muted); font-size: var(--text-xs);
  margin: var(--sp-5) 0;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .grid-stats { grid-template-columns: repeat(2,1fr); }
  .grid-2     { grid-template-columns: 1fr; }
  .grid-3     { grid-template-columns: 1fr 1fr; }
  .grid-span-2 { grid-column: span 1; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 199; display: none; backdrop-filter: blur(2px); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .topbar-hamburger { display: flex; }
  .topbar-search { display: none; }
  .page-wrap { padding: var(--sp-5) var(--sp-4); }
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .grid-stats { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .topbar { padding: 0 var(--sp-4); }
  .login-card { padding: var(--sp-8) var(--sp-5); }
}
