/* ══════════════════════════════════════════════════════════════
   HomeVault — app stylesheet (mobile-first)
   ══════════════════════════════════════════════════════════════ */
:root {
  --primary:      #0f3b69;   /* primary dark blue (matches hv) */
  --primary-dark: #0b2f55;   /* gradient end */
  --primary-light:#1F4E8C;
  --sidebar:      #123a63;   /* sidebar blue */
  --accent:       #F59E0B;   /* accent orange */
  --bg:           #F3F6FA;   /* app background */
  --surface:      #FFFFFF;
  --text:         #102033;   /* primary text */
  --muted:        #64748B;
  --border:       #E2E8F0;
  --success:      #22C55E;
  --purple:       #9333EA;
  --pink:         #EC4899;
  --warn:         #F59E0B;
  --danger:       #EF4444;
  --radius:       14px;
  --radius-sm:    10px;
  --shadow:       0 1px 3px rgba(16,32,51,.06), 0 1px 2px rgba(16,32,51,.04);
  --shadow-md:    0 4px 16px rgba(16,32,51,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; font-size: 15px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth screens ────────────────────────────────────────────── */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.auth-card { background: var(--surface); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.2);
  padding: 36px 32px; width: 100%; max-width: 400px; }
.auth-card__brand { font-size: 24px; font-weight: 800; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.auth-card__logo { font-size: 28px; }
.auth-card__sub { color: var(--muted); font-size: 14px; margin: 6px 0 22px; }

/* ── Form fields ─────────────────────────────────────────────── */
.field { display: block; margin-bottom: 16px; }
.field__label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field__input, .field select, select.field__input, textarea.field__input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; min-height: 44px; }
.field__input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,59,103,.15); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border: none; border-radius: 10px; font-size: 14px; font-weight: 700;
  cursor: pointer; min-height: 44px; transition: opacity .15s, background .15s; }
.btn:hover { text-decoration: none; opacity: .9; }
.btn--primary { background: var(--primary); color: #fff; }
.btn__plus { color: var(--accent); font-weight: 800; font-size: 16px; line-height: 1; }
.btn--ghost { background: #fff; color: var(--primary); border: 1px solid var(--border); }
.btn--block { width: 100%; }

/* ── Flash messages ──────────────────────────────────────────── */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; font-weight: 500; }
.flash--success { background: #DCFCE7; color: #166534; }
.flash--error   { background: #FEE2E2; color: #991B1B; }
.flash--warn    { background: #FEF3C7; color: #92400E; }

/* ── App layout ──────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: #fff; width: 240px; flex-shrink: 0; display: flex; flex-direction: column;
  padding: 18px 12px; position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .25s; z-index: 50; }
.sidebar.is-open { transform: translateX(0); }
.sidebar__brand { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; padding: 8px 12px 18px; }
.sidebar__logo { font-size: 24px; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px;
  color: #CBD5E1; font-weight: 600; font-size: 14px; min-height: 44px; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--accent); color: var(--primary-dark); }
.nav-link__icon { font-size: 18px; width: 22px; text-align: center; }
.nav-link--logout { margin-top: 8px; color: #FCA5A5; }

.main { flex: 1; padding: 18px; margin-left: 0; width: 100%; }
.nav-toggle { position: fixed; top: 12px; right: 12px; z-index: 60; background: var(--primary); color: #fff;
  border: none; border-radius: 10px; width: 44px; height: 44px; font-size: 20px; cursor: pointer; }

/* ── Page header ─────────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-top: 48px; }
.page-title { font-size: 32px; font-weight: 800; letter-spacing: -.01em; }
.page-sub { color: var(--muted); font-size: 16px; font-weight: 600; margin-top: 6px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── KPI / stat cards ────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px;
  display: flex; align-items: center; gap: 15px; }
.stat__icon { flex-shrink: 0; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 21px; background: rgba(23,59,103,.10); color: var(--primary); }
.stat__icon--blue   { background: rgba(23,59,103,.10);  color: var(--primary); }
.stat__icon--orange { background: rgba(245,158,11,.14); color: var(--accent); }
.stat__icon--green  { background: rgba(34,197,94,.14);  color: var(--success); }
.stat__icon--purple { background: rgba(147,51,234,.12); color: var(--purple); }
.stat__icon--pink   { background: rgba(236,72,153,.12); color: var(--pink); }
.stat__icon--red    { background: rgba(239,68,68,.12);  color: var(--danger); }
.stat__body { min-width: 0; flex: 1; }
.stat__label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat__value { font-size: 26px; font-weight: 800; margin-top: 3px; line-height: 1.1; }
.stat__value--sm { font-size: 15px; }

.progress { height: 6px; background: var(--border); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--success); border-radius: 4px; }
.progress__bar.is-warn { background: var(--warn); }
.progress__bar.is-danger { background: var(--danger); }

/* ── Cards & grids ───────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card__title { font-size: 15px; font-weight: 700; }
.card__link { font-size: 13px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 18px; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 12px; background: #F8FAFC; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.ta-right { text-align: right; }
.strong { font-weight: 700; }
.muted { color: var(--muted); }
.chip { display: inline-block; padding: 5px 13px; border-radius: 20px; font-size: 12.5px; font-weight: 700;
  color: #fff; background: var(--chip, #64748B); }
.empty { color: var(--muted); text-align: center; padding: 24px; font-size: 14px; }

/* ── Buttons (variants/sizes) ────────────────────────────────── */
.btn--danger { background: var(--danger); color: #fff; }
.btn--accent { background: var(--accent); color: var(--primary-dark); }
.btn--sm { padding: 7px 12px; min-height: 36px; font-size: 13px; }

/* ── Expense detail hero header ──────────────────────────────── */
.exp-hero { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.exp-hero__main { flex: 1 1 240px; min-width: 0; }
.exp-hero__top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.exp-hero__title { font-size: 23px; font-weight: 800; line-height: 1.2; word-break: break-word; }
.exp-hero__meta { margin-top: 10px; font-size: 13px; color: #CBD5E1; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.exp-hero__amount { text-align: right; }
.exp-hero__amount-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #CBD5E1; }
.exp-hero__amount-value { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.exp-hero__actions { display: flex; gap: 8px; flex-basis: 100%; }
@media (min-width: 768px) { .exp-hero__actions { flex-basis: auto; } }

/* ── Filters bar ─────────────────────────────────────────────── */
.filters { padding: 16px 18px; }
.filters__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filters .field { margin-bottom: 0; }
.filters__actions { display: flex; gap: 8px; margin-top: 16px; }
.filters input[type="search"] {
  padding-left: 38px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 13px center;
}

/* ── Form layout ─────────────────────────────────────────────── */
.form-section { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.form-section:first-of-type { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.form .field { margin-bottom: 14px; }
textarea.field__input { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 8px; margin-top: 20px; }
.form-hint { font-size: 13px; color: var(--muted); background: #F8FAFC; border-radius: 8px; padding: 10px 12px; margin-top: 4px; }
.field__note { display: block; font-size: 12px; color: var(--warn); margin-top: 5px; }

/* ── Status badges ───────────────────────────────────────────── */
.badge { display: inline-block; padding: 5px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 700; }
.badge--reviewed { background: #DCFCE7; color: #166534; }
.badge--draft    { background: #FEF3C7; color: #92400E; }
.badge--archived { background: #E2E8F0; color: #475569; }

/* ── Key-value detail tables ─────────────────────────────────── */
.table--kv th { text-transform: none; background: transparent; color: var(--muted); font-weight: 600; width: 40%; }
.table--kv td { font-weight: 500; }
.row-total th, .row-total td { border-top: 2px solid var(--border); font-size: 16px; }

/* ── Action row + pager ──────────────────────────────────────── */
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; }
.actions-row form { margin: 0; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 4px; padding: 4px 2px; }
.pager__info { font-size: 13px; color: var(--muted); }
.pager__nav { display: flex; align-items: center; gap: 6px; }
.pager__btn { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px;
  padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); background: #fff; color: var(--text);
  font-size: 13px; font-weight: 700; }
.pager__btn:hover { border-color: var(--primary); text-decoration: none; }
.pager__btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager__btn.is-disabled { opacity: .4; pointer-events: none; }

/* ── Upload dropzone ─────────────────────────────────────────── */
.dropzone { position: relative; border: 2px dashed var(--border); border-radius: 12px;
  background: #F8FAFC; padding: 30px 16px; text-align: center; transition: border-color .15s, background .15s; }
.dropzone.is-drag { border-color: var(--primary); background: #EAF0F6; }
.dropzone__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 1; }
.dropzone__prompt { display: flex; flex-direction: column; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.dropzone__icon { font-size: 30px; }
.dropzone__link { color: var(--primary); font-weight: 700; text-decoration: underline; }
.dropzone__preview { display: flex; align-items: center; gap: 12px; justify-content: center; flex-wrap: wrap; }
.dropzone__preview img { max-height: 96px; border-radius: 8px; border: 1px solid var(--border); }
.dropzone__clear { position: relative; z-index: 2; background: var(--danger); color: #fff; border: none;
  border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: 13px; line-height: 1; }

/* ── Expense transaction list (card rows) ────────────────────── */
.exp-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.exp-item { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 15px 18px 15px 24px; transition: box-shadow .15s; }
.exp-item:hover { box-shadow: var(--shadow-md); }
.exp-item__bar { position: absolute; left: 0; top: 10px; bottom: 10px; width: 5px;
  border-radius: 0 4px 4px 0; background: var(--c, #64748B); }
.exp-item__main { flex: 1 1 230px; min-width: 0; }
.exp-item__title { font-weight: 800; font-size: 15.5px; color: var(--text); display: inline-block; }
.exp-item__title:hover { color: var(--primary); text-decoration: none; }
.exp-item__sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.exp-item__tags { display: flex; flex-wrap: wrap; gap: 8px; }
.exp-item__amount { font-size: 18px; font-weight: 800; color: var(--text); white-space: nowrap; min-width: 78px; text-align: right; }
.exp-item__actions { display: flex; gap: 8px; }

/* Receipt indicator pill */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 20px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill--receipt { background: rgba(34,197,94,.12); color: #15803D; }
.pill--none { background: #EEF2F6; color: var(--muted); }

/* Mobile: amount pushes to the right of its wrap row. */
@media (max-width: 899px) {
  .exp-item__amount { margin-left: auto; }
}

/* Desktop: align every group into even columns (like the mockup). */
@media (min-width: 900px) {
  .exp-item { display: grid; flex-wrap: nowrap;
    grid-template-columns: minmax(0, 2.3fr) 1.4fr 1.3fr 0.9fr auto;
    column-gap: 16px; align-items: center; }
  .exp-item__tags { justify-self: start; }
  .exp-item__amount { justify-self: end; min-width: 0; }
  .exp-item__actions { justify-self: end; }
}

/* ── Line-item add form ──────────────────────────────────────── */
.item-form__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.item-form .field { margin-bottom: 12px; }

/* ── Receipt → expense suggestions ───────────────────────────── */
.suggest { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; background: #F8FAFC; }
.suggest__head { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.suggest__row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.suggest__row:first-of-type { border-top: none; }
.suggest__info { font-size: 13px; }
.suggest__row form { margin: 0; }

/* ── Receipts ────────────────────────────────────────────────── */
.receipt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.receipt-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; background: #fff; color: inherit; }
.receipt-card:hover { text-decoration: none; box-shadow: var(--shadow); border-color: var(--primary); }
.receipt-card__thumb { height: 140px; background: #F1F5F9; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.receipt-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.receipt-card__pdf { font-size: 15px; font-weight: 700; color: var(--muted); }
.receipt-card__body { padding: 10px 12px; }
.receipt-card__name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.receipt-card__meta { font-size: 12px; color: var(--muted); margin: 3px 0 6px; }

.receipt-preview { text-align: center; }
.receipt-preview img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.receipt-frame { width: 100%; height: 480px; border: 1px solid var(--border); border-radius: 8px; }

/* ── Tablet / desktop ────────────────────────────────────────── */
@media (min-width: 768px) {
  .stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .filters__grid { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .receipt-grid { grid-template-columns: repeat(4, 1fr); }
  .item-form__grid { grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr; }
}
@media (min-width: 1024px) {
  .sidebar { position: static; transform: none; }
  .nav-toggle { display: none; }
  .main { padding: 28px 32px; }
  .page-head { padding-top: 0; }
}

/* ── Password strength meter (assets/js/password-strength.js) ─────────── */
.hv-pw-meter { margin-top: 8px; }
.hv-pw-meter__track {
  height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden;
}
.hv-pw-meter__fill {
  display: block; height: 100%; width: 0; border-radius: 999px;
  transition: width .2s ease, background-color .2s ease; background: #ef4444;
}
.hv-pw-meter__fill[data-level="1"] { background: #ef4444; }
.hv-pw-meter__fill[data-level="2"] { background: #f59e0b; }
.hv-pw-meter__fill[data-level="3"] { background: #3b82f6; }
.hv-pw-meter__fill[data-level="4"] { background: #16a34a; }
.hv-pw-meter__label {
  margin-top: 4px; font-size: 12px; font-weight: 700; color: #64748b;
}

/* ── Accessibility (Phase D) — visible keyboard focus + reduced motion ──── */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
