
:root{
  --teal:#017785; --teal-dark:#015a65; --teal-tint:#eaf5f6; --ink:#111111; --muted:#6b7280;
  --line:#e5e7eb; --white:#ffffff; --bg:#f7f8f8; --danger:#b91c1c; --good:#0a7a3c; --warn:#b45309;
  --radius:16px; --radius-sm:10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;height:100%}
body{
  font-family:'Montserrat',system-ui,-apple-system,sans-serif;
  background:var(--bg); color:var(--ink); -webkit-font-smoothing:antialiased;
  overscroll-behavior-y: none;
}
h1,h2,h3,.serif{font-family:'Playfair Display',Georgia,serif;}
.hidden{display:none !important}
button{font-family:inherit}
input{font-family:inherit}

.app{height:100%}
.screen{height:100%; display:flex; flex-direction:column}

/* ---------- Login ---------- */
.screen-login{align-items:center; justify-content:center; padding:24px; background:linear-gradient(180deg,var(--teal) 0%, var(--teal-dark) 55%, #09282c 100%);}
.login-card{background:var(--white); border-radius:var(--radius); padding:32px 24px; width:100%; max-width:360px; text-align:center; box-shadow:0 20px 50px rgba(0,0,0,.25)}
.login-logo{width:64px; height:64px; margin-bottom:12px; border-radius:14px}
.login-title{margin:0 0 4px; font-size:26px; color:var(--ink)}
.login-sub{margin:0 0 24px; color:var(--muted); font-size:14px}
.field{display:block; text-align:left; margin-bottom:14px}
.field span{display:block; font-size:12px; font-weight:600; color:var(--muted); margin-bottom:6px; text-transform:uppercase; letter-spacing:.04em}
.field input{width:100%; padding:12px 14px; border:1.5px solid var(--line); border-radius:var(--radius-sm); font-size:16px; outline:none; transition:border-color .15s}
.field input:focus{border-color:var(--teal)}
.error{background:#fdecec; color:var(--danger); padding:10px 12px; border-radius:var(--radius-sm); font-size:13px; margin-bottom:14px; text-align:left}

.btn{border:none; border-radius:var(--radius-sm); padding:13px 18px; font-size:15px; font-weight:600; cursor:pointer; transition:transform .08s, opacity .15s}
.btn:active{transform:scale(.98)}
.btn-primary{background:var(--teal); color:var(--white)}
.btn-primary:hover{background:var(--teal-dark)}
.btn-block{width:100%}
.btn-secondary{background:var(--teal-tint); color:var(--teal-dark)}
.btn-ghost{background:transparent; color:var(--teal-dark); border:1.5px solid var(--teal)}
.btn-danger{background:#fdecec; color:var(--danger)}
.btn-sm{padding:8px 12px; font-size:13px; border-radius:8px}
.btn:disabled{opacity:.5; cursor:default}

/* ---------- App shell ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:calc(12px + var(--safe-top)) 16px 12px; background:var(--white); border-bottom:1px solid var(--line);
  position:sticky; top:0; z-index:5;
}
.topbar-brand{display:flex; align-items:center; gap:10px}
.brand-mark{width:30px; height:30px; border-radius:7px}
.brand-name{font-family:'Playfair Display',serif; font-weight:700; font-size:18px; color:var(--ink)}
.icon-btn{background:none; border:none; font-size:20px; color:var(--teal-dark); cursor:pointer; padding:6px; line-height:1}

.main{flex:1; overflow-y:auto; padding:16px 16px calc(96px + var(--safe-bottom)); -webkit-overflow-scrolling:touch}

.tabbar{
  position:fixed; left:0; right:0; bottom:0; display:flex; background:var(--white);
  border-top:1px solid var(--line); padding-bottom:var(--safe-bottom); z-index:10;
}
.tab-btn{
  flex:1; background:none; border:none; display:flex; flex-direction:column; align-items:center; gap:3px;
  padding:9px 4px 8px; color:var(--muted); font-size:11.5px; font-weight:600; cursor:pointer; position:relative;
}
.tab-btn .tab-icon{font-size:18px}
.tab-btn.active{color:var(--teal-dark)}
.badge{position:absolute; top:2px; right:calc(50% - 22px); background:var(--danger); color:#fff; font-size:10px; font-weight:700; min-width:16px; height:16px; border-radius:8px; display:flex; align-items:center; justify-content:center; padding:0 4px}

/* ---------- Overview ---------- */
.month-picker{display:flex; align-items:center; justify-content:space-between; margin-bottom:18px}
.month-picker .label{font-family:'Playfair Display',serif; font-weight:700; font-size:20px}
.month-nav{display:flex; gap:6px}
.month-nav button{background:var(--teal-tint); border:none; color:var(--teal-dark); width:34px; height:34px; border-radius:50%; font-size:16px; cursor:pointer}

.big-card{background:var(--white); border-radius:var(--radius); padding:18px 20px; margin-bottom:14px; box-shadow:0 1px 3px rgba(0,0,0,.04)}
.big-card .kicker{font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); margin-bottom:6px}
.big-number{font-family:'Playfair Display',serif; font-weight:700; font-size:34px; line-height:1.1}
.big-number.good{color:var(--good)}
.big-number.bad{color:var(--danger)}
.big-number.neutral{color:var(--ink)}
.sub-line{font-size:13px; color:var(--muted); margin-top:4px}

.section-title{font-family:'Playfair Display',serif; font-weight:700; font-size:17px; margin:22px 0 10px}
.row-list{background:var(--white); border-radius:var(--radius); overflow:hidden; box-shadow:0 1px 3px rgba(0,0,0,.04)}
.row-item{display:flex; align-items:center; justify-content:space-between; padding:13px 16px; border-bottom:1px solid var(--line)}
.row-item:last-child{border-bottom:none}
.row-item .name{font-size:14.5px; font-weight:500}
.row-item .count{font-size:11.5px; color:var(--muted); margin-left:6px}
.row-item .amt{font-size:15px; font-weight:700; font-variant-numeric:tabular-nums}
.amt.pos{color:var(--good)} .amt.neg{color:var(--danger)}

.pill{display:inline-block; font-size:10.5px; font-weight:700; padding:2px 8px; border-radius:20px; text-transform:uppercase; letter-spacing:.03em}
.pill-business{background:#e7f3ff; color:#0b5fa8}
.pill-personal{background:var(--teal-tint); color:var(--teal-dark)}
.pill-transfer{background:#f1eefc; color:#6d28d9}

.grid-table{width:100%; border-collapse:collapse; font-size:12.5px; background:var(--white); border-radius:var(--radius); overflow:hidden}
.grid-table th,.grid-table td{padding:8px 6px; text-align:center; border-bottom:1px solid var(--line)}
.grid-table th{font-size:10.5px; color:var(--muted); font-weight:700}
.grid-table td:first-child,.grid-table th:first-child{text-align:left; padding-left:12px; font-weight:600; max-width:108px; white-space:normal; line-height:1.25; word-break:break-word}
.dot{display:inline-block; width:9px; height:9px; border-radius:50%}
.dot-met{background:var(--good)} .dot-partial{background:var(--warn)} .dot-missed{background:var(--danger)}
.dot-received{background:var(--teal)} .dot-none{background:var(--line)} .dot-nodata{background:#f3f4f6; border:1px solid var(--line)}

.empty-state{text-align:center; padding:48px 20px; color:var(--muted)}
.empty-state .emoji{font-size:40px; display:block; margin-bottom:10px}
.empty-state h3{margin:0 0 6px; color:var(--ink)}
.empty-state p{margin:0; font-size:13.5px; line-height:1.5}

/* ---------- Review cards ---------- */
.review-progress{display:flex; align-items:center; justify-content:space-between; margin-bottom:14px}
.review-progress .count{font-family:'Playfair Display',serif; font-weight:700; font-size:22px}
.tx-card{background:var(--white); border-radius:var(--radius); padding:16px; margin-bottom:12px; box-shadow:0 1px 3px rgba(0,0,0,.05)}
.tx-card .tx-top{display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:4px}
.tx-card .tx-desc{font-size:15px; font-weight:600; max-width:70%}
.tx-card .tx-amt{font-size:18px; font-weight:700; font-variant-numeric:tabular-nums}
.tx-card .tx-meta{font-size:12px; color:var(--muted); margin-bottom:12px}
.toggle-group{display:flex; gap:8px; margin-bottom:10px}
.toggle-btn{flex:1; padding:10px 6px; border-radius:10px; border:1.5px solid var(--line); background:var(--white); font-size:13px; font-weight:600; color:var(--muted); cursor:pointer}
.toggle-btn.sel-business{border-color:#0b5fa8; background:#e7f3ff; color:#0b5fa8}
.toggle-btn.sel-personal{border-color:var(--teal); background:var(--teal-tint); color:var(--teal-dark)}
.toggle-btn.sel-transfer{border-color:#6d28d9; background:#f1eefc; color:#6d28d9}
select.select-cat{width:100%; padding:10px 12px; border-radius:10px; border:1.5px solid var(--line); font-size:14px; margin-bottom:10px; background:var(--white)}
.tx-actions{display:flex; gap:8px; align-items:center}
.tx-actions .btn{flex:1}
.link-btn{background:none; border:none; color:var(--muted); font-size:12.5px; text-decoration:underline; cursor:pointer; padding:4px}
.rule-row{display:flex; align-items:center; gap:8px; font-size:12.5px; color:var(--muted); margin-top:10px}
.suggestion-chip{display:inline-flex; align-items:center; gap:4px; background:var(--teal-tint); color:var(--teal-dark); font-size:11.5px; font-weight:600; padding:3px 9px; border-radius:20px; margin-bottom:10px}

/* ---------- Upload / Accounts ---------- */
.account-card{background:var(--white); border-radius:var(--radius); padding:16px; margin-bottom:12px; box-shadow:0 1px 3px rgba(0,0,0,.04)}
.account-card .acc-name{font-weight:700; font-size:15px}
.account-card .acc-sub{font-size:12.5px; color:var(--muted); margin-top:2px}
.upload-zone{border:2px dashed var(--line); border-radius:var(--radius); padding:24px 16px; text-align:center; margin-top:10px; background:var(--white)}
.upload-zone input[type=file]{display:none}
.help-card{background:var(--teal-tint); border-radius:var(--radius); padding:16px; font-size:13px; color:var(--teal-dark); line-height:1.6; margin-top:16px}
.help-card h4{margin:0 0 8px; font-family:'Playfair Display',serif; font-size:15px}
.help-card ol{margin:0; padding-left:18px}

/* ---------- Settings sheet ---------- */
.sheet-backdrop{position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:19}
.sheet{
  position:fixed; left:0; right:0; bottom:0; background:var(--white); z-index:20;
  border-radius:20px 20px 0 0; max-height:88vh; display:flex; flex-direction:column;
  box-shadow:0 -10px 40px rgba(0,0,0,.2); padding-bottom:var(--safe-bottom);
}
.sheet-handle{width:40px; height:4px; background:var(--line); border-radius:4px; margin:10px auto 0}
.sheet-header{display:flex; align-items:center; justify-content:space-between; padding:10px 18px 6px}
.sheet-header h2{margin:0; font-size:19px}
.sheet-body{overflow-y:auto; padding:0 18px 24px}

.settings-section{margin-bottom:22px}
.settings-section h3{font-size:14px; margin:0 0 10px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; font-weight:700; font-family:'Montserrat',sans-serif}
.rule-item{background:var(--bg); border-radius:12px; padding:12px; margin-bottom:8px; font-size:13px}
.rule-item .rp{font-weight:700}
.rule-item .rmeta{color:var(--muted); font-size:11.5px; margin-top:3px}
.form-row{display:flex; gap:8px; margin-bottom:8px}
.form-row input, .form-row select{flex:1; padding:9px 10px; border:1.5px solid var(--line); border-radius:8px; font-size:13px}

.toast{
  position:fixed; left:50%; bottom:calc(84px + var(--safe-bottom)); transform:translateX(-50%);
  background:var(--ink); color:#fff; padding:10px 18px; border-radius:30px; font-size:13.5px;
  z-index:30; box-shadow:0 6px 20px rgba(0,0,0,.25); max-width:88vw; text-align:center;
}

@media (min-width: 640px){
  .main{max-width:560px; margin:0 auto; padding-left:20px; padding-right:20px}
  .topbar > *{max-width:560px}
  .sheet{max-width:560px; left:50%; transform:translateX(-50%); right:auto; width:100%}
}
