/* ============================================================
   Design tokens — passbook / ledger, not the AI-default palette.
   Ink navy + brass stamp + warm paper, evoking a physical
   chitty passbook rather than a generic dashboard.
   ============================================================ */
:root{
  --ink:        #16232E;
  --ink-soft:   #3B4A56;
  --paper:      #FBF7EC;
  --paper-dim:  #F1EBDA;
  --line:       #E3DAC2;
  --brass:      #B08A4E;
  --brass-deep: #8C6D3A;
  --teal:       #2E6B67;
  --green:      #3E7D52;
  --red:        #AE4232;
  --white:      #FFFFFF;

  --font-display: 'Zilla Slab', Georgia, serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 10px rgba(22,35,46,0.08);
}

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

/* Elements toggled via the `hidden` attribute must actually hide,
   even when they also have their own `display` set elsewhere below
   (display:flex etc. on an element otherwise silently overrides the
   browser's default [hidden]{display:none} rule). */
[hidden]{ display: none !important; }

body{
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

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

/* ---------- focus visibility (accessibility floor) ---------- */
:focus-visible{
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ============================================================
   Login
   ============================================================ */
.screen{ min-height: 100vh; }

#login-screen{
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(176,138,78,0.10), transparent 40%),
    var(--paper);
}

.login-card{
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 28px 28px;
  text-align: center;
}

.stamp-mark{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2.5px solid var(--brass);
  color: var(--brass-deep);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.06em;
  transform: rotate(-6deg);
  margin-bottom: 14px;
}
.stamp-mark.small{
  width: 30px; height: 30px;
  font-size: 11px;
  border-width: 1.5px;
}

.login-card h1{
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
}
.login-sub{
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 22px;
}

#login-form{ display:flex; flex-direction:column; gap:14px; text-align:left; }
#login-form label{
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  display:flex; flex-direction:column; gap:6px;
}
#login-form input{
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 15px;
  background: var(--paper);
  color: var(--ink);
}
#login-form input:focus{ border-color: var(--brass); }

.error-text{
  color: var(--red);
  font-size: 13px;
  margin: 2px 0 0;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary{
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary:hover{ background: #24384A; }
.btn-primary.small{ padding: 8px 14px; font-size: 13px; }

.btn-ghost{
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover{ border-color: var(--brass); color: var(--brass-deep); }

.btn-text{
  background:none; border:none; color: var(--teal);
  font-size: 13px; font-weight:600; cursor:pointer; padding:4px 0;
}
.btn-text.danger{ color: var(--red); }

.btn-icon{
  background: none; border: 1px solid var(--line); border-radius: var(--radius-sm);
  width: 34px; height: 34px; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); flex-shrink: 0;
}
.btn-icon:hover{ border-color: var(--brass); }

/* ============================================================
   App shell
   ============================================================ */
#app-shell{
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 18px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky; top:0; z-index: 20;
}
.brand{ display:flex; align-items:center; gap:10px; }
.brand-name{ font-family: var(--font-display); font-weight:600; font-size:16px; }

.content{
  flex: 1;
  padding: 20px 16px 90px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel h2{
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px;
}

.panel-header{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.panel-header h2{ margin:0; }
.header-actions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

/* ============================================================
   Bottom tab bar
   ============================================================ */
.tabbar{
  position: fixed; bottom:0; left:0; right:0;
  display:flex;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 30;
}
.tab-btn{
  flex:1;
  display:flex; flex-direction:column; align-items:center; gap:2px;
  background:none; border:none; cursor:pointer;
  color: var(--ink-soft);
  padding: 6px 2px;
  font-size: 11px;
  border-radius: var(--radius-sm);
}
.tab-btn .tab-icon{ font-size: 17px; line-height:1; }
.tab-btn.active{ color: var(--brass-deep); }

.more-sheet{
  position: fixed; bottom: 66px; right: 10px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display:flex; flex-direction:column;
  overflow:hidden;
  z-index: 35;
  min-width: 160px;
}
.more-item{
  background:none; border:none; text-align:left;
  padding: 12px 16px; font-size:14px; cursor:pointer;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.more-item:last-child{ border-bottom:none; color: var(--ink-soft); }
.more-item:hover{ background: var(--paper-dim); }

/* ============================================================
   Dashboard summary cards
   ============================================================ */
.summary-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.summary-card{
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.summary-card.wide{ grid-column: 1 / -1; }
.summary-card .label{
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-soft); font-weight: 600; margin-bottom: 6px;
}
.summary-card .value{
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600;
}
.summary-card.positive .value{ color: var(--green); }
.summary-card.negative .value{ color: var(--red); }
.summary-card.accent .value{ color: var(--brass-deep); }

.loading-note{ color: var(--ink-soft); font-size:14px; grid-column: 1/-1; }

/* ============================================================
   Chitty grid table
   ============================================================ */
.cycle-select{
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--white);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.search-input{
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--white);
  color: var(--ink);
  margin-bottom: 14px;
}
.search-input:focus{ border-color: var(--brass); }
.search-input::-webkit-search-cancel-button{ cursor: pointer; }

.table-scroll{
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}
.grid-table{
  border-collapse: collapse;
  width: 100%;
}
.grid-table th, .grid-table td{
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}
.grid-table th{
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 11px;
  background: var(--paper-dim);
  position: sticky; top: 0;
}
.grid-table td.sino-cell, .grid-table th.sino-cell{
  text-align: center; position: sticky; left: 0;
  background: var(--white); color: var(--ink-soft); font-weight: 400;
  min-width: 34px;
}
.grid-table th.sino-cell{ background: var(--paper-dim); }

.grid-table td.name-cell, .grid-table th.name-cell{
  text-align: left; position: sticky; left: 34px;
  background: var(--white);
  font-weight: 600;
  min-width: 110px;
}
.grid-table th.name-cell{ background: var(--paper-dim); }

.availed-cell{ cursor: pointer; }
.availed-cell.availed{
  background: #F5D9A8 !important;
}
.avail-mark{
  color: var(--brass-deep);
  font-weight: 700;
  margin-left: 5px;
}

.grid-table tr.total-row td, .grid-table tr.total-row th{
  border-top: 2px solid var(--brass);
  border-bottom: none;
  font-weight: 700;
  background: var(--paper-dim);
  color: var(--brass-deep);
}
.grid-table tr.total-row td.sino-cell{ background: var(--paper-dim); }

/* the "stamp" — signature element for paid status */
.stamp-cell{ cursor: pointer; padding: 4px !important; }
.stamp{
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  margin: 0 auto;
  display:flex; align-items:center; justify-content:center;
  font-size: 13px;
  color: transparent;
  transition: all 0.12s ease;
}
.stamp.paid{
  border-color: var(--brass);
  color: var(--brass-deep);
  transform: rotate(-8deg);
  font-weight: 700;
}
.stamp.paid::after{ content: "✓"; }
.stamp-cell:hover .stamp:not(.paid){ border-color: var(--ink-soft); }

/* ============================================================
   Member grid lists (Savings / Sanjayka)
   ============================================================ */
.member-grid-list{ display:flex; flex-direction:column; gap:14px; }
.member-grid-row{
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.member-grid-row .row-top{
  display:flex; justify-content:space-between; align-items:baseline;
  margin-bottom: 10px;
}
.member-grid-row .row-name{ font-weight:600; font-size:14px; }
.member-grid-row .row-total{
  font-family: var(--font-display);
  font-weight:600; color: var(--brass-deep); font-size:15px;
}
.month-strip{
  display:flex; gap:6px; overflow-x:auto; padding-bottom:2px;
}
.month-cell{
  flex: 0 0 auto;
  display:flex; flex-direction:column; align-items:center; gap:4px;
  min-width: 44px;
}
.month-cell .month-label{ font-size:10px; color:var(--ink-soft); }
.amount-chip{
  min-width: 44px; height: 30px; padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 12px; font-weight:600;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; color: var(--ink-soft);
}
.amount-chip.has-value{ border-color: var(--brass); color: var(--brass-deep); background: #FBF3E4; }

/* ============================================================
   Record lists (Loans / Withdrawals / Members)
   ============================================================ */
.record-list{ display:flex; flex-direction:column; gap:10px; }
.record-card{
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display:flex; justify-content:space-between; align-items:flex-start;
  gap: 10px;
}
.record-main .r-title{ font-weight:600; font-size:14px; margin-bottom:3px; }
.record-main .r-sub{ font-size:12px; color: var(--ink-soft); }
.record-side{ text-align:right; display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
.record-amount{ font-family: var(--font-display); font-weight:600; font-size:15px; }
.record-amount.negative{ color: var(--red); }

.status-pill{
  font-size: 10px; font-weight:700; text-transform:uppercase; letter-spacing:0.04em;
  padding: 3px 8px; border-radius: 20px;
}
.status-pill.open{ background:#FBEFE4; color:var(--brass-deep); }
.status-pill.closed{ background:#E6F0EA; color:var(--green); }

.wa-btn{
  background: none; border: 1px solid var(--teal); color: var(--teal);
  border-radius: 20px; padding: 5px 10px; font-size:11px; font-weight:600;
  cursor:pointer;
}

.empty-note{
  color: var(--ink-soft); font-size: 13px; text-align:center; padding: 30px 10px;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop{
  position: fixed; inset:0; background: rgba(22,35,46,0.45);
  display:flex; align-items:flex-end; justify-content:center;
  z-index: 50;
}
.modal-card{
  background: var(--white);
  width: 100%; max-width: 440px;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 86vh; overflow-y: auto;
}
@media (min-width: 560px){
  .modal-backdrop{ align-items:center; }
  .modal-card{ border-radius: var(--radius); }
}
.modal-card h3{ font-family: var(--font-display); margin: 0 0 16px; font-size:18px; }
.modal-card label{
  display:flex; flex-direction:column; gap:6px;
  font-size:12px; font-weight:600; color: var(--ink-soft);
  margin-bottom: 14px;
}
.modal-card input, .modal-card select{
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size:14px; background: var(--paper); color: var(--ink);
}
.checkbox-group{
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 6px 12px;
  max-height: 180px; overflow-y: auto;
}
.checkbox-row{
  display:flex !important; flex-direction:row !important; align-items:center;
  gap: 8px; font-size:14px; font-weight:400; color: var(--ink);
  padding: 7px 0; margin: 0 !important; border-bottom: 1px solid var(--line);
}
.modal-card .checkbox-row{ font-size:14px; font-weight:400; color: var(--ink); }
.checkbox-row:last-child{ border-bottom:none; }
.checkbox-row input[type="checkbox"]{ width:16px; height:16px; accent-color: var(--brass); }
.modal-hint{
  font-size: 12px; color: var(--ink-soft); margin: -6px 0 4px;
  line-height: 1.4;
}
.modal-actions{ display:flex; gap:10px; margin-top: 18px; justify-content:flex-end; }

/* ============================================================
   Responsive
   ============================================================ */
@media (min-width: 720px){
  .summary-grid{ grid-template-columns: repeat(3, 1fr); }
}
