/* ------------------------------------------------------------------ */
/*  Finanse — minimalist finance PWA, Dokploy-inspired dark aesthetic  */
/* ------------------------------------------------------------------ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500&display=swap');

:root {
  /* Surfaces */
  --bg:            #09090b;
  --bg-card:       #0f0f11;
  --bg-hover:     #17171a;
  --bg-input:     #131316;

  /* Borders */
  --border:       #1f1f23;
  --border-hover: #2a2a30;
  --border-focus: #3f3f46;

  /* Text */
  --text:         #fafafa;
  --text-muted:   #a1a1aa;
  --text-subtle:  #52525b;
  --text-dim:     #3f3f46;

  /* Accents — used sparingly */
  --green:        #4ade80;
  --green-dim:    #22c55e;
  --red:          #f87171;
  --red-dim:      #ef4444;
  --amber:        #fbbf24;

  /* Sizing */
  --radius:       8px;
  --radius-sm:    6px;
  --radius-xs:    4px;

  --sidebar-w:    232px;
  --month-w:      320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'SF Pro Text',
               'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
}

button { font-family: inherit; }

::selection { background: rgba(74, 222, 128, 0.25); }

/* --------------------------  layout  ----------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* --------------------------  sidebar  ---------------------------- */

.sidebar {
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #fafafa 0%, #a1a1aa 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.02em;
}

.brand-name {
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  padding: 8px 10px 4px;
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav a.active {
  background: var(--bg-hover);
  color: var(--text);
}

.nav a svg { flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-subtle);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* --------------------------  main  ------------------------------- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
}

.topbar-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar-sub {
  font-size: 12px;
  color: var(--text-subtle);
}

.topbar-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-crumbs span { color: var(--text-dim); }

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

.mobile-nav-toggle { display: none; }

/* --------------------------  hero strip  ------------------------- */

.hero {
  padding: 28px 24px 20px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.stat-value {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-value.small {
  font-size: 20px;
}

.stat-value .unit {
  font-size: 0.6em;
  color: var(--text-subtle);
  margin-left: 4px;
  font-weight: 400;
}

.stat-delta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.stat-delta.pos { color: var(--green); }
.stat-delta.neg { color: var(--red); }

/* --------------------------  months grid  ------------------------ */

.months-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}

.months-wrap::-webkit-scrollbar { height: 8px; }
.months-wrap::-webkit-scrollbar-track { background: transparent; }
.months-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.months-wrap::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

.months {
  display: flex;
  gap: 14px;
  padding: 20px 24px 40px;
  min-height: 100%;
}

.month {
  flex: 0 0 var(--month-w);
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
}

.month:hover { border-color: var(--border-hover); }

.month.current {
  border-color: var(--border-hover);
  box-shadow: 0 0 0 1px rgba(250, 250, 250, 0.02) inset;
}

.month.current .month-name::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--green);
}

/* month header */

.month-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.month-name {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  text-transform: capitalize;
}

.month-year {
  color: var(--text-subtle);
  font-weight: 400;
  margin-left: 6px;
}

.month-metrics {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 10.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.metric-value.income { color: var(--green); }
.metric-value.expense { color: var(--text); }

.metric-value.income.editable,
.metric-value.editable {
  cursor: text;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: var(--radius-xs);
  transition: background 0.12s ease;
}

.metric-value.editable:hover { background: var(--bg-hover); }

/* running balance under metrics */

.month-balance {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.month-balance-label {
  font-size: 10.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.month-balance-value {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

.month-balance-value.neg { color: var(--red); }

/* sections (stałe / jednorazowe) */

.sections {
  padding: 0 6px 4px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 4px;
  gap: 8px;
}

.section-title {
  font-size: 10.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.section-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-subtotal {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-subtle);
}

.section-add {
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  padding: 0;
  transition: color 0.1s ease, background 0.1s ease;
}

.section-add:hover {
  color: var(--text);
  background: var(--bg-input);
}

.section-add svg { width: 12px; height: 12px; }

.section-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 8px;
}

.section-empty {
  padding: 6px 10px 8px;
  color: var(--text-dim);
  font-size: 12px;
}

.section-divider {
  margin: 6px 12px 2px;
  border-bottom: 1px dashed var(--border);
}

.add-slot { padding: 0; }
.add-slot:not(:empty) { padding: 6px 4px 4px; }

/* expense row */

.expense {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  position: relative;
  transition: background 0.1s ease;
}

.expense:hover { background: var(--bg-hover); }

.expense-check {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1.5px solid var(--border-focus);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.expense-check:hover { border-color: var(--text-muted); }

.expense-check.checked {
  background: var(--green);
  border-color: var(--green);
}

.expense-check.checked svg {
  display: block;
  color: var(--bg);
}

.expense-check svg { display: none; width: 10px; height: 10px; }

.expense-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense.paid .expense-name {
  color: var(--text-subtle);
  text-decoration: line-through;
  text-decoration-color: var(--text-dim);
}

.expense-amount {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.expense.paid .expense-amount { color: var(--text-dim); }

.expense.pending .expense-amount {
  color: var(--amber);
}

.expense.pending .expense-name::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--amber);
  margin-left: 7px;
  vertical-align: middle;
  opacity: 0.85;
}

.expense-amount.editable {
  cursor: text;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: var(--radius-xs);
  transition: background 0.12s ease;
}

.expense-amount.editable:hover { background: var(--bg-input); }

/* row actions — overlay on hover so long expense names get full width */

.expense-actions {
  display: flex;
  gap: 2px;
  margin-left: 2px;
}

@media (hover: hover) {
  .expense-actions {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
    padding: 3px 4px;
    background: var(--bg-hover);
    border-radius: var(--radius-xs);
    box-shadow: -14px 0 10px -6px var(--bg-hover);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
  }
  .expense:hover .expense-actions,
  .expense:focus-within .expense-actions {
    opacity: 1;
    pointer-events: all;
  }
}

.expense-action {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s ease, color 0.1s ease;
}

.expense-action:hover {
  background: var(--bg-input);
  color: var(--text);
}

.expense-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.expense-action.danger:hover { color: var(--red); }

.expense-action svg { width: 13px; height: 13px; }

/* inline add-expense form (injected into an .add-slot) */

.expense-add-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
}

.expense-add-form input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  outline: none;
}

.expense-add-form input::placeholder { color: var(--text-subtle); }

.expense-add-form input:focus { background: rgba(255, 255, 255, 0.03); }

.expense-add-form .row {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 4px;
}

.expense-add-form input.amount {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.expense-add-form .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 2px;
}

.btn {
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-hover);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn:hover { background: var(--bg-hover); border-color: var(--border-focus); }

.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn.primary:hover { background: #e4e4e7; border-color: #e4e4e7; }

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

.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }

/* topbar edit-balance mini form */

.balance-edit {
  display: flex;
  align-items: center;
  gap: 6px;
}

.balance-edit input {
  background: var(--bg-input);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 4px 8px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  width: 140px;
  outline: none;
}

.balance-edit input:focus { border-color: var(--border-focus); }

/* --------------------------  dashboard  -------------------------- */

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
}

.empty-state-inner {
  max-width: 380px;
  text-align: center;
}

.empty-state-mark {
  width: 42px;
  height: 42px;
  margin: 0 auto 16px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
}

.empty-state h1 {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

/* --------------------------  responsive  ------------------------- */

@media (max-width: 900px) {
  :root { --month-w: 300px; }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 30;
    width: 260px;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    border-right: 1px solid var(--border);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 20;
  }

  .sidebar-backdrop.show { display: block; }

  .mobile-nav-toggle {
    display: flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    margin-right: 4px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 20px 16px 16px;
  }

  .stat-value { font-size: 24px; }

  .months { padding: 16px 16px 32px; }

  .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
  :root { --month-w: 84vw; }
  .stat-value { font-size: 22px; }
}
