/* ============================================================
   BASE.CSS — Variables, reset, app shell, header, nav
   ============================================================ */

:root {
  /* Brand palette */
  --deep:     #012B27;
  --deep2:    #023F3A;
  --mid:      #166961;
  --sage:     #4A8C87;
  --mist:     #EEF5F4;
  --border:   #C8DDD9;
  --white:    #FFFFFF;
  --paper:    #F4F9F8;
  --ink:      #010E0D;

  /* Status colors */
  --paid:        #16A34A;  --paid-bg:     #DCFCE7;  --paid-brd:    #15803D;
  --unpaid:      #DC2626;  --unpaid-bg:   #FEE2E2;  --unpaid-brd:  #B91C1C;
  --pending:     #2563EB;  --pending-bg:  #DBEAFE;  --pending-brd: #1D4ED8;
  --partial:     #D97706;  --partial-bg:  #FEF3C7;  --partial-brd: #B45309;
  --grey:        #64748B;  --grey-bg:     #F1F5F9;  --grey-brd:    #475569;

  /* Layout */
  --nav-h:      62px;
  --hdr-h:      54px;
  --tl-left:    92px;
  --row-h:      52px;
  --dates-h:    42px;
  --day-w:      34px;   /* default: month zoom; updated by JS */

  /* Animation */
  --ease:   cubic-bezier(.16,1,.3,1);
  --spring: cubic-bezier(.34,1.56,.64,1);

  /* Safe areas */
  --safe-top: env(safe-area-inset-top,    0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-lft: env(safe-area-inset-left,   0px);
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--deep);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
}

/* ── App shell ── */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--white);
  padding-top:    var(--safe-top);
  padding-bottom: var(--safe-bot);
}

/* ── Content wrapper ── */
#content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Sections ── */
.section {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.section.active {
  display: flex;
  animation: fade-in .22s var(--ease);
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   HEADER
   ============================================================ */
#hdr {
  height: var(--hdr-h);
  flex-shrink: 0;
  background: var(--deep);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  position: relative;
  z-index: 20;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.hdr-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(74,140,135,.18);
  border: 1px solid rgba(74,140,135,.28);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.hdr-logo svg { width: 18px; height: 18px; }

.hdr-title-wrap { flex: 1; min-width: 0; }
.hdr-title {
  font-family: "Fraunces", serif;
  font-size: 16px; font-weight: 500;
  color: #fff; line-height: 1.1;
}
.hdr-sub {
  font-size: 10px; color: rgba(255,255,255,.38);
  letter-spacing: .08em; text-transform: uppercase; margin-top: 1px;
}

.hdr-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.09);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.hdr-btn:active { background: rgba(255,255,255,.14); }
.hdr-btn svg {
  width: 17px; height: 17px;
  stroke: #fff; fill: none; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}

.tl-controls {
  display: flex; align-items: center; gap: 6px; margin-left: auto;
}

/* ── Today button (Block 1.2) ── */
.tl-today-btn {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s; flex-shrink: 0;
  color: rgba(255,255,255,.75);
}
.tl-today-btn:active { background: rgba(255,255,255,.18); }
.tl-today-btn svg { width: 15px; height: 15px; }

/* ── Period navigation ── */
.tl-nav {
  display: flex; align-items: center; gap: 2px;
}
.tl-nav-btn {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.09);
  color: rgba(255,255,255,.7); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.tl-nav-btn:active { background: rgba(255,255,255,.16); }
#tl-period-label {
  font-size: 11.5px; font-weight: 600;
  color: rgba(255,255,255,.8);
  padding: 0 4px; min-width: 82px; text-align: center;
  white-space: nowrap;
}

/* ── View selector dropdown ── */
.view-select-wrap { position: relative; }
.view-select-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 9px; border-radius: 7px;
  background: rgba(22,105,97,.4);
  border: 1px solid rgba(74,140,135,.4);
  color: rgba(255,255,255,.88); cursor: pointer;
  font-size: 11px; font-weight: 600; transition: background .15s;
}
.view-select-btn:active { background: rgba(22,105,97,.7); }
.view-select-btn svg { width: 10px; height: 10px; stroke: currentColor; fill: none; stroke-width: 2.5; }
#view-select-label { white-space: nowrap; }

.view-select-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: #fff; border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
  overflow: hidden; z-index: 50;
  display: none; min-width: 120px;
}
.view-select-menu.open { display: block; }
.vsm-option {
  display: block; width: 100%;
  padding: 11px 14px; text-align: left;
  font-size: 13px; font-weight: 500; color: var(--ink);
  background: transparent; border: none; cursor: pointer;
  transition: background .12s;
}
.vsm-option:not(:last-child) { border-bottom: 1px solid var(--border); }
.vsm-option:active, .vsm-option.active { background: var(--mist); color: var(--deep); font-weight: 700; }

/* ── Toast notification ── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 12px); left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--deep); color: #fff;
  padding: 10px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  opacity: 0; transition: opacity .25s, transform .25s;
  white-space: nowrap; z-index: 100; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#sync-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22C55E;
  animation: pulse-sync 3s ease-in-out infinite;
  margin-left: 4px; flex-shrink: 0;
}
@keyframes pulse-sync {
  0%,100% { opacity: 1; }
  60%     { opacity: .35; }
}

/* ============================================================
   BOTTOM NAV
   ============================================================ */
#nav {
  height: var(--nav-h);
  flex-shrink: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  position: relative; z-index: 20;
}

.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; cursor: pointer;
  position: relative; border: none; background: transparent;
  transition: all .2s;
}
.nav-item svg {
  width: 21px; height: 21px;
  stroke: rgba(74,140,135,.7); fill: none; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
  transition: stroke .2s, transform .2s;
}
.nav-item span {
  font-size: 9.5px; font-weight: 500;
  color: rgba(74,140,135,.7); letter-spacing: .03em;
  transition: color .2s;
}
.nav-item.active svg {
  stroke: var(--deep);
  transform: scale(1.1) translateY(-1px);
}
.nav-item.active span {
  color: var(--deep); font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute; top: 0;
  left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px;
  background: var(--deep);
  border-radius: 0 0 3px 3px;
}

.nav-badge {
  position: absolute;
  top: 8px; right: calc(50% - 19px);
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--unpaid); color: #fff;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--white);
}

/* ============================================================
   SHARED SECTION CHROME
   ============================================================ */
.sec-hdr {
  padding: 14px 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: var(--white);
}
.sec-hdr h2 {
  font-family: "Fraunces", serif;
  font-size: 21px; font-weight: 500; color: var(--deep);
}
.sec-btn {
  font-size: 12px; font-weight: 700; color: var(--mid);
  padding: 7px 12px; border-radius: 9px;
  background: var(--mist);
  border: 1px solid var(--border); cursor: pointer;
}

.list-header {
  padding: 10px 14px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--white); flex-shrink: 0;
}

.search-box {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 11px; padding: 9px 12px;
}
.search-box svg {
  width: 15px; height: 15px;
  stroke: var(--sage); fill: none; stroke-width: 1.5; flex-shrink: 0;
}
.search-box input {
  flex: 1; border: none; background: transparent;
  font-size: 14px; color: var(--ink); outline: none;
}
.search-box input::placeholder { color: var(--sage); }

.tab-row {
  display: flex; padding: 0 14px; gap: 4px;
  border-bottom: 1px solid var(--border);
  background: var(--white); flex-shrink: 0;
  overflow-x: auto;
}
.tab-row::-webkit-scrollbar { display: none; }

.tab-pill {
  font-size: 12px; font-weight: 600;
  padding: 10px 12px;
  border-bottom: 2.5px solid transparent;
  color: var(--sage); cursor: pointer;
  transition: all .15s; border: none; background: transparent;
  white-space: nowrap;
}
.tab-pill.active { color: var(--deep); border-bottom-color: var(--deep); }

.list-scroll {
  flex: 1; height: 0;
  overflow-y: auto; padding: 8px 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.list-scroll::-webkit-scrollbar { display: none; }

/* Block 13: Remove number input spinners globally */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

.empty-state {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 40px 20px; color: var(--sage);
}
.empty-state svg {
  width: 36px; height: 36px;
  stroke: var(--border); fill: none; stroke-width: 1.5; stroke-linecap: round;
}
.empty-state p { font-size: 14px; text-align: center; }
