/* ============================================
   RESET & BASE
============================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-soft: rgba(139, 92, 246, 0.15);
  --accent-glow: rgba(139, 92, 246, 0.35);
  --cyan: #22d3ee;
  --pink: #f472b6;
  --yellow: #facc15;
  --green: #22c55e;
  --red: #ef4444;
  --red-hover: #dc2626;
  --red-soft: rgba(239, 68, 68, 0.12);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 12px;
  --radius-lg: 16px;

  --sidebar-w: 260px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
}

/* Dark theme (default) */
body[data-theme="dark"] {
  --bg: #0a0a0f;
  --bg-2: #0f0f16;
  --bg-3: #131320;
  --surface: #16161f;
  --surface-2: #1c1c28;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f5f5fa;
  --text-soft: #b8b8c7;
  --text-muted: #6e6e7d;
  --text-dim: #48485a;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --chart-grid: rgba(255, 255, 255, 0.05);
}

/* Light theme */
body[data-theme="light"] {
  --bg: #f7f7fb;
  --bg-2: #ffffff;
  --bg-3: #f0f0f6;
  --surface: #ffffff;
  --surface-2: #f5f5fa;
  --border: rgba(15, 15, 30, 0.08);
  --border-strong: rgba(15, 15, 30, 0.15);
  --text: #14141e;
  --text-soft: #4a4a5c;
  --text-muted: #7a7a8a;
  --text-dim: #a0a0b0;
  --shadow: 0 20px 60px -25px rgba(20, 20, 40, 0.15);
  --shadow-sm: 0 1px 2px rgba(15, 15, 30, 0.05);
  --chart-grid: rgba(15, 15, 30, 0.06);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}
input:focus,
select:focus,
textarea:focus { outline: none; }

::selection { background: var(--accent); color: white; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================
   APP SHELL
============================================ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   SIDEBAR
============================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: width 0.3s var(--ease), transform 0.3s var(--ease);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: var(--topbar-h);
  gap: 0.5rem;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 1.2rem 0.5rem;
}
.sidebar.collapsed .logo { display: none; }
.sidebar.collapsed .sidebar-toggle {
  width: 34px;
  height: 34px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--accent);
  flex-shrink: 0;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 15px -3px var(--accent-glow);
}

.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
}
.sidebar-toggle svg {
  transition: transform 0.3s var(--ease);
}
.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* Workspace switcher */
.sidebar-workspace {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.workspace-switcher {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s var(--ease);
  white-space: nowrap;
}
.workspace-switcher:hover { background: var(--surface-2); }

.workspace-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f472b6, #8b5cf6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.workspace-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.workspace-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
}
.workspace-plan {
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 500;
}

.sidebar.collapsed .workspace-info { display: none; }

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-group-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 0.75rem 0.5rem;
  white-space: nowrap;
}

.sidebar.collapsed .nav-group-label {
  opacity: 0;
  height: 0.5rem;
  padding: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--text-soft);
  font-weight: 500;
  font-size: 0.85rem;
  transition: all 0.2s var(--ease);
  position: relative;
  white-space: nowrap;
  cursor: pointer;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.active svg { opacity: 1; }

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-badge {
  margin-left: auto;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-mono);
}
.nav-item.active .nav-badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar.collapsed .nav-item span:not(.nav-badge) {
  opacity: 0;
  pointer-events: none;
}
.sidebar.collapsed .nav-badge { display: none; }

/* Sidebar footer */
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-block { width: 100%; justify-content: center; }

.sidebar.collapsed .sidebar-footer .btn span {
  display: none;
}
.sidebar.collapsed .sidebar-footer .btn {
  padding: 0.7rem;
}

/* ============================================
   MAIN
============================================ */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  transition: margin-left 0.3s var(--ease);
  min-width: 0;
}

.sidebar.collapsed ~ .main {
  margin-left: var(--sidebar-w-collapsed);
}

/* ============================================
   TOPBAR
============================================ */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 40;
  gap: 1.5rem;
}

body[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.8);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.sidebar-toggle-mobile {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--text-muted);
  align-items: center;
  justify-content: center;
}
.sidebar-toggle-mobile:hover {
  background: var(--surface-2);
  color: var(--text);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}
.breadcrumb svg { opacity: 0.4; }
.breadcrumb-current { color: var(--text); font-weight: 600; }

.topbar-center {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.date-filter {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.date-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  transition: all 0.2s var(--ease);
}
.date-btn:hover { color: var(--text); }
.date-btn.active {
  background: var(--accent);
  color: white;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: flex-end;
}

.theme-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
}
.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.theme-toggle svg {
  position: absolute;
  transition: opacity 0.3s var(--ease), transform 0.4s var(--ease);
}
body[data-theme="dark"] .theme-icon-light { opacity: 0; transform: rotate(90deg); }
body[data-theme="dark"] .theme-icon-dark { opacity: 1; transform: rotate(0); }
body[data-theme="light"] .theme-icon-dark { opacity: 0; transform: rotate(-90deg); }
body[data-theme="light"] .theme-icon-light { opacity: 1; transform: rotate(0); }

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 0 1rem;
  }
  .topbar-center { display: none; }
  .sidebar-toggle-mobile { display: flex; }
}

@media (max-width: 600px) {
  .topbar-right .btn-primary { padding: 0.5rem 0.7rem; }
  .topbar-right .btn-primary span:not(svg) { display: none; }
  .topbar-right .btn-primary { gap: 0; }
}

/* ============================================
   BUTTONS
============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}

.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.78rem; }

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 15px -3px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -3px var(--accent-glow);
}

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

.btn-danger {
  background: var(--red);
  color: white;
  box-shadow: 0 4px 12px -3px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: var(--red-hover);
  transform: translateY(-1px);
}

/* ============================================
   CONTENT
============================================ */
.content {
  padding: 1.75rem 2rem 3rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 700px) {
  .content { padding: 1.25rem 1rem 2rem; }
}

/* ============================================
   KPI GRID
============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: all 0.3s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.kpi-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--surface-2);
  color: var(--text-muted);
}
.kpi-badge.positive {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
}
.kpi-badge.negative {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 550px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ============================================
   MAIN GRID
============================================ */
.main-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  transition: border-color 0.3s var(--ease);
}
.card:hover { border-color: var(--border-strong); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.card-title {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-action {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  transition: background 0.2s var(--ease);
}
.card-action:hover { background: var(--accent-soft); }

.card-legend {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-soft);
  font-weight: 500;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend-pill-accent .legend-dot { background: var(--accent); }
.legend-pill-cyan .legend-dot { background: var(--cyan); }

@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ============================================
   CHART
============================================ */
.card-chart {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  min-height: 420px;
  position: relative;
}

.chart-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 0.5rem;
}

.chart-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 1.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-align: right;
}

.chart-area {
  position: relative;
}

.chart-svg {
  width: 100%;
  height: 260px;
  display: block;
  overflow: visible;
}

.chart-grid line {
  stroke: var(--chart-grid);
  stroke-width: 1;
  stroke-dasharray: 3 5;
}

.hover-line {
  stroke: var(--text-dim);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
}
.hover-line.visible { opacity: 1; }

.hover-dot {
  fill: var(--accent);
  stroke: var(--bg-2);
  stroke-width: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.hover-dot.visible { opacity: 1; }

.chart-x-axis {
  display: flex;
  justify-content: space-between;
  padding-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.chart-tooltip {
  position: absolute;
  top: 20px;
  left: 0;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-8px);
  transition: opacity 0.2s var(--ease);
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.4);
  min-width: 170px;
  z-index: 10;
}
.chart-tooltip.visible { opacity: 1; }

.tooltip-date {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-soft);
  padding: 0.2rem 0;
}
.tooltip-row strong {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
}

.tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.tooltip-dot-accent { background: var(--accent); }
.tooltip-dot-cyan { background: var(--cyan); }

.chart-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 3rem 1rem;
  text-align: center;
}
.chart-empty.visible { display: flex; }
.chart-empty p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 700px) {
  .card-chart { min-height: auto; }
  .chart-svg { height: 200px; }
  .chart-y-axis { display: none; }
  .chart-wrap { grid-template-columns: 1fr; }
}

/* ============================================
   SUMMARY CARD
============================================ */
.card-summary {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

.summary-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.5rem;
  border-radius: 8px;
  transition: background 0.2s var(--ease);
}
.summary-item:hover { background: var(--surface-2); }

.summary-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.summary-value {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

/* ============================================
   ENTRIES
============================================ */
.card-entries {
  grid-column: 1 / -1;
  grid-row: 2 / 3;
}

.entries-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.entry-item {
  display: grid;
  grid-template-columns: 100px 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0.6rem;
  border-radius: 10px;
  transition: background 0.2s var(--ease);
  animation: slideIn 0.35s var(--ease);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.entry-item:hover { background: var(--surface-2); }

.entry-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.entry-note {
  font-size: 0.85rem;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-note .muted { color: var(--text-dim); font-style: italic; }

.entry-metrics {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.entry-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}
.entry-metric-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-family: var(--font-sans);
}
.entry-metric-value {
  font-weight: 600;
  color: var(--text);
}

.entry-actions {
  display: flex;
  gap: 0.15rem;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.entry-item:hover .entry-actions { opacity: 1; }

.entry-action {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
}
.entry-action:hover {
  background: var(--surface);
  color: var(--text);
}
.entry-action.delete:hover {
  background: var(--red-soft);
  color: var(--red);
}

.entries-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 3rem 1rem;
  text-align: center;
}
.entries-empty.visible { display: flex; }
.entries-empty p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 700px) {
  .entry-item {
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0.8rem 0.5rem;
  }
  .entry-date {
    grid-column: 1 / 2;
    font-size: 0.72rem;
  }
  .entry-note {
    grid-column: 1 / 2;
    font-size: 0.8rem;
  }
  .entry-metrics {
    grid-column: 1 / -1;
    justify-content: space-between;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    margin-top: 0.4rem;
  }
  .entry-metric { align-items: flex-start; }
  .entry-actions {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
    align-self: center;
    opacity: 1;
  }
  .entry-actions .entry-action:not(.delete) { display: none; }
}

/* ============================================
   DATA VIEW
============================================ */
.data-view {
  display: none;
  flex-direction: column;
}
.data-view.visible { display: flex; }

.data-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.data-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.data-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table-head {
  display: grid;
  grid-template-columns: 140px 1fr 1fr 1fr 1.5fr 40px;
  gap: 0.75rem;
  padding: 0.85rem 1.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.data-table-body {
  display: flex;
  flex-direction: column;
}

.data-row {
  display: grid;
  grid-template-columns: 140px 1fr 1fr 1fr 1.5fr 40px;
  gap: 0.75rem;
  padding: 0.85rem 1.2rem;
  align-items: center;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s var(--ease);
  animation: slideIn 0.3s var(--ease);
}
.data-row:hover { background: var(--surface-2); }
.data-row:last-child { border-bottom: none; }

.data-cell {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-cell-note {
  font-family: var(--font-sans);
  color: var(--text-muted);
  font-style: italic;
}
.data-cell-note.empty { color: var(--text-dim); }

.data-row-delete {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
  opacity: 0;
}
.data-row:hover .data-row-delete { opacity: 1; }
.data-row-delete:hover {
  background: var(--red-soft);
  color: var(--red);
}

.data-table-empty {
  display: none;
  padding: 3rem 1rem;
  text-align: center;
}
.data-table-empty.visible { display: block; }
.data-table-empty p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 800px) {
  .data-table-head { display: none; }
  .data-row {
    grid-template-columns: 1fr auto;
    gap: 0.4rem 1rem;
    padding: 1rem;
  }
  .data-cell:nth-child(1) {
    grid-column: 1 / -1;
    font-weight: 600;
  }
  .data-cell:nth-child(5) {
    grid-column: 1 / -1;
  }
  .data-row-delete {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    opacity: 1;
  }
}

/* ============================================
   MODAL
============================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}
.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.3s var(--ease);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
}
.modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-soft);
}

.field-optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.field input,
.field select {
  padding: 0.7rem 0.9rem;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: 9px;
  font-size: 0.88rem;
  color: var(--text);
  transition: all 0.2s var(--ease);
  width: 100%;
}
.field input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder { color: var(--text-muted); }

.amount-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.amount-currency {
  position: absolute;
  left: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}
.amount-input-wrap input {
  padding-left: 1.9rem !important;
  font-family: var(--font-mono) !important;
  font-weight: 500 !important;
}

.modal-footer {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* Confirm modal */
.modal-confirm {
  max-width: 380px;
  text-align: center;
}

.confirm-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.confirm-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0.4rem 0 1.5rem;
}

.modal-confirm .modal-footer { justify-content: center; }

/* ============================================
   TOAST
============================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--bg);
  padding: 0.75rem 1.2rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 300;
  transition: transform 0.4s var(--ease);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.toast-undo {
  background: rgba(255, 255, 255, 0.15);
  color: var(--bg);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: 0.3rem;
  transition: background 0.2s var(--ease);
}
.toast-undo:hover { background: rgba(255, 255, 255, 0.25); }

/* ============================================
   RESPONSIVE (mobile sidebar)
============================================ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
  }
  .main { margin-left: 0 !important; }
  .sidebar.collapsed { width: var(--sidebar-w); }
  .sidebar.collapsed .logo,
  .sidebar.collapsed .workspace-info,
  .sidebar.collapsed .sidebar-footer .btn span {
    display: flex;
  }
  .sidebar.collapsed .nav-item span:not(.nav-badge) {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar.collapsed .nav-badge { display: inline-block; }
  .sidebar.collapsed .nav-group-label {
    opacity: 1;
    height: auto;
    padding: 0 0.75rem 0.5rem;
  }
  .sidebar.collapsed .sidebar-header {
    justify-content: space-between;
    padding: 1.2rem 1.2rem;
  }
  .sidebar.collapsed .sidebar-toggle { display: none; }
}