/* ==========================================================================
   Bebakids Transfer Portal — Base + App Shell
   ========================================================================== */

@import url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,700,900&f[]=jetbrains-mono@400,500,700&display=swap');

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

html, body, #root { height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.003em;
}

a { color: inherit; text-decoration: none; }

/* Numbers always tabular */
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ==========================================================================
   APP LAYOUT
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: 60px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 220ms var(--ease-out);
}
.app.sidebar-expanded { grid-template-columns: 220px 1fr; }

/* ---- SIDEBAR ---- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 20;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  height: 56px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}
.sidebar-brand-mark {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 7px;
  background: linear-gradient(135deg, #0a0a0f 0%, var(--accent) 120%);
  display: grid; place-items: center;
  color: white; font-weight: 900; font-size: 13px;
  letter-spacing: -0.02em;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset;
}
[data-theme='dark'] .sidebar-brand-mark {
  background: linear-gradient(135deg, var(--accent) 0%, #8fa7ff 120%);
}
.sidebar-brand-text { display: flex; flex-direction: column; opacity: 0; transition: opacity 180ms var(--ease-out); white-space: nowrap; }
.app.sidebar-expanded .sidebar-brand-text { opacity: 1; }
.sidebar-brand-text .name { font-weight: 700; font-size: 13px; letter-spacing: -0.01em; }
.sidebar-brand-text .sub { font-size: 10.5px; color: var(--text-subtle); letter-spacing: 0.02em; text-transform: uppercase; }

.sidebar-nav {
  flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto; overflow-x: hidden;
}
.sidebar-section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-subtle); padding: 14px 12px 6px;
  opacity: 0; transition: opacity 160ms var(--ease-out); white-space: nowrap;
}
.app.sidebar-expanded .sidebar-section-label { opacity: 1; }

.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms var(--ease-out), color 120ms var(--ease-out);
  font-size: 13px; font-weight: 500;
  position: relative;
  white-space: nowrap;
}
.side-link:hover { background: var(--surface-hover); color: var(--text); }
.side-link.active {
  background: var(--accent-soft); color: var(--accent);
}
.side-link.active::before {
  content: ''; position: absolute; left: -8px; top: 8px; bottom: 8px;
  width: 2px; background: var(--accent); border-radius: 2px;
}
.side-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.side-link span.label { opacity: 0; transition: opacity 160ms var(--ease-out); }
.app.sidebar-expanded .side-link span.label { opacity: 1; }
.side-link .kbd {
  margin-left: auto; font-family: var(--font-mono); font-size: 10px;
  padding: 1px 5px; border-radius: 3px; background: var(--kbd-bg);
  color: var(--text-subtle); opacity: 0;
  transition: opacity 160ms var(--ease-out);
}
.app.sidebar-expanded .side-link .kbd { opacity: 1; }

.sidebar-footer {
  padding: 10px 8px; border-top: 1px solid var(--divider);
  display: flex; flex-direction: column; gap: 2px;
}

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 120ms var(--ease-out);
}
.user-chip:hover { background: var(--surface-hover); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #8e5bff, var(--accent));
  color: white; display: grid; place-items: center;
  font-weight: 700; font-size: 11px; flex-shrink: 0;
}
.user-chip-info { display: flex; flex-direction: column; min-width: 0; opacity: 0; transition: opacity 160ms var(--ease-out); }
.app.sidebar-expanded .user-chip-info { opacity: 1; }
.user-chip-info .name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-info .role { font-size: 10.5px; color: var(--text-subtle); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- MAIN ---- */
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 28px; height: 56px;
  background: rgba(255,255,255,0.78);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
[data-theme='dark'] .topbar { background: rgba(10,10,12,0.7); }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); min-width: 0; }
.breadcrumb .crumb { padding: 3px 6px; border-radius: 4px; cursor: pointer; }
.breadcrumb .crumb:hover { background: var(--surface-hover); color: var(--text); }
.breadcrumb .crumb.current { color: var(--text); font-weight: 600; }
.breadcrumb .sep { color: var(--text-subtle); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent;
  display: grid; place-items: center; cursor: pointer;
  color: var(--text-muted);
  transition: background 120ms var(--ease-out), color 120ms, border-color 120ms;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.icon-btn svg { width: 16px; height: 16px; }

.search-trigger {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px 0 10px;
  min-width: 240px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-subtle); font-size: 12.5px;
  cursor: pointer;
  transition: background 120ms var(--ease-out), border-color 120ms;
}
.search-trigger:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.search-trigger svg { width: 14px; height: 14px; }
.search-trigger .kbd {
  margin-left: auto; font-family: var(--font-mono); font-size: 10.5px;
  padding: 1px 6px; border-radius: 4px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ---- CONTENT ---- */
.content { padding: 28px; max-width: 1400px; width: 100%; margin: 0 auto; min-width: 0; }
.content.wide { max-width: 1600px; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title-group h1 {
  font-size: 24px; font-weight: 700; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 12px;
}
.page-title-group .page-sub {
  margin-top: 4px; font-size: 13px; color: var(--text-muted);
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 120ms var(--ease-out), border-color 120ms, box-shadow 120ms, transform 80ms;
  white-space: nowrap;
  font-family: var(--font-sans);
  letter-spacing: -0.005em;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--text); color: var(--text-inverse);
  border-color: var(--text);
}
.btn-primary:hover { background: #1f1f2b; border-color: #1f1f2b; }
[data-theme='dark'] .btn-primary:hover { background: #e0e0e8; border-color: #e0e0e8; }

.btn-accent {
  background: var(--accent); color: white;
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

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

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { filter: brightness(1.08); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 11.5px; border-radius: 4px; }

/* ==========================================================================
   CARD / PANEL
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--divider);
}
.card-header h2, .card-header h3 {
  font-size: 14px; font-weight: 700; letter-spacing: -0.01em;
}
.card-header .card-sub { font-size: 12px; color: var(--text-muted); }
.card-header .card-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 18px; }
.card-body.pad-sm { padding: 12px; }
.card-body.no-pad { padding: 0; }

/* ==========================================================================
   BADGES / CHIPS
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; height: 20px;
  border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1;
}
.badge.dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-neutral { background: var(--chip-bg); color: var(--text-muted); }

/* Filter chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 500;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 100ms var(--ease-out), color 100ms, border-color 100ms;
}
.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip.active {
  background: var(--text); color: var(--text-inverse); border-color: var(--text);
}

/* ==========================================================================
   INPUTS
   ========================================================================== */
.input, .select, .textarea {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color 120ms var(--ease-out), box-shadow 120ms;
  outline: none;
}
.input:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; }
.input-sm { height: 28px; font-size: 12px; padding: 0 10px; }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label {
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.form-field .hint { font-size: 11px; color: var(--text-subtle); }

.search-input {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 34px;
  border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--border);
}
.search-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.search-input svg { width: 14px; height: 14px; color: var(--text-subtle); flex-shrink: 0; }
.search-input input {
  border: none; background: transparent; outline: none;
  font-size: 13px; color: var(--text); font-family: var(--font-sans);
  flex: 1; min-width: 0;
}

/* ==========================================================================
   TABLE
   ========================================================================== */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.data-table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}
.data-table thead th.num { text-align: right; }
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--text); }
.data-table thead th .sort-icon { margin-left: 4px; opacity: 0.35; }
.data-table thead th.sorted .sort-icon { opacity: 1; color: var(--accent); }

.data-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}
.data-table tbody td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.data-table tbody tr { transition: background 80ms var(--ease-out); }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr.selected { background: var(--accent-soft); }
.data-table tbody tr.selected:hover { background: var(--accent-soft); filter: brightness(0.98); }

.data-table tbody tr.totals td { border-top: 2px solid var(--border-strong); font-weight: 700; background: var(--surface-2); }

.data-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.data-table th input[type='checkbox'],
.data-table td input[type='checkbox'] { accent-color: var(--accent); }

/* Bulk action bar */
.bulk-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  background: var(--text); color: var(--text-inverse);
  border-radius: var(--r-md);
  font-size: 12.5px;
  animation: slideDown 160ms var(--ease-out);
}
.bulk-bar .bulk-count { font-weight: 700; font-family: var(--font-mono); }
.bulk-bar .sep { opacity: 0.35; }
.bulk-bar button {
  background: transparent; border: 1px solid rgba(255,255,255,0.18);
  color: inherit; font-weight: 600;
  padding: 4px 10px; border-radius: 4px; height: 26px;
  font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit;
}
.bulk-bar button:hover { background: rgba(255,255,255,0.12); }
.bulk-bar button svg { width: 13px; height: 13px; }
.bulk-bar .bulk-close { margin-left: auto; opacity: 0.7; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   STAT CARDS (with sparklines)
   ========================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0;
  transition: border-color 120ms var(--ease-out);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-card .stat-head { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 11.5px; font-weight: 500; }
.stat-card .stat-head svg { width: 13px; height: 13px; }
.stat-card .stat-value {
  font-size: 26px; font-weight: 700;
  font-family: var(--font-mono); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-card .stat-trend { font-size: 11px; display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.stat-card .stat-trend.up { color: var(--success); }
.stat-card .stat-trend.down { color: var(--danger); }
.stat-card .stat-trend.flat { color: var(--text-muted); }
.stat-card .spark { height: 32px; margin-top: 2px; }
.stat-card.accent { border-color: var(--accent-soft); background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 60%); }
.stat-card.success-tint { background: linear-gradient(180deg, var(--success-soft) 0%, var(--surface) 70%); }
.stat-card.danger-tint { background: linear-gradient(180deg, var(--danger-soft) 0%, var(--surface) 70%); }
.stat-card.warning-tint { background: linear-gradient(180deg, var(--warning-soft) 0%, var(--surface) 70%); }

/* ==========================================================================
   SECTION HEADS
   ========================================================================== */
.section-head {
  display: flex; align-items: center; gap: 10px;
  margin: 28px 0 12px;
}
.section-head h2 {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
}
.section-head .section-rule { flex: 1; height: 1px; background: var(--border); }
.section-head .section-side { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--text-muted); }

/* ==========================================================================
   TABS
   ========================================================================== */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 0;
}
.tab {
  padding: 10px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer; background: transparent; border-top: none; border-left: none; border-right: none;
  font-family: inherit;
  transition: color 100ms var(--ease-out);
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab svg { width: 14px; height: 14px; }

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,10,15,0.38);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 50;
  animation: fadeIn 140ms var(--ease-out);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  width: 92%; max-width: 560px;
  max-height: 86vh; overflow: auto;
  animation: popIn 180ms var(--ease-out);
}
.modal-header { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--divider); }
.modal-header h3 { font-size: 14px; font-weight: 700; }
.modal-header .icon-btn { margin-left: auto; }
.modal-body { padding: 18px; font-size: 13.5px; line-height: 1.6; color: var(--text); }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--divider); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ==========================================================================
   TOASTS
   ========================================================================== */
.toast-container {
  position: fixed; bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 60; max-width: 380px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 10px;
  animation: slideIn 200ms var(--ease-out);
  font-size: 13px;
}
.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast .toast-title { font-weight: 600; margin-bottom: 2px; }
.toast .toast-body { color: var(--text-muted); font-size: 12px; }
@keyframes slideIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }

/* ==========================================================================
   COMMAND PALETTE
   ========================================================================== */
.cmdk {
  width: 92%; max-width: 600px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popIn 180ms var(--ease-out);
}
.cmdk-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--divider);
}
.cmdk-input-row svg { width: 16px; height: 16px; color: var(--text-muted); }
.cmdk-input-row input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text); font-family: var(--font-sans);
}
.cmdk-list { max-height: 380px; overflow: auto; padding: 6px; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer;
  font-size: 13px;
}
.cmdk-item svg { width: 14px; height: 14px; color: var(--text-muted); }
.cmdk-item.active { background: var(--surface-hover); }
.cmdk-item .cmdk-kbd {
  margin-left: auto; font-family: var(--font-mono); font-size: 10.5px;
  color: var(--text-subtle);
}
.cmdk-group { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-subtle); padding: 10px 12px 4px; }

/* ==========================================================================
   UTILITY
   ========================================================================== */
.hstack { display: flex; align-items: center; gap: 8px; }
.vstack { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.link { color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }
.divider { height: 1px; background: var(--border); }

.positive { color: var(--success); }
.negative { color: var(--danger); }
.zero { color: var(--text-subtle); }

kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  padding: 1px 6px; border-radius: 4px;
  background: var(--kbd-bg); border: 1px solid var(--border);
  color: var(--text-muted);
}

details.collapsy > summary {
  cursor: pointer;
  padding: 6px 10px;
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  list-style: none;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--r-sm);
}
details.collapsy > summary:hover { background: var(--accent-soft); }
details.collapsy > summary::-webkit-details-marker { display: none; }
details.collapsy > summary::before {
  content: '▸'; font-size: 9px; transition: transform 140ms var(--ease-out);
}
details.collapsy[open] > summary::before { transform: rotate(90deg); }

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.login-hero {
  background: linear-gradient(160deg, #0a0a0f 0%, #1a1f3d 45%, var(--accent) 140%);
  color: white;
  padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-hero::before {
  content: ''; position: absolute; inset: -40% -20% auto auto;
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(91,123,255,0.35), transparent 60%);
}
.login-hero-mark {
  display: flex; align-items: center; gap: 10px;
}
.login-hero-mark .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  font-weight: 900; font-size: 15px;
  border: 1px solid rgba(255,255,255,0.25);
}
.login-hero h1 {
  font-size: 44px; line-height: 1.08; font-weight: 700;
  letter-spacing: -0.03em; max-width: 440px;
  position: relative;
}
.login-hero .hero-caption {
  font-size: 14px; color: rgba(255,255,255,0.75); max-width: 400px;
  margin-top: 16px; line-height: 1.6; position: relative;
}
.login-hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
  position: relative;
  border-top: 1px solid rgba(255,255,255,0.14);
  padding-top: 24px;
}
.login-hero-stats .st-val {
  font-size: 24px; font-weight: 700; font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.login-hero-stats .st-lab {
  font-size: 11px; color: rgba(255,255,255,0.6);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-top: 2px;
}

.login-right { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-form { width: 100%; max-width: 360px; }
.login-form h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.login-form p.lead { font-size: 13.5px; color: var(--text-muted); margin-bottom: 24px; }
.login-form .form-field { margin-bottom: 14px; }
.login-form .btn-accent { width: 100%; height: 40px; font-size: 14px; margin-top: 8px; }
.login-form .foot {
  margin-top: 28px; padding-top: 18px;
  border-top: 1px solid var(--divider);
  font-size: 12px; color: var(--text-subtle);
  display: flex; justify-content: space-between; align-items: center;
}

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

/* ==========================================================================
   VIZ — bars, heatmaps
   ========================================================================== */
.store-balance-row {
  display: grid;
  grid-template-columns: 70px 1fr 80px;
  align-items: center;
  gap: 14px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--divider);
  font-size: 13px;
}
.store-balance-row:last-child { border-bottom: none; }
.store-balance-row .store-tag { font-weight: 600; font-family: var(--font-mono); }
.store-balance-bar-wrap {
  position: relative; height: 22px; display: flex; align-items: center;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
}
.store-balance-bar {
  height: 100%;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 8px;
  color: white; font-size: 11px; font-weight: 600;
  transition: width 400ms var(--ease-out);
}
.store-balance-bar.positive { background: linear-gradient(90deg, #34d399, var(--success)); }
.store-balance-bar.negative { background: linear-gradient(90deg, var(--danger), #fca5a5); justify-content: flex-start; }
.store-balance-row .bal-val { font-family: var(--font-mono); font-weight: 700; text-align: right; }

/* Heatmap */
.heatmap-row { display: flex; align-items: center; gap: 2px; }
.heatmap-cell {
  width: 32px; height: 28px;
  border-radius: 4px;
  display: grid; place-items: center;
  font-size: 11px; font-family: var(--font-mono); font-weight: 600;
  color: var(--text);
  cursor: default;
  transition: transform 80ms var(--ease-out);
}
.heatmap-cell:hover { transform: scale(1.1); z-index: 2; }

/* Product image hover */
.sku-hover { position: relative; display: inline-block; }
.sku-hover .sku-img {
  display: none; position: absolute; z-index: 100;
  left: 0; top: 100%; margin-top: 6px;
  width: 160px; height: 160px; object-fit: contain;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 6px;
}
.sku-hover:hover .sku-img { display: block; }

/* Severity cell backgrounds for PRE/POSLE stock grid */
.sev-0 { background: rgba(239,68,68,0.18); color: var(--danger); font-weight: 700; }
.sev-1 { background: rgba(245,158,11,0.18); color: var(--warning); font-weight: 700; }
.sev-2 { background: rgba(245,158,11,0.10); color: var(--warning); }
.sev-3 { background: rgba(18,185,129,0.12); color: var(--success); }
.sev-hi { background: rgba(18,185,129,0.22); color: var(--success); font-weight: 700; }
.chg-up { box-shadow: inset 0 0 0 1.5px var(--success); color: var(--success); font-weight: 700; }
.chg-down { box-shadow: inset 0 0 0 1.5px rgba(91,123,255,0.4); color: var(--accent); }
.chg-filled { background: rgba(18,185,129,0.35); color: #0a3d2e; font-weight: 800; box-shadow: inset 0 0 0 1.5px var(--success); }
[data-theme='dark'] .chg-filled { color: #8bfcd0; }

/* ==========================================================================
   PROGRESS RING (donut)
   ========================================================================== */
.ring-wrap { position: relative; width: 64px; height: 64px; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-wrap .ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
}

/* ==========================================================================
   ANALYSIS PIVOT (drill-down)
   ========================================================================== */
.pivot-table th, .pivot-table td { padding: 8px 10px; }
.pivot-row { cursor: pointer; }
.pivot-row:hover td { background: var(--surface-hover); }
.pivot-row .tree-indent { display: inline-block; }
.pivot-row .arrow {
  display: inline-block; width: 14px; font-size: 9px;
  color: var(--text-subtle); transition: transform 140ms var(--ease-out);
  margin-right: 4px;
}
.pivot-row.open > td .arrow { transform: rotate(90deg); color: var(--accent); }
.pivot-row.level-0 td { font-weight: 600; background: var(--surface-2); }
.pivot-row.level-1 td { font-size: 12.5px; }
.pivot-row.level-2 td { font-size: 12px; color: var(--text-muted); }
.pivot-child { display: none; }
.pivot-child.visible { display: table-row; }
.pivot-bar {
  display: inline-block; height: 6px; border-radius: 3px;
  vertical-align: middle; margin-left: 4px;
  background: var(--accent);
}
.pivot-bar.bar-sales { background: var(--success); }
.pivot-row.pivot-totals td { border-top: 2px solid var(--border-strong); font-weight: 700; background: var(--surface-2); }

/* ==========================================================================
   SEGMENTED
   ========================================================================== */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.segmented button {
  height: 26px; padding: 0 12px;
  background: transparent; border: none; color: var(--text-muted);
  font-size: 12px; font-weight: 600; font-family: inherit;
  border-radius: 4px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: color 100ms var(--ease-out), background 100ms;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button svg { width: 13px; height: 13px; }

/* Empty states */
.empty {
  padding: 48px 20px; text-align: center; color: var(--text-muted);
}
.empty .empty-icon {
  width: 48px; height: 48px; margin: 0 auto 12px;
  border-radius: 12px; background: var(--surface-2);
  display: grid; place-items: center; color: var(--text-subtle);
}
.empty h3 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto; }

.alert {
  padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.alert.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.alert.warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.alert.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
