/* ============================================================
   DESIGN TOKENS
============================================================ */
:root {
  --ink:             #08080E;
  --surface:         #0F0F1A;
  --card:            #13131F;
  --term:            #050508;
  --border:          #1E1E35;
  --rim:             #2A2A45;

  --primary:         #7B3FE4;
  --primary-dim:     #5A2DB0;
  --primary-glow:    #9B5FFF;

  --cyan:            #00D4FF;
  --cyan-dim:        #00A3CC;

  --success:         #22C55E;
  --warning:         #F59E0B;
  --danger:          #EF4444;
  --orange:          #F97316;

  --text:            #F0EEFF;
  --text-secondary:  #A9A8CC;
  --dim:             #8B8AB0;
  --muted:           #4A4A6A;
}

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

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: 'Sora', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--ink);
  background-image: radial-gradient(circle, #2A2A45 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100dvh;
  /* Reserve space for sticky summary bar */
  padding-bottom: 130px;
}

::selection {
  background: var(--primary);
  color: #fff;
}

/* Scrollbars */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: var(--surface); }
::-webkit-scrollbar-thumb  { background: var(--rim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-dim); }

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  color: var(--cyan);
  background: rgba(0,212,255,0.07);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ============================================================
   TYPOGRAPHY HELPERS
============================================================ */
.mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

.color-cyan    { color: var(--cyan) !important; }
.color-success { color: var(--success) !important; }
.color-warning { color: var(--warning) !important; }
.color-danger  { color: var(--danger) !important; }
.color-dim     { color: var(--dim); }
.color-muted   { color: var(--muted); }

/* ============================================================
   LAYOUT
============================================================ */
.page-wrapper {
  max-width: 1152px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 640px) {
  .page-wrapper { padding: 0 24px; }
}

@media (min-width: 1024px) {
  .page-wrapper {
    max-width: none;
    width: 100%;
    padding: 0 24px;
  }
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 0;
}

@media (min-width: 1024px) {
  .main-content {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }

  #section-salary,
  #section-savings,
  #section-budget,
  #section-loans {
    grid-column: span 1;
  }

  .table-wrap {
    max-height: 420px;
    overflow-y: auto;
  }
}

@media (max-width: 1023px) {
  .main-content {
    display: flex;
    flex-direction: column;
  }
}

/* ============================================================
   STICKY HEADER
============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  background: rgba(8, 8, 14, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.header-inner {
  max-width: 1152px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

@media (min-width: 640px) {
  .header-inner { padding: 0 24px; }
}

@media (min-width: 1024px) {
  .header-inner {
    max-width: none;
    width: 100%;
    padding: 0 24px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
  flex-wrap: wrap;
}

.brand-icon {
  width: 30px;
  height: 30px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.brand-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--dim);
  display: none;
  margin-left: 2px;
}

@media (min-width: 500px) {
  .brand-subtitle { display: inline; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   CARDS
============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  animation: fadeInUp 0.3s ease-out both;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}

.card-title-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-cyan   { background: rgba(0,212,255,0.12); color: var(--cyan); }
.icon-green  { background: rgba(34,197,94,0.12); color: var(--success); }
.icon-yellow { background: rgba(245,158,11,0.12); color: var(--warning); }
.icon-red    { background: rgba(239,68,68,0.12); color: var(--danger); }
.icon-purple { background: rgba(123,63,228,0.12); color: var(--primary-glow); }

.card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-total {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
}

.card-body-pad {
  padding: 16px 18px;
}

.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: rgba(15,15,26,0.6);
}

/* ============================================================
   TABLES
============================================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

/* Keep tables readable on small screens: use horizontal scroll instead of cramping */
.table-salary { min-width: 760px; }
.table-savings { min-width: 520px; }
.table-budget { min-width: 760px; }
.table-loans { min-width: 1120px; }

thead tr {
  background: var(--surface);
}

thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  line-height: 1.25;
  border-bottom: 1px solid var(--border);
}

thead th:first-child { border-radius: 0; }

tbody tr {
  border-bottom: 1px solid rgba(30, 30, 53, 0.7);
  transition: background 0.12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.018); }

td {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
  overflow-wrap: normal;
  word-break: normal;
}

/* Table-specific width guidance by data type */
.table-salary th:nth-child(1) { width: 34%; }
.table-salary th:nth-child(2) { width: 16%; }
.table-salary th:nth-child(3) { width: 14%; }
.table-salary th:nth-child(4) { width: 18%; }
.table-salary th:nth-child(5) { width: 56px; }
.table-salary th:nth-child(1), .table-salary td:nth-child(1) { min-width: 220px; }
.table-salary th:nth-child(2), .table-salary td:nth-child(2) { min-width: 120px; }
.table-salary th:nth-child(3), .table-salary td:nth-child(3) { min-width: 120px; }
.table-salary th:nth-child(4), .table-salary td:nth-child(4) { min-width: 140px; }

.table-savings th:nth-child(1) { width: 62%; }
.table-savings th:nth-child(2) { width: 24%; }
.table-savings th:nth-child(3) { width: 56px; }
.table-savings th:nth-child(1), .table-savings td:nth-child(1) { min-width: 260px; }
.table-savings th:nth-child(2), .table-savings td:nth-child(2) { min-width: 140px; }

.table-budget th:nth-child(1) { width: 48px; }
.table-budget th:nth-child(2) { width: 46%; }
.table-budget th:nth-child(3) { width: 18%; }
.table-budget th:nth-child(4) { width: 14%; }
.table-budget th:nth-child(5) { width: 56px; }
.table-budget th:nth-child(2), .table-budget td:nth-child(2) { min-width: 260px; }
.table-budget th:nth-child(3), .table-budget td:nth-child(3) { min-width: 120px; }
.table-budget th:nth-child(4), .table-budget td:nth-child(4) { min-width: 100px; }

.table-loans th:nth-child(1) { width: 25%; }
.table-loans th:nth-child(2) { width: 10%; }
.table-loans th:nth-child(3) { width: 12%; }
.table-loans th:nth-child(4) { width: 12%; }
.table-loans th:nth-child(5) { width: 12%; }
.table-loans th:nth-child(6) { width: 15%; }
.table-loans th:nth-child(7) { width: 10%; }
.table-loans th:nth-child(8) { width: 86px; }
.table-loans th:nth-child(1), .table-loans td:nth-child(1) { min-width: 240px; }
.table-loans th:nth-child(2), .table-loans td:nth-child(2) { min-width: 120px; }
.table-loans th:nth-child(3), .table-loans td:nth-child(3) { min-width: 130px; }
.table-loans th:nth-child(4), .table-loans td:nth-child(4) { min-width: 120px; }
.table-loans th:nth-child(5), .table-loans td:nth-child(5) { min-width: 120px; }
.table-loans th:nth-child(6), .table-loans td:nth-child(6) { min-width: 180px; }
.table-loans th:nth-child(7), .table-loans td:nth-child(7) { min-width: 120px; }
.table-loans th:nth-child(8), .table-loans td:nth-child(8) { min-width: 100px; }

/* Two-word headers should wrap naturally on space, single words remain intact */
.table-salary th,
.table-savings th,
.table-budget th,
.table-loans th {
  white-space: normal;
}

#import-file-meta {
  margin-top: 10px;
}

/* Paid row strikethrough */
tr.row-paid td:not(.no-strike) {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--rim);
}
tr.row-paid {
  background: rgba(34,197,94,0.06);
}

/* Empty state row */
.empty-row td {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* Column helpers */
.col-check  { width: 48px; }
.col-actions { width: 48px; }

.col-hide-sm { display: none; }
@media (min-width: 640px) {
  .col-hide-sm { display: table-cell; }
}

/* ============================================================
   INLINE INPUTS (inside table cells)
============================================================ */
.input-inline {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 13px;
  padding: 5px 8px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.input-inline:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123,63,228,0.15);
}

.input-inline::placeholder {
  color: var(--muted);
  font-style: italic;
}

.input-inline.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* Select inside table cells */
.select-inline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  width: 100%;
  max-width: 100%;
}

.select-inline:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123,63,228,0.15);
}

.select-inline option {
  background: var(--surface);
  color: var(--text);
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 8px 16px;
  white-space: normal;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, border-color 0.15s, opacity 0.15s;
  min-height: 34px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Icons inside buttons must not capture clicks */
.btn i[data-lucide],
.btn-icon i[data-lucide] {
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-glow);
  box-shadow: 0 0 18px rgba(123,63,228,0.4);
}
.btn-primary:active:not(:disabled) {
  background: var(--primary-dim);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface);
  border-color: var(--rim);
}
.btn-ghost:active:not(:disabled) {
  background: var(--border);
}

/* Dashed add */
.btn-add {
  width: 100%;
  background: rgba(123,63,228,0.06);
  color: var(--primary-glow);
  border: 1px dashed rgba(123,63,228,0.3);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
}
.btn-add:hover {
  background: rgba(123,63,228,0.12);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(123,63,228,0.2);
}

/* Icon button (32x32) */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--dim);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.btn-icon:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.1);
}

/* Loan → Budget button */
.btn-to-budget {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid rgba(0,212,255,0.25);
  background: rgba(0,212,255,0.07);
  color: var(--cyan);
  transition: background 0.15s, border-color 0.15s;
}
.btn-to-budget:hover {
  background: rgba(0,212,255,0.15);
  border-color: var(--cyan);
}
.btn-to-budget.added {
  border-color: rgba(34,197,94,0.25);
  background: rgba(34,197,94,0.07);
  color: var(--success);
  cursor: default;
  pointer-events: none;
}

/* ============================================================
   CHECKBOX / PAID TOGGLE
============================================================ */
.paid-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--rim);
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  margin: auto;
}
.paid-check:hover {
  border-color: var(--success);
}
.paid-check:checked {
  border-color: var(--success);
  background: var(--success);
  background-image: linear-gradient(135deg, var(--success), #4ade80);
}
.paid-check:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
}
.paid-check:checked::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(5px, 1px) rotate(45deg);
}

/* ============================================================
   PROGRESS BAR
============================================================ */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 100px;
}
.progress-track {
  height: 5px;
  background: var(--rim);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--primary-glow));
  transition: width 0.5s ease;
}
.progress-fill.done {
  background: linear-gradient(90deg, var(--success), #4ade80);
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--dim);
}

/* ============================================================
   BADGES
============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-cyan    { background: rgba(0,212,255,0.12); color: var(--cyan); }
.badge-green   { background: rgba(34,197,94,0.12); color: var(--success); }
.badge-yellow  { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge-red     { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-purple  { background: rgba(123,63,228,0.12); color: var(--primary-glow); }
.badge-muted   { background: rgba(74,74,106,0.3); color: var(--dim); }

/* ============================================================
   PAYMENT HISTORY (under loan rows)
============================================================ */
.payment-history-row td {
  padding: 6px 14px 10px;
  background: rgba(5,5,8,0.5);
  border-top: 1px dashed rgba(30,30,53,0.8);
}
.payment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.payment-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.2);
  color: var(--success);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
}
.payment-chip-date {
  color: var(--muted);
  font-size: 9px;
}

/* ============================================================
   STICKY SUMMARY BAR
============================================================ */
.summary-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(8,8,14,0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
}

@media (min-width: 640px) {
  .summary-bar { padding: 10px 24px; }
}

.summary-inner {
  max-width: 1152px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 16px;
}

@media (min-width: 640px) {
  .summary-inner { grid-template-columns: repeat(6, 1fr); }
}

@media (min-width: 1024px) {
  .summary-inner {
    max-width: none;
    width: 100%;
  }
}

.sum-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sum-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  white-space: normal;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.sum-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 400px) {
  .sum-value { font-size: 11px; }
}

/* ============================================================
   DROP ZONE
============================================================ */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: rgba(15,15,26,0.5);
}
.drop-zone:hover,
.drop-zone:focus {
  border-color: var(--primary-dim);
  background: rgba(123,63,228,0.05);
  outline: none;
}
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(123,63,228,0.1);
  box-shadow: 0 0 20px rgba(123,63,228,0.2);
}
.drop-zone.has-file {
  border-color: rgba(34,197,94,0.65);
  background: rgba(34,197,94,0.1);
  box-shadow: inset 0 0 0 1px rgba(34,197,94,0.35), 0 0 20px rgba(34,197,94,0.18);
}
.drop-zone.has-file .drop-zone-icon {
  color: var(--success);
}
.drop-zone.has-file .drop-zone-title {
  color: var(--success);
  font-weight: 600;
}
.drop-zone.has-file .drop-zone-sub {
  color: var(--text-secondary);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  font-size: 0;
}
.drop-zone-icon {
  color: var(--dim);
  margin-bottom: 12px;
}
.drop-zone-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.drop-zone-title strong { color: var(--primary-glow); }
.drop-zone-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.drop-zone-badges {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ============================================================
   INFO BOX
============================================================ */
.info-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(0,212,255,0.05);
  border: 1px solid rgba(0,212,255,0.12);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  color: var(--text-secondary);
}
.info-box i {
  color: var(--cyan);
}

/* ============================================================
   APP DISCLAIMER
============================================================ */
.app-disclaimer {
  margin: 14px 0 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(34,197,94,0.22);
  background: rgba(34,197,94,0.06);
  color: var(--text-secondary);
}

.app-disclaimer-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--success);
  margin: 0 0 4px;
}

.app-disclaimer-text {
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
}

/* ============================================================
   MODAL
============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInOverlay 0.2s ease-out;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
  background: var(--card);
  border: 1px solid var(--rim);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7), 0 0 30px rgba(123,63,228,0.1);
  animation: slideUp 0.25s ease-out;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   FORM ELEMENTS (modal)
============================================================ */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123,63,228,0.18);
}
.form-input::placeholder { color: var(--muted); }

.form-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
}

.form-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  user-select: none;
}

.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ============================================================
   CALCULATOR FAB
============================================================ */
.calc-fab {
  position: fixed;
  right: 18px;
  bottom: 92px;
  z-index: 90;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(0,212,255,0.35);
  background: linear-gradient(145deg, rgba(0,212,255,0.2), rgba(123,63,228,0.22));
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45), 0 0 20px rgba(0,212,255,0.2);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.calc-fab:hover {
  transform: translateY(-1px);
  border-color: rgba(0,212,255,0.7);
  box-shadow: 0 10px 26px rgba(0,0,0,0.45), 0 0 24px rgba(0,212,255,0.28);
}

.calculator-panel {
  position: fixed;
  right: 18px;
  bottom: 154px;
  z-index: 95;
  width: min(92vw, 300px);
  background: var(--card);
  border: 1px solid var(--rim);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.55);
  padding: 10px;
}

.calculator-panel[hidden] { display: none; }

.calculator-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.calculator-display {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: right;
  padding: 8px 12px;
  margin-bottom: 8px;
  min-height: 66px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.calc-display-expr {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.2;
  min-height: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-display-result {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.calculator-btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  border-radius: 8px;
  height: 36px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.calculator-btn.op {
  color: var(--cyan);
  border-color: rgba(0,212,255,0.3);
}

.calculator-btn.eq {
  color: #fff;
  border-color: rgba(123,63,228,0.5);
  background: linear-gradient(145deg, var(--primary), var(--primary-glow));
}

.calculator-btn:hover {
  background: rgba(123,63,228,0.12);
}

@media (max-width: 860px) {
  .calc-fab { bottom: 100px; right: 12px; }
  .calculator-panel { right: 12px; bottom: 162px; }
}

/* ============================================================
   TOAST NOTIFICATIONS
============================================================ */
#toast-container {
  position: fixed;
  top: 68px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 340px;
  width: calc(100% - 32px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid;
  font-size: 13px;
  backdrop-filter: blur(12px);
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease-out;
  line-height: 1.4;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.out {
  opacity: 0;
  transform: translateX(16px);
}
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-msg  { flex: 1; }

.toast-success { background: rgba(34,197,94,0.12);  border-color: rgba(34,197,94,0.3);  color: var(--success); }
.toast-error   { background: rgba(239,68,68,0.12);  border-color: rgba(239,68,68,0.3);  color: var(--danger);  }
.toast-info    { background: rgba(0,212,255,0.09);  border-color: rgba(0,212,255,0.22); color: var(--cyan);    }

/* ============================================================
   ANIMATIONS
============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}
@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0);    }
}

/* ============================================================
   RESPONSIVE — MOBILE OVERRIDES
============================================================ */
@media (max-width: 480px) {
  body { font-size: 13px; padding-bottom: 150px; }

  td { padding: 8px 10px; }
  thead th { padding: 8px 10px; }
  .card-header { padding: 12px 14px; }
  .card-footer { padding: 10px 14px; }
  .card-body-pad { padding: 14px; }

  .btn { padding: 7px 13px; font-size: 12px; }
  .btn-add { font-size: 12px; }

  .summary-inner {
    grid-template-columns: repeat(3, minmax(92px, 1fr));
    gap: 8px 10px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

@media (max-width: 860px) {
  .header-inner {
    flex-wrap: wrap;
    justify-content: center;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .header-actions {
    width: 100%;
    justify-content: center;
  }

  .app-header {
    height: auto;
    min-height: 56px;
  }

  .main-content {
    gap: 14px;
  }
}

@media (max-width: 1023px) {
  .summary-inner {
    grid-template-columns: repeat(3, minmax(92px, 1fr));
    gap: 8px 10px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
}

.stack-layout .summary-inner {
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 8px 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

@media (max-width: 560px) {
  .stack-layout .summary-inner { grid-template-columns: repeat(3, minmax(92px, 1fr)); }
}

/* ============================================================
   UTILITY CLASSES
============================================================ */
.text-right { text-align: right; }
.nowrap     { white-space: nowrap; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}
