/* ==========================================================================
   saveUrMoney — style.css
   Base styles: colors, typography, layout, and all UI components.
   Design: Dark Minimalist — "Know where your money goes."
   Breakpoint-specific overrides live in responsive.css.
   ========================================================================== */


  :root {
    --bg: #0D0D0D;
    --card: #181818;
    --input: #242424;
    --input-border: #2A2A2A;
    --text-primary: #F5F5F5;
    --text-secondary: #A0A0A0;
    --text-tertiary: #6B6B6B;
    --income: #10B981;
    --income-dim: #0B3B2C;
    --expense: #EF4444;
    --expense-dim: #4A1515;
    --normal: #3B82F6;
    --warn: #F59E0B;
    --radius: 12px;
    --radius-sm: 8px;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html { -webkit-text-size-adjust: 100%; }

  body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    min-height: 100vh;
    padding-bottom: 96px;
    overflow-x: hidden;
  }

  .container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 16px 0;
  }

  /* ---------- Header ---------- */
  header.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0 20px;
  }

  .brand {
    display: flex;
    align-items: baseline;
    gap: 2px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--income), #0a8f68);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 9px;
    flex-shrink: 0;
  }

  .brand-mark svg { width: 15px; height: 15px; }

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

  .brand-name .dim { color: var(--text-secondary); font-weight: 600; }

  .header-actions { display: flex; gap: 8px; }

  .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--card);
    border: 1px solid var(--input-border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .icon-btn:hover { background: var(--input); color: var(--text-primary); }
  .icon-btn svg { width: 17px; height: 17px; }

  /* ---------- Summary Card ---------- */
  .summary-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
  }

  .summary-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
  }

  .summary-balance {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    margin-bottom: 18px;
    word-break: break-all;
  }

  .summary-balance.negative { color: var(--expense); }

  .summary-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .summary-stat {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--input);
    border-radius: var(--radius-sm);
    padding: 12px;
  }

  .stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .stat-icon.income { background: var(--income-dim); color: var(--income); }
  .stat-icon.expense { background: var(--expense-dim); color: var(--expense); }
  .stat-icon svg { width: 15px; height: 15px; }

  .stat-text { min-width: 0; }
  .stat-text .label { font-size: 11px; color: var(--text-secondary); margin-bottom: 2px; }
  .stat-text .value {
    font-size: 14.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .stat-text .value.income { color: var(--income); }
  .stat-text .value.expense { color: var(--expense); }

  /* ---------- Budget Card ---------- */
  .budget-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
  }

  .budget-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
  }

  .budget-title { font-size: 16px; font-weight: 600; }

  .budget-edit {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12.5px;
    cursor: pointer;
    padding: 4px 0;
  }
  .budget-edit:hover { color: var(--text-primary); }

  .budget-sub {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 16px;
  }

  .budget-figures {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
  }

  .budget-spent {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .budget-total {
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
  }

  .progress-track {
    width: 100%;
    height: 10px;
    background: var(--input);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 12px;
  }

  .progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease, background 0.4s ease;
  }

  .budget-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 999px;
  }

  .status-dot { width: 6px; height: 6px; border-radius: 50%; }

  .status-pill.hemat { background: var(--income-dim); color: var(--income); }
  .status-pill.hemat .status-dot { background: var(--income); }
  .status-pill.normal { background: #0F2540; color: var(--normal); }
  .status-pill.normal .status-dot { background: var(--normal); }
  .status-pill.boros { background: #40300a; color: var(--warn); }
  .status-pill.boros .status-dot { background: var(--warn); }
  .status-pill.melebihi { background: var(--expense-dim); color: var(--expense); }
  .status-pill.melebihi .status-dot { background: var(--expense); }

  .budget-pct {
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
  }

  .budget-empty {
    text-align: center;
    padding: 8px 0 4px;
  }
  .budget-empty p { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
  .btn-set-budget {
    background: var(--income);
    color: #052A1E;
    border: none;
    font-weight: 700;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }

  /* ---------- Section heads ---------- */
  .section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 22px 0 12px;
  }
  .section-title { font-size: 16px; font-weight: 600; }
  .section-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12.5px;
    cursor: pointer;
  }
  .section-link:hover { color: var(--text-primary); }

  /* ---------- Category breakdown ---------- */
  .category-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 14px;
  }

  .cat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
  }

  .cat-info { flex: 1; min-width: 0; }
  .cat-name-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
  }
  .cat-name { font-weight: 600; }
  .cat-amount { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
  .cat-bar-track {
    height: 6px;
    background: var(--input);
    border-radius: 999px;
    overflow: hidden;
  }
  .cat-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--cat-color, var(--income));
  }

  .empty-inline {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 18px 0;
  }

  /* ---------- Transaction list ---------- */
  .tx-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 14px;
  }

  .tx-filter-bar {
    display: flex;
    gap: 6px;
    padding: 14px 14px 0;
  }
  .filter-chip {
    background: var(--input);
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 13px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .filter-chip.active { background: var(--text-primary); color: #0D0D0D; }

  .tx-list { padding: 6px 8px 8px; }

  .tx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    cursor: default;
    position: relative;
  }
  .tx-item:not(:last-child) { border-bottom: 1px solid #212121; }

  .tx-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
  }
  .tx-icon.income { background: var(--income-dim); }
  .tx-icon.expense { background: var(--expense-dim); }

  .tx-detail { flex: 1; min-width: 0; }
  .tx-cat { font-size: 13.5px; font-weight: 600; }
  .tx-meta {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
  }

  .tx-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

  .tx-amount {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .tx-amount.income { color: var(--income); }
  .tx-amount.expense { color: var(--expense); }

  .tx-menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 2px;
  }
  .tx-menu-btn:hover { background: var(--input); color: var(--text-primary); }
  .tx-menu-btn svg { width: 15px; height: 15px; }

  .tx-actions-popup {
    position: absolute;
    right: 8px;
    top: 100%;
    margin-top: 4px;
    background: #202020;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    z-index: 20;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    min-width: 120px;
  }
  .tx-actions-popup button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    padding: 10px 14px;
    cursor: pointer;
    text-align: left;
  }
  .tx-actions-popup button:hover { background: var(--input); }
  .tx-actions-popup button.danger { color: var(--expense); }
  .tx-actions-popup button svg { width: 14px; height: 14px; }

  /* ---------- FAB ---------- */
  .fab {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    width: min(calc(100% - 32px), 768px);
    display: flex;
    justify-content: flex-end;
    pointer-events: none;
    z-index: 30;
  }
  .fab button {
    pointer-events: all;
    background: var(--income);
    color: #052A1E;
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
    transition: transform 0.15s;
  }
  .fab button:active { transform: scale(0.94); }
  .fab button svg { width: 24px; height: 24px; }

  /* ---------- Modal / Sheet ---------- */
  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
  }
  .overlay.open { display: flex; }

  .sheet {
    background: #161616;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    animation: slideUp 0.22s ease;
  }

  @keyframes slideUp {
    from { transform: translateY(24px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
  }
  .sheet-title { font-size: 17px; font-weight: 700; }
  .sheet-close {
    background: var(--input);
    border: none;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .sheet-close svg { width: 14px; height: 14px; }

  .type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--input);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 18px;
  }
  .type-toggle button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 700;
    padding: 10px 0;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .type-toggle button.active.expense { background: var(--expense); color: #2A0A0A; }
  .type-toggle button.active.income { background: var(--income); color: #052A1E; }

  .field { margin-bottom: 14px; }
  .field label {
    display: block;
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
  }

  .amount-input-wrap {
    display: flex;
    align-items: center;
    background: var(--input);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
  }
  .amount-prefix { color: var(--text-secondary); font-size: 20px; font-weight: 700; margin-right: 4px; }
  .amount-input-wrap input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 13px 0;
    min-width: 0;
    font-family: inherit;
  }

  input[type=text], input[type=date], select, textarea {
    width: 100%;
    background: var(--input);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    padding: 12px 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
  }
  input[type=text]:focus, input[type=date]:focus, select:focus, textarea:focus {
    border-color: var(--text-secondary);
  }
  select { appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23A0A0A0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 34px;
  }

  .field-error {
    color: var(--expense);
    font-size: 12px;
    margin-top: 6px;
    display: none;
  }
  .field-error.show { display: block; }
  .field.has-error input, .field.has-error select {
    border-color: var(--expense);
  }

  .btn-primary {
    width: 100%;
    background: var(--income);
    color: #052A1E;
    border: none;
    font-size: 15px;
    font-weight: 700;
    padding: 15px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 4px;
    transition: opacity 0.15s;
  }
  .btn-primary:active { opacity: 0.85; }
  .btn-primary.is-expense { background: var(--expense); color: #2A0A0A; }

  .btn-secondary {
    width: 100%;
    background: var(--input);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    font-size: 14px;
    font-weight: 600;
    padding: 13px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 8px;
  }

  .confirm-box { text-align: center; padding: 6px 4px 4px; }
  .confirm-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--expense-dim);
    color: var(--expense);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
  }
  .confirm-icon svg { width: 24px; height: 24px; }
  .confirm-box p.q { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
  .confirm-box p.d { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
  .btn-danger {
    width: 100%;
    background: var(--expense);
    color: #2A0A0A;
    border: none;
    font-size: 14.5px;
    font-weight: 700;
    padding: 13px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }

  .toast {
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: #232323;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    padding: 11px 18px;
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 200;
    white-space: nowrap;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* ---------- Tablet / Desktop dashboard split ---------- */

  ::selection { background: var(--income); color: #052A1E; }
  
