/* ============================================================
   Jurnal Trading — Design System
   Refined dark fintech: deep slate canvas, dark-blue accent,
   layered surfaces, tabular numerics, subtle motion.
   ============================================================ */

/* ----------  1. DESIGN TOKENS  ---------- */
:root {
  /* Surface layers */
  --bg-app:        #0a0d14;
  --bg-sidebar:    #0c1019;
  --bg-card:       #11151f;
  --bg-card-2:     #141927;
  --bg-elevated:   #1a1f2c;
  --bg-input:      #0e131c;
  --bg-input-hover:#131927;
  --bg-row-hover:  rgba(255, 255, 255, 0.025);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default:rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Text */
  --text-primary:   #e7eaf3;
  --text-secondary: #aab1c4;
  --text-tertiary:  #777e92;
  --text-muted:     #555c6e;

  /* Accent — professional dark blue */
  --accent:           #2563eb; /* blue-600 */
  --accent-hover:     #3b82f6; /* blue-500 */
  --accent-active:    #1d4ed8; /* blue-700 */
  --accent-deep:      #1e3a8a; /* blue-900 */
  --accent-soft:      rgba(37, 99, 235, 0.12);
  --accent-soft-2:    rgba(37, 99, 235, 0.20);
  --accent-ring:      rgba(37, 99, 235, 0.35);
  --accent-glow:      rgba(37, 99, 235, 0.28);

  /* Semantic */
  --success:        #34d399;
  --success-strong: #4ade80;
  --success-soft:   rgba(52, 211, 153, 0.12);
  --success-border: rgba(52, 211, 153, 0.28);

  --danger:         #f87171;
  --danger-strong:  #fb7185;
  --danger-soft:    rgba(248, 113, 113, 0.12);
  --danger-border:  rgba(248, 113, 113, 0.28);

  --warning:        #fbbf24;
  --warning-soft:   rgba(251, 191, 36, 0.12);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs:   0.75rem;     /* 12 */
  --fs-sm:   0.8125rem;   /* 13 */
  --fs-base: 0.875rem;    /* 14 */
  --fs-md:   0.9375rem;   /* 15 */
  --fs-lg:   1rem;        /* 16 */
  --fs-xl:   1.125rem;    /* 18 */
  --fs-2xl:  1.375rem;    /* 22 */
  --fs-3xl:  1.75rem;     /* 28 */
  --fs-4xl:  2.25rem;     /* 36 */

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10:40px;
  --sp-12:48px;
  --sp-16:64px;

  /* Radius */
  --r-sm:   6px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-2xl:  20px;
  --r-pill: 999px;

  /* Shadows — subtle layered for dark mode */
  --sh-sm:    0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-md:    0 4px 14px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.18);
  --sh-lg:    0 16px 40px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.20);
  --sh-xl:    0 24px 60px rgba(0, 0, 0, 0.50), 0 4px 12px rgba(0, 0, 0, 0.25);
  --sh-inner: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --sh-glow:  0 0 0 1px var(--accent-soft), 0 8px 28px var(--accent-glow);

  /* Easing & transitions */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 120ms var(--ease-out);
  --t-base: 180ms var(--ease-out);
  --t-slow: 280ms var(--ease-out);

  /* Layout */
  --sidebar-w: 248px;

  /* Legacy aliases for any inline `var(--x)` left in HTML */
  --bg:       var(--bg-app);
  --panel:    var(--bg-card);
  --panel-2:  var(--bg-input);
  --border:   var(--border-default);
  --text:     var(--text-primary);
  --muted:    var(--text-tertiary);
  --accent-2: var(--accent);
}

/* ----------  2. RESET & BASE  ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background-color: var(--bg-app);
  background-image:
    radial-gradient(1200px 600px at 100% -10%, rgba(37, 99, 235, 0.08), transparent 60%),
    radial-gradient(900px  500px at -10% 100%, rgba(30, 58, 138, 0.06), transparent 55%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
  overflow: hidden;
}

::selection {
  background: var(--accent-soft-2);
  color: var(--text-primary);
}

h1, h2, h3, h4 {
  margin: 0;
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
h1 { font-size: var(--fs-3xl); letter-spacing: -0.03em; font-weight: 600; }
h2 { font-size: var(--fs-xl);  letter-spacing: -0.02em; }
h3 { font-size: var(--fs-lg); }

p { margin: 0; color: var(--text-secondary); }

a { color: inherit; text-decoration: none; }

img, svg { display: block; }

/* Tabular numerics utility */
.num,
td.num,
input[type='number'] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ----------  3. SCROLLBAR  ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-muted);
  background-clip: padding-box;
}

/* ----------  4. FOCUS  ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
button:focus-visible,
a:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 3px;
}

/* ============================================================
   APP SHELL — sidebar + content
   ============================================================ */
.layout {
  display: flex;
  min-height: 100vh;
  height: 100vh;
}

/* ----------  5. SIDEBAR  ---------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2);
  margin-bottom: var(--sp-6);
}
.brand__mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #3b82f6 0%, #1e3a8a 100%);
  color: #fff;
  flex: 0 0 auto;
  box-shadow:
    0 6px 16px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.brand__mark svg { width: 18px; height: 18px; }
.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__name {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.15;
}
.brand__sub {
  font-size: 10.5px;
  color: var(--text-tertiary);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-top: 2px;
  font-weight: 500;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-label {
  padding: var(--sp-2) var(--sp-3) 6px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 500;
  position: relative;
  transition: color var(--t-fast), background-color var(--t-fast);
  user-select: none;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}
.nav-link.active {
  background: var(--accent-soft);
  color: var(--text-primary);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--text-tertiary);
  transition: color var(--t-fast);
}
.nav-link:hover .nav-icon,
.nav-link.active .nav-icon { color: var(--accent); }

.sidebar__bottom {
  margin-top: auto;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 9px var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--t-fast);
}
.btn-logout svg { width: 16px; height: 16px; }
.btn-logout:hover {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger-strong);
}

/* ----------  6. CONTENT  ---------- */
.content {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--sp-6) var(--sp-8);
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
}

.page-header { margin-bottom: var(--sp-5); }
.page-header h1 { margin: 0 0 4px; }
.page-header .subtitle {
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
}

.section-spacer { margin-bottom: var(--sp-5); }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ----------  7. CARD (generic surface)  ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--sh-sm), var(--sh-inner);
  margin-bottom: var(--sp-4);
}
.card:last-child { margin-bottom: 0; }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.card__title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-primary);
}

/* ----------  8. GRIDS  ---------- */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.grid-categories {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

/* Charts grid: 2 cols on desktop, 1 col on mobile */
.grid-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.grid-charts .chart-card.span-2 { grid-column: 1 / -1; }

/* Chart card surface */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  box-shadow: var(--sh-sm), var(--sh-inner);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chart-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.chart-card__title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}
.chart-card__sub {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}
/* Smaller charts get a more compact body; equity curve (span-2) gets a bit more room */
.chart-card__body {
  position: relative;
  width: 100%;
  height: 220px;
}
.chart-card.span-2 .chart-card__body {
  height: 280px;
}
.chart-card__body canvas {
  width: 100% !important;
  height: 100% !important;
}
.chart-card__empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
  padding: var(--sp-4);
}
.chart-card.is-empty .chart-card__empty { display: flex; }
.chart-card.is-empty canvas { opacity: 0; }

/* ----------  9. STAT CARD  ---------- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--sp-4) var(--sp-5);
  position: relative;
  overflow: hidden;
  box-shadow: var(--sh-sm), var(--sh-inner);
  transition: transform var(--t-base), border-color var(--t-base), box-shadow var(--t-base);
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent);
  pointer-events: none;
}
.stat-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-default);
  box-shadow: var(--sh-md), var(--sh-inner);
}
.stat-card .label {
  display: block;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-bottom: var(--sp-2);
}
.stat-card .value {
  display: block;
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  line-height: 1.1;
}
.stat-card .value.profit { color: var(--success-strong); }
.stat-card .value.loss   { color: var(--danger-strong); }
.stat-card .micro {
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ----------  10. CATEGORY CARD  ---------- */
.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--sh-sm), var(--sh-inner);
  transition: transform var(--t-base), border-color var(--t-base);
}
.category-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-default);
}
.category-card__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.category-card__icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.category-card__icon svg { width: 18px; height: 18px; }
.category-card.cat-crypto .category-card__icon { background: rgba(247, 147, 26, 0.12); color: #f7931a; }
.category-card.cat-forex  .category-card__icon { background: rgba(52, 211, 153, 0.12); color: var(--success); }
.category-card.cat-saham  .category-card__icon { background: rgba(37, 99, 235, 0.14); color: var(--accent); }

.category-card__title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.category-card dl {
  margin: 0;
  display: flex;
  flex-direction: column;
}
.dl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-subtle);
  min-height: 32px;
}
.dl-row:last-child { border-bottom: 0; }
.dl-row dt {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dl-row dd {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* PL "value" inside category card → pill style.
   JS overwrites className on these spans to exactly
   'value profit' / 'value loss', so we scope by parent. */
.category-card .value {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1.4;
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}
.category-card .value.profit {
  background: var(--success-soft);
  color: var(--success-strong);
  box-shadow: inset 0 0 0 1px var(--success-border);
}
.category-card .value.loss {
  background: var(--danger-soft);
  color: var(--danger-strong);
  box-shadow: inset 0 0 0 1px var(--danger-border);
}

/* ----------  11. TABLES  ---------- */
.table-wrapper {
  overflow-x: auto;
  margin: 0 calc(-1 * var(--sp-2));
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
thead th {
  text-align: left;
  padding: 10px var(--sp-4);
  color: var(--text-tertiary);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
  background: transparent;
}
tbody td {
  padding: 12px var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  white-space: nowrap;
}
tbody tr {
  transition: background-color var(--t-fast);
}
tbody tr:hover { background: var(--bg-row-hover); }
tbody tr:last-child td { border-bottom: 0; }

/* Direction badges
   Used as <td class="badge-buy/sell"> (legacy, color only)
   and as <span class="badge badge-buy/sell"> (new, pill) */
.badge-buy  { color: var(--success-strong); font-weight: 600; }
.badge-sell { color: var(--danger-strong);  font-weight: 600; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.4;
}
.badge.badge-buy {
  background: var(--success-soft);
  color: var(--success-strong);
  box-shadow: inset 0 0 0 1px var(--success-border);
}
.badge.badge-sell {
  background: var(--danger-soft);
  color: var(--danger-strong);
  box-shadow: inset 0 0 0 1px var(--danger-border);
}

/* P/L color (used on td or span) */
.profit { color: var(--success-strong); font-weight: 600; }
.loss   { color: var(--danger-strong);  font-weight: 600; }

/* PL pill (used as <span class="pl-pill profit/loss">) */
.pl-pill {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.pl-pill.profit {
  background: var(--success-soft);
  color: var(--success-strong);
  box-shadow: inset 0 0 0 1px var(--success-border);
}
.pl-pill.loss {
  background: var(--danger-soft);
  color: var(--danger-strong);
  box-shadow: inset 0 0 0 1px var(--danger-border);
}

/* Notes column / muted cell content */
.cell-muted {
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-cap { text-transform: capitalize; }

/* Empty state row */
.empty-row td {
  padding: var(--sp-12) var(--sp-4);
  text-align: center;
  border-bottom: 0;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  max-width: 380px;
  margin: 0 auto;
}
.empty-state__icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--sp-1);
}
.empty-state__icon svg { width: 28px; height: 28px; }
.empty-state__title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.empty-state__desc {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  margin: 0;
  line-height: 1.55;
}

/* ----------  12. FORMS  ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
}
.form-field { display: flex; flex-direction: column; }
.form-field--full { grid-column: 1 / -1; }

label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--fs-base);
  outline: none;
  transition:
    border-color var(--t-fast),
    box-shadow   var(--t-fast),
    background-color var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder,
textarea::placeholder { color: var(--text-muted); }
input:hover,
select:hover,
textarea:hover { border-color: var(--border-strong); }
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: var(--bg-input-hover);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input[type='number'] { font-variant-numeric: tabular-nums; }

textarea {
  resize: vertical;
  min-height: 64px;
  font-family: inherit;
  line-height: 1.55;
}

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23777e92' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

input[type='date'] {
  color-scheme: dark;
}
input[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(0.7) brightness(0.85);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--t-fast);
}
input[type='date']:hover::-webkit-calendar-picker-indicator { opacity: 1; }

.form-actions {
  margin-top: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.form-msg {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
}

/* ----------  13. BUTTONS  ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.005em;
  transition:
    background-color var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast),
    transform var(--t-fast),
    box-shadow var(--t-fast);
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow:
    0 6px 16px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
  transform: translateY(1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-default);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-block { width: 100%; padding: 12px 16px; }

/* Icon-only buttons (table row actions) */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-icon-edit:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.30);
}
.btn-icon-del:hover {
  background: var(--danger-soft);
  color: var(--danger-strong);
  border-color: var(--danger-border);
}
.row-actions {
  display: inline-flex;
  gap: 6px;
}

/* ============================================================
   PAGES
   ============================================================ */

/* ----------  14. LOGIN  ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  position: relative;
  overflow: auto;
  background-color: var(--bg-app);
  background-image:
    radial-gradient(800px 500px at 20% 10%, rgba(37, 99, 235, 0.18), transparent 60%),
    radial-gradient(700px 500px at 80% 90%, rgba(30, 58, 138, 0.10), transparent 55%);
  background-attachment: fixed;
}
.auth-shell::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.30) 100%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background:
    linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card-2) 100%);
  border: 1px solid var(--border-default);
  border-radius: var(--r-2xl);
  padding: var(--sp-8);
  box-shadow: var(--sh-xl), var(--sh-inner);
}
.auth-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 35%);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.auth-brand .brand__name { font-size: var(--fs-lg); }

.auth-card h1 {
  font-size: var(--fs-2xl);
  margin: 0 0 6px;
}
.auth-card .subtitle {
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
  margin: 0 0 var(--sp-6);
}
.auth-card .field { margin-bottom: var(--sp-4); }

.error-msg {
  margin-top: var(--sp-4);
  padding: 10px 14px;
  background: var(--danger-soft);
  color: var(--danger-strong);
  border: 1px solid var(--danger-border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  display: none;
}

/* ============================================================
   15. MOBILE TOPBAR (hamburger + brand) — hidden on desktop
   ============================================================ */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-4);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 40;
}
.mobile-topbar .brand { margin: 0; padding: 0; flex: 1 1 auto; }
.mobile-topbar .brand__mark { width: 30px; height: 30px; }
.mobile-topbar .brand__mark svg { width: 16px; height: 16px; }
.mobile-topbar .brand__name { font-size: var(--fs-sm); }
.mobile-topbar .brand__sub { font-size: 9.5px; }

.btn-hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex: 0 0 auto;
  transition: all var(--t-fast);
}
.btn-hamburger svg { width: 20px; height: 20px; }
.btn-hamburger:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Backdrop shown when mobile sidebar is open */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 49;
  opacity: 0;
  transition: opacity var(--t-base);
}
.sidebar-backdrop.is-open {
  display: block;
  opacity: 1;
}

/* ============================================================
   16. RESPONSIVE BREAKPOINTS
   ============================================================ */

/* ---------- ≤ 1024px : tighter desktop / small laptop ---------- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .content { padding: var(--sp-5) var(--sp-6); }
  .grid-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .grid-categories { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .grid-charts { grid-template-columns: 1fr; }
  .grid-charts .chart-card.span-2 { grid-column: auto; }
  .chart-card.span-2 .chart-card__body { height: 260px; }
}

/* ---------- ≤ 768px : tablet & mobile — sidebar becomes drawer ---------- */
@media (max-width: 768px) {
  body { overflow: auto; }
  .layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  /* Show mobile topbar */
  .mobile-topbar { display: flex; }

  /* Sidebar slides in from the left as an off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    min-width: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    border-right: 1px solid var(--border-subtle);
    border-bottom: 0;
    box-shadow: var(--sh-xl);
    padding: var(--sp-5) var(--sp-4) var(--sp-4);
  }
  .sidebar.is-open { transform: translateX(0); }

  /* Restore highlight bar (was hidden in old breakpoint) */
  .nav-link.active::before { display: block; }

  .content {
    height: auto;
    max-height: none;
    padding: var(--sp-4) var(--sp-5);
    overflow: visible;
  }

  /* Headings & spacing */
  h1 { font-size: var(--fs-2xl); }
  .page-header { margin-bottom: var(--sp-4); }
  .grid-stats,
  .grid-categories,
  .grid-charts { gap: var(--sp-3); margin-bottom: var(--sp-4); }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-categories { grid-template-columns: 1fr; }

  /* Charts a touch shorter on tablets */
  .chart-card__body { height: 200px; }
  .chart-card.span-2 .chart-card__body { height: 240px; }

  /* Cards & forms */
  .card { padding: var(--sp-4); border-radius: var(--r-lg); }
  .stat-card,
  .category-card,
  .chart-card { border-radius: var(--r-lg); }
  .form-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
  }

  /* Touch targets ≥ 40px */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-block { padding: 12px 16px; }
  input, select, textarea {
    font-size: var(--fs-md); /* ≥16px equivalent → no iOS zoom on focus */
    padding: 11px 12px;
    min-height: 44px;
  }
  textarea { min-height: 72px; }
  .btn-icon { width: 36px; height: 36px; }
  .btn-icon svg { width: 16px; height: 16px; }

  /* Auth card scales */
  .auth-shell { padding: var(--sp-4); }
  .auth-card { padding: var(--sp-6); border-radius: var(--r-xl); }
  .auth-card h1 { font-size: var(--fs-xl); }
}

/* ---------- ≤ 480px : phones — single column everywhere ---------- */
@media (max-width: 480px) {
  .content { padding: var(--sp-3) var(--sp-4); }

  .grid-stats { grid-template-columns: 1fr; }

  .stat-card,
  .category-card { padding: var(--sp-4); }
  .stat-card .value { font-size: var(--fs-xl); }
  .stat-card .label { margin-bottom: 6px; }
  .stat-card .micro { display: none; }

  .chart-card { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
  .chart-card__body { height: 180px; }
  .chart-card.span-2 .chart-card__body { height: 220px; }
  .chart-card__head {
    flex-wrap: wrap;
    row-gap: 2px;
  }

  .card { padding: var(--sp-3) var(--sp-4); }
  .card__head { margin-bottom: var(--sp-3); }
  .card__title { font-size: var(--fs-md); }

  .form-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; }

  /* Tables stay scrollable horizontally */
  .table-wrapper {
    margin: 0 calc(-1 * var(--sp-4));
    padding: 0 var(--sp-4);
    -webkit-overflow-scrolling: touch;
  }
  thead th { padding: 9px var(--sp-3); }
  tbody td { padding: 10px var(--sp-3); }
  .cell-muted { max-width: 140px; }

  .sidebar { width: 86vw; max-width: 320px; }

  .mobile-topbar { padding: 8px var(--sp-3); }

  .auth-card { padding: var(--sp-5); }
  .auth-card h1 { font-size: var(--fs-lg); }
  .auth-card .subtitle { font-size: var(--fs-xs); margin-bottom: var(--sp-4); }
}
