/* Handa Crafts Brand Book — Light-Mode Only, Zero Gradients, Organic S-Curve Motifs */
:root {
  color-scheme: light only;
  /* Primary Palette */
  --nata: #FAF5EF;
  --white: #FFFFFF;
  --night: #1B1D32;
  --prussian: #313456;
  --cherrywood: #6C1807;
  --maroon: #3D0A00;
  --grass: #486F44;
  --forest: #122510;
  /* Secondary Palette */
  --cloud: #A6D6E5;
  --cloud-soft: #DFEFF5;
  --glacier: #66B1C9;
  --fern: #93CC8E;
  --garden: #64A45D;
  --goldenrod: #FFD571;
  --goldenrod-soft: #FFF4D6;
  --sunshine: #DCAD3F;
  --orange: #F26E54;
  --red: #821802;
  /* Borders & Surfaces */
  --border: #E6DDD2;
  --muted: #5C5F78;
  --radius: 14px;
  --radius-sm: 10px;
}

/* Optional Brand Book Custom Font Slots — drop .woff2 files into /public/fonts/ */
@font-face {
  font-family: "Sandigan";
  src: url("/fonts/Sandigan-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Corsair PE";
  src: url("/fonts/CorsairPE-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

html, body {
  background-color: var(--nata);
  color: var(--night);
  font-family: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  line-height: 1.35;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.font-display {
  font-family: "Sandigan", "DM Serif Display", Georgia, serif;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.font-accent {
  font-family: "Corsair PE", "Hanken Grotesk", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.num { font-variant-numeric: tabular-nums; }

.hidden { display: none !important; }

/* ---------- PIN LOCK OVERLAY ---------- */
.lock-screen {
  position: fixed;
  inset: 0;
  background: var(--nata);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border: 2px solid var(--night);
  border-radius: 18px;
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
}

.lock-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.lock-header img { width: 48px; height: 48px; border-radius: 10px; }

.security-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cloud-soft);
  color: var(--night);
  border: 1px solid var(--glacier);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 18px;
}

.partner-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.partner-btn {
  border: 2px solid var(--border);
  background: var(--nata);
  color: var(--night);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.partner-btn.active {
  background: var(--night);
  color: var(--nata);
  border-color: var(--night);
}

.pin-input {
  width: 100%;
  text-align: center;
  font-size: 24px;
  letter-spacing: 0.35em;
  padding: 12px;
  border: 2px solid var(--night);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--night);
  margin-bottom: 14px;
}

/* ---------- APP SHELL (RESPONSIVE MOBILE + PC) ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  display: none;
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 84px; /* space for mobile bottom nav */
}

.topbar {
  background: var(--night);
  color: var(--nata);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand img { width: 34px; height: 34px; border-radius: 8px; }

.topbar-title { font-size: 19px; color: var(--nata); }
.topbar-sub { font-size: 11px; color: var(--cloud); letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; }

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

.wave-divider {
  width: 100%;
  height: 12px;
  display: block;
  background: var(--nata);
}

.content-wrap {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 16px 32px;
}

/* Mobile Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 2px solid var(--night);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 50;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 10px;
}

.nav-item.active {
  color: var(--night);
  background: var(--goldenrod-soft);
}

.nav-item.cta-log {
  background: var(--night);
  color: var(--goldenrod);
  margin: 0 4px;
}

/* Desktop Sidebar (>= 1024px) */
@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    width: 248px;
    flex-shrink: 0;
    background: var(--night);
    color: var(--nata);
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 3px solid var(--prussian);
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--prussian);
    margin-bottom: 18px;
  }
  .sidebar-brand img { width: 42px; height: 42px; border-radius: 10px; }
  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
  }
  .side-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--cloud);
    border: none;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
  }
  .side-btn:hover { background: var(--prussian); color: var(--white); }
  .side-btn.active { background: var(--goldenrod); color: var(--night); }
  .side-btn.side-cta {
    background: var(--grass);
    color: var(--white);
    margin-top: 8px;
  }
  .sidebar-footer {
    border-top: 1px solid var(--prussian);
    padding-top: 14px;
    font-size: 12px;
    color: var(--cloud);
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .bottom-nav { display: none; }
  .main-area { padding-bottom: 24px; }
  .topbar {
    background: var(--white);
    color: var(--night);
    border-bottom: 1px solid var(--border);
  }
  .topbar-brand { display: none; }
  .topbar-desktop-title { display: block !important; }
  .content-wrap { padding: 24px 28px 40px; }
}

.topbar-desktop-title { display: none; }

/* ---------- BUTTONS & BADGES ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--night); color: var(--nata); }
.btn-accent { background: var(--goldenrod); color: var(--night); border-color: var(--night); }
.btn-grass { background: var(--grass); color: var(--white); }
.btn-danger { background: var(--cherrywood); color: var(--white); }
.btn-outline { background: var(--white); color: var(--night); border-color: var(--night); }
.btn-soft { background: var(--cloud-soft); color: var(--night); border-color: var(--glacier); }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-inflow { background: #E3F1E1; color: var(--forest); }
.badge-outflow { background: #FBE4DF; color: var(--maroon); }
.badge-transfer { background: var(--cloud-soft); color: var(--night); }
.badge-partner { background: var(--goldenrod-soft); color: var(--night); border: 1px solid var(--sunshine); }
.badge-noncash { background: #ECE8E2; color: var(--muted); }

/* ---------- CARDS & GRIDS ---------- */
.card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card-cream { background: var(--nata); border-color: var(--border); }

.banner-warn {
  background: var(--goldenrod-soft);
  border: 2px solid var(--sunshine);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (min-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}

.kpi-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-top: 4px solid var(--night);
}
.kpi-card.kpi-total { background: var(--night); color: var(--nata); border-color: var(--night); border-top-color: var(--goldenrod); }
.kpi-card.kpi-in { border-top-color: var(--grass); }
.kpi-card.kpi-out { border-top-color: var(--cherrywood); }
.kpi-card.kpi-bank { border-top-color: var(--glacier); }
.kpi-card.kpi-roi { border-top-color: var(--sunshine); }

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.kpi-card.kpi-total .kpi-label { color: var(--cloud); }

.kpi-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
}
@media (min-width: 768px) {
  .kpi-value { font-size: 22px; }
}
.kpi-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.kpi-card.kpi-total .kpi-sub { color: var(--goldenrod); }

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (min-width: 900px) {
  .charts-grid { grid-template-columns: 1fr 1fr; }
}

.chart-box {
  position: relative;
  height: 250px;
  width: 100%;
}

/* ---------- SECTION HEADER ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.section-head h2 { font-size: 22px; }

/* ---------- FORMS ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 768px) {
  .form-grid-2 { grid-template-columns: 1fr 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--prussian);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--night);
  font-family: inherit;
  font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--night);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--nata);
  padding: 5px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  margin-bottom: 16px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.seg-btn.active[data-flow="inflow"] { background: var(--grass); color: var(--white); }
.seg-btn.active[data-flow="outflow"] { background: var(--cherrywood); color: var(--white); }
.seg-btn.active[data-flow="transfer"] { background: var(--night); color: var(--goldenrod); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.quick-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--night);
  background: var(--white);
  color: var(--night);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.quick-pill.active { background: var(--night); color: var(--goldenrod); }

.impact-callout {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}
.impact-company { background: var(--cloud-soft); border-left: 4px solid var(--glacier); }
.impact-partner { background: var(--goldenrod-soft); border-left: 4px solid var(--sunshine); }
.impact-noncash { background: #EFECE6; border-left: 4px solid var(--muted); }

/* ---------- LEDGER FILTERS & TABLE / CARDS ---------- */
.filter-bar {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (min-width: 900px) {
  .filter-row { grid-template-columns: repeat(6, 1fr); }
}

.totals-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--night);
  color: var(--nata);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
}

.ledger-table-wrap { display: none; overflow-x: auto; }
.ledger-cards { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 900px) {
  .ledger-table-wrap { display: block; }
  .ledger-cards { display: none; }
}

table.ledger-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid var(--border);
  font-size: 13px;
}
table.ledger-table th {
  background: var(--night);
  color: var(--nata);
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
table.ledger-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.ledger-table tr:nth-child(even) td { background: #FDFBF8; }
table.ledger-table tr:hover td { background: var(--goldenrod-soft); }

.tx-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.tx-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.tx-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- RECEIPT BOX ---------- */
.receipt-drop {
  border: 2px dashed var(--glacier);
  background: #F6FBFD;
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.receipt-thumb {
  max-height: 160px;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
}

/* ---------- MODALS & TOAST ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 29, 50, 0.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-panel {
  background: var(--white);
  border: 2px solid var(--night);
  border-radius: 16px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
}

.toast {
  position: fixed;
  bottom: 84px;
  right: 18px;
  background: var(--night);
  color: var(--goldenrod);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  z-index: 300;
  border: 2px solid var(--goldenrod);
}
@media (min-width: 1024px) {
  .toast { bottom: 24px; }
}

/* Settings layout */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 900px) {
  .settings-grid { grid-template-columns: 1fr 1fr; }
}

.list-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.list-item-row:last-child { border-bottom: none; }
