/* style.css — Budżet Domowy | Dark Financial Terminal */

/* ── CSS Custom Properties ──────────────────────────────── */
:root {
  --bg: #0a0e1a;
  --bg2: #111827;
  --bg3: #1a2235;
  --border: #1e2d47;
  --border-lt: #2a3f5f;
  --txt: #e2e8f0;
  --txt-muted: #64748b;
  --txt-dim: #334155;

  --blue: #3b82f6;
  --blue-glow: #3b82f640;
  --blue-dk: #1d4ed8;
  --green: #10b981;
  --green-glow: #10b98120;
  --amber: #f59e0b;
  --amber-glow: #f59e0b20;
  --red: #ef4444;
  --red-glow: #ef444420;
  --purple: #8b5cf6;

  --font-ui: 'Syne', sans-serif;
  --font-mono: 'Fira Code', monospace;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px #00000040;
  --shadow-lg: 0 8px 40px #00000060;

  --sidebar-w: 220px;
  --transition: .2s ease;
}

/* ── Reset ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  overflow-x: hidden;
}

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

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

input,
select,
textarea {
  font-family: inherit;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--txt);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  width: 100%;
  transition: border-color var(--transition),
    box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-glow);
}

svg {
  width: 1.1em;
  height: 1.1em;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: var(--bg2);
}

::-webkit-scrollbar-thumb {
  background: var(--border-lt);
  border-radius: 2px;
}

/* ════════════════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════════════════ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
  /* Scanline overlay */
  background-image:
    repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      #ffffff04 2px,
      #ffffff04 4px);
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: min(380px, calc(100vw - 2rem));
  box-shadow: var(--shadow-lg), 0 0 60px #3b82f610;
  animation: fadeIn .4s ease;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.logo-icon {
  font-size: 2.4rem;
  font-family: var(--font-mono);
  color: var(--blue);
  text-shadow: 0 0 20px var(--blue-glow);
}

.logo-icon.small {
  font-size: 1.4rem;
}

.logo-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 0 15px var(--blue-glow));
}

.logo-img.small {
  width: 32px;
  height: 32px;
}

.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--txt);
}

.login-logo h1 span {
  color: var(--blue);
}

.login-error {
  background: var(--red-glow);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  font-size: .85rem;
  margin-bottom: 1rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--txt-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .4rem;
}

.btn-primary {
  width: 100%;
  padding: .8rem;
  background: var(--blue);
  background: linear-gradient(to bottom, var(--blue), var(--blue-dk));
  color: #fff;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .04em;
  margin-top: .5rem;
  border-bottom: 4px solid #1e3a8a;
  transition: all 0.1s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 5px 20px var(--blue-glow);
}

.btn-primary:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  border-bottom-width: 4px;
}

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

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 50;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.5rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--txt);
  letter-spacing: .03em;
}

.nav-list {
  list-style: none;
  padding: .75rem 0;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.2rem;
  color: var(--txt-muted);
  font-size: .9rem;
  font-weight: 600;
  border-radius: 8px;
  margin: 0.2rem 0.6rem;
  border: 1px solid transparent;
  transition: all var(--transition);
}

.nav-link:hover {
  color: var(--txt);
  background: var(--bg3);
}

.nav-link.active {
  color: #fff;
  background: var(--blue);
  background: linear-gradient(to bottom, var(--blue), var(--blue-dk));
  border-color: var(--blue-dk);
  box-shadow: 0 4px 0 #1e3a8a, 0 4px 15px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.nav-link.active:active {
  transform: translateY(0);
  box-shadow: 0 1px 0 #1e3a8a, 0 2px 5px rgba(0, 0, 0, 0.3);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1rem 1.2rem;
  color: var(--txt-muted);
  font-size: .85rem;
  font-weight: 600;
  background: none;
  border-top: 1px solid var(--border);
  transition: color var(--transition);
  width: 100%;
}

.btn-logout:hover {
  color: var(--red);
}

/* ── Hamburger ──────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 60;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem;
  flex-direction: column;
  gap: 4px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--txt);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ── Main Content ───────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn .3s ease;
}

/* Centrowanie wszystkich głównych bloków na stronie */
.main-content>* {
  width: 100%;
  max-width: 1300px;
}

/* ════════════════════════════════════════════════════════
   PAGE HEADER
═══════════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--txt);
}

.page-subtitle {
  color: var(--txt-muted);
  font-size: 1rem;
  margin-top: .2rem;
}

/* ════════════════════════════════════════════════════════
   KPI CARDS
═══════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  transition: border-color var(--transition),
    box-shadow var(--transition);
  text-align: center;
}

.kpi-card:hover {
  border-color: var(--border-lt);
  box-shadow: var(--shadow);
}

.kpi-card.accent-blue {
  border-top: 3px solid var(--blue);
}

.kpi-card.accent-green {
  border-top: 3px solid var(--green);
}

.kpi-card.accent-amber {
  border-top: 3px solid var(--amber);
}

.kpi-card.accent-red {
  border-top: 3px solid var(--red);
}

.kpi-card.clickable {
  cursor: pointer;
  user-select: none;
}

.kpi-card.clickable:active {
  transform: scale(0.97);
}

.kpi-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--txt-muted);
  margin-bottom: .5rem;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--txt);
  line-height: 1;
}

.kpi-value.green {
  color: var(--green);
}

.kpi-value.amber {
  color: var(--amber);
}

.kpi-value.red {
  color: var(--red);
}

.kpi-value.blue {
  color: var(--blue);
}

.kpi-meta {
  font-size: .78rem;
  color: var(--txt-muted);
  margin-top: .4rem;
}

/* ════════════════════════════════════════════════════════
   GRID LAYOUTS
═══════════════════════════════════════════════════════════ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* ════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════ */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--txt);
}

.card-body {
  padding: 1.25rem;
}

/* ════════════════════════════════════════════════════════
   CHARTS
═══════════════════════════════════════════════════════════ */
.chart-wrap {
  position: relative;
  height: 220px;
}

/* ════════════════════════════════════════════════════════
   UPCOMING PAYMENTS LIST
═══════════════════════════════════════════════════════════ */
.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.upcoming-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem .9rem;
  background: var(--bg3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  gap: .75rem;
}

.upcoming-name {
  font-size: .9rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upcoming-badge {
  font-size: .72rem;
  font-family: var(--font-mono);
  padding: .2rem .5rem;
  border-radius: 99px;
  white-space: nowrap;
}

.badge-today {
  background: var(--red-glow);
  color: var(--red);
  border: 1px solid var(--red);
}

.badge-soon {
  background: var(--amber-glow);
  color: var(--amber);
  border: 1px solid var(--amber);
}

.badge-ok {
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid var(--green);
}

.badge-late {
  background: #ef444430;
  color: #ff5f5f;
  border: 1px solid var(--red);
  font-weight: 800;
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.upcoming-amount {
  font-family: var(--font-mono);
  font-size: .9rem;
  color: var(--txt-muted);
  white-space: nowrap;
}

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

.bills-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.bills-table th {
  text-align: left;
  padding: .65rem .9rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--txt-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.bills-table td {
  padding: .75rem .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.bills-table tr:last-child td {
  border-bottom: none;
}

.bills-table tr:hover td {
  background: var(--bg3);
}

.amount-cell {
  font-family: var(--font-mono);
  font-size: .9rem;
  white-space: nowrap;
}

.day-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg3);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--txt-muted);
}

.category-chip {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--bg3);
  color: var(--txt-muted);
  border: 1px solid var(--border);
}

/* ── Status toggle ──────────────────────────────────── */
.status-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .8rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.1s;
  border: 1px solid transparent;
  box-shadow: 0 3px 0 rgba(0,0,0,0.3);
}

.status-btn.paid {
  background: var(--green);
  color: #fff;
  border-bottom: 3px solid #065f46;
}

.status-btn.unpaid {
  background: var(--red);
  color: #fff;
  border-bottom: 3px solid #991b1b;
}

.status-btn.na {
  background: #fff;
  color: #000;
  border-bottom: 3px solid #999;
  font-weight: 800;
}

.status-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.status-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.3);
  border-bottom-width: 1px;
}

/* ── Table actions ──────────────────────────────────── */
.row-actions {
  display: flex;
  gap: .4rem;
  justify-content: flex-end;
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--bg3);
  color: var(--txt-muted);
  border: 1px solid var(--border);
  border-bottom: 3px solid #0f172a;
  transition: all 0.1s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn-icon:hover {
  color: var(--txt);
  border-color: var(--border-lt);
  transform: translateY(-1px);
}

.btn-icon:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.btn-icon.danger:hover {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-glow);
}

/* ════════════════════════════════════════════════════════
   LOAN PROGRESS CARDS
═══════════════════════════════════════════════════════════ */
.loan-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  transition: border-color var(--transition);
}

.loan-card:hover {
  border-color: var(--border-lt);
}

.drag-handle {
  cursor: grab;
  color: var(--txt-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 6px;
  transition: all var(--transition);
  background: var(--bg3);
  border: 1px solid var(--border);
}

.drag-handle:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle svg {
  width: 1rem;
  height: 1rem;
}

.loan-card-header {
  display: flex;
  align-items: center;
  margin-bottom: .8rem;
  gap: .75rem;
}

.loan-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--txt);
}

.loan-status {
  flex-shrink: 0;
}

.loan-meta {
  display: flex;
  gap: 1.5rem;
  margin-bottom: .9rem;
  flex-wrap: wrap;
}

.loan-meta-item {
  display: flex;
  flex-direction: column;
}

.meta-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--txt-muted);
  font-weight: 700;
}

.meta-value {
  font-family: var(--font-mono);
  font-size: .95rem;
  color: var(--txt);
  margin-top: .15rem;
}

.meta-value.highlight {
  color: var(--amber);
}

.meta-value.highlight-green {
  color: var(--green);
}

.meta-value.highlight-blue {
  color: var(--blue);
}

/* Progress bar */
.progress-wrap {
  background: var(--bg3);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin-bottom: .4rem;
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  transition: width .6s ease;
}

.progress-bar.done {
  background: var(--green);
}

.progress-label {
  font-size: .72rem;
  color: var(--txt-muted);
  font-family: var(--font-mono);
  display: flex;
  justify-content: space-between;
}

/* ════════════════════════════════════════════════════════
   SZAMBO
═══════════════════════════════════════════════════════════ */
.szambo-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.szambo-stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.4rem;
  flex: 1;
  min-width: 160px;
}

/* ════════════════════════════════════════════════════════
   MODAL / FORM
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: #00000080;
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn .2s ease;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: min(460px, 100%);
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

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

.btn-secondary {
  padding: .6rem 1.2rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--txt-muted);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .88rem;
  transition: all var(--transition);
}

.btn-secondary:hover {
  color: var(--txt);
  border-color: var(--border-lt);
}

.btn-danger {
  padding: .6rem 1.2rem;
  background: var(--red-glow);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .88rem;
  transition: all var(--transition);
}

.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

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

.form-row .field {
  margin-bottom: 0;
}

/* ════════════════════════════════════════════════════════
   ADD BUTTON
═══════════════════════════════════════════════════════════ */
.btn-add {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.2rem;
  background: var(--blue);
  background: linear-gradient(to bottom, var(--blue), var(--blue-dk));
  color: #fff;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .85rem;
  border-bottom: 3px solid #1e3a8a;
  transition: all 0.1s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.btn-add:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 15px var(--blue-glow);
  transform: translateY(-1px);
}

.btn-add:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.3);
}

/* ════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  padding: .75rem 1.1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 600;
  border-left: 4px solid;
  animation: slideIn .3s ease, fadeOut .3s ease 2.7s forwards;
  max-width: 320px;
  pointer-events: auto;
}

.toast.success {
  background: var(--bg2);
  border-color: var(--green);
  color: var(--green);
}

.toast.error {
  background: var(--bg2);
  border-color: var(--red);
  color: var(--red);
}

.toast.info {
  background: var(--bg2);
  border-color: var(--blue);
  color: var(--blue);
}

/* ════════════════════════════════════════════════════════
   LOADER
═══════════════════════════════════════════════════════════ */
.loader-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
}

.loader {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ════════════════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--txt-muted);
}

.empty-state svg {
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  opacity: .3;
}

.empty-state p {
  font-size: .9rem;
}

/* ════════════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════════════ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .hamburger {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    max-width: 100vw;
    padding: 1rem;
    padding-top: 4rem;
  }

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

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 1.4rem;
  }

  .page-title {
    font-size: 1.3rem;
  }
}

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

/* ── Calendar Redesign ──────────────────────────────── */
.cal-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 5px;
  font-size: 0.9rem;
  background: rgba(17, 24, 39, 0.4);
  border-radius: var(--radius-lg);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  overflow: hidden; /* For column highlight clipping */
}

.cal-table th,
.cal-table td {
  padding: 0;
  text-align: center;
  border: none;
}

.cal-table th {
  padding: 12px 4px;
  color: #9ca3af;
  font-weight: 600;
  text-transform: capitalize;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  background: #1f2937;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -2px 0 rgba(0, 0, 0, 0.3);
  width: 74px;
  min-width: 74px;
}

.cal-name {
  text-align: left !important;
  min-width: 160px;
  padding: 12px 16px !important;
  color: #e5e7eb;
  font-weight: 600;
  background: #1f2937;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

.cal-group-header {
  height: 40px;
}

.cal-group-header td {
  text-align: left !important;
  padding: 24px 10px 12px 10px !important;
  color: var(--txt-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  background: transparent !important;
  box-shadow: none !important;
}

.cal-cell {
  width: 44px;
  height: 44px;
  min-width: 44px;
  background: #13151a;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8), inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}

.cal-cell:hover {
  filter: brightness(1.15);
  z-index: 2;
}

/* Crosshair Highlight: Row */
.cal-table tr:hover .cal-cell,
.cal-table tr:hover .cal-name {
  background-color: #1e2533 !important;
}

/* Crosshair Highlight: Column (using pseudo-element) */
.cal-cell:hover::before,
.cal-table th:hover::before {
  content: "";
  position: absolute;
  top: -1000px;
  bottom: -1000px;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.04);
  z-index: -1;
  pointer-events: none;
  border-radius: 4px;
}

/* Active Cell (intersection) */
.cal-cell:hover {
  background-color: #2d3748 !important;
  box-shadow: 0 0 15px var(--blue-glow), inset 0 2px 5px rgba(0,0,0,0.5);
}

/* Base button inside cell */
.cal-icon-wrapper {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

/* Status: Paid (Green Check) */
.cal-cell.paid .cal-icon-wrapper {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), inset 0 -2px 3px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(22, 163, 74, 0.3);
}

.icon-paid {
  color: #ffffff;
  stroke-width: 4;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}

/* Status: Unpaid (Red Cross) */
.cal-cell.unpaid .cal-icon-wrapper {
  background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), inset 0 -2px 3px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(220, 38, 38, 0.3);
}

.icon-unpaid {
  color: #ffffff;
  stroke-width: 4;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}

/* Status: N/A (Dash) */
.cal-cell.na .cal-icon-wrapper {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.icon-na {
  color: rgba(255, 255, 255, 0.4);
  stroke-width: 3;
}

.cal-icon {
  width: 22px;
  height: 22px;
}

/* Glassmorphism for the card containing the table */
.card {
  backdrop-filter: blur(10px);
  background: rgba(17, 24, 39, 0.8);
}



.yearly-notes:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-glow);
}

.notes-footer {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

.notes-hint {
  font-size: 0.8rem;
  color: var(--txt-muted);
}

.yearly-notes {
  width: 100%;
  min-height: 200px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--txt);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
}

.year-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.debt-quick-actions {
  display: flex;
  gap: .5rem;
  margin: .75rem 0;
}

.btn-sm {
  padding: .35rem .75rem;
  font-size: .8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition);
}

.btn-sm.btn-success {
  background: var(--green-glow);
  color: var(--green);
  border-color: var(--green);
}

.btn-sm.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--txt-muted);
}

.btn-sm:hover {
  filter: brightness(1.2);
}

.current-year {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blue);
  min-width: 60px;
  text-align: center;
}

.cal-table th.current-month {
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-dk) 100%) !important;
  color: #fff !important;
  box-shadow: 0 0 20px var(--blue-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  border-bottom: 2px solid #1e3a8a !important;
}

.cal-cell.current-month-col {
  background-color: rgba(59, 130, 246, 0.08) !important;
}

/* ── Theme: Light ────────────────────────────────────── */
body.theme-light {
  --bg: #f1f5f9;
  --bg2: #ffffff;
  --bg3: #f8fafc;
  --border: #e2e8f0;
  --border-lt: #cbd5e1;
  --txt: #0f172a;
  --txt-muted: #64748b;
  --txt-dim: #94a3b8;
  
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
  
  background-image: none;
}

body.theme-light .card,
body.theme-light .kpi-card,
body.theme-light .sidebar,
body.theme-light .modal,
body.theme-light .upcoming-item {
  box-shadow: var(--shadow);
}

body.theme-light .nav-link:hover {
  background: #f1f5f9;
}

body.theme-light .nav-link.active {
  background: rgba(59, 130, 246, 0.1);
}

body.theme-light input, 
body.theme-light select, 
body.theme-light textarea {
  background: #fff;
  border-color: #e2e8f0;
  color: #0f172a;
}

/* ── Sidebar Theme Toggle ───────────────────────────── */
.theme-toggle-wrap {
  padding: 0.5rem 1.2rem;
  border-top: 1px solid var(--border);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg3);
  border-radius: var(--radius);
  color: var(--txt-muted);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition);
}

.theme-toggle:hover {
  color: var(--txt);
  background: var(--border);
}

.theme-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
}

.theme-toggle .toggle-icon-dark { display: none; }
body.theme-light .theme-toggle .toggle-icon-light { display: none; }
body.theme-light .theme-toggle .toggle-icon-dark { display: block; }