@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root{
  --bg: #EEF1EF;
  --surface: #FFFFFF;
  --ink: #16242B;
  --muted: #5B6B70;
  --line: #DDE3E1;
  --brass: #B9852F;
  --brass-soft: #F1E2C4;
  --green: #3E7C59;
  --green-soft: #E1EDE5;
  --rust: #A83232;
  --rust-soft: #F6DFDD;
  --orange: #C9702E;
  --toast-bg: #16242B;
  --toast-fg: #ffffff;
}

body.dark{
  --bg: #1B2226;
  --surface: #232B30;
  --ink: #ECEFF0;
  --muted: #9AA6AA;
  --line: #343F44;
  --brass: #D2A24C;
  --brass-soft: #3A2F1C;
  --green: #5FA97D;
  --green-soft: #1E3327;
  --rust: #E58A7D;
  --rust-soft: #3A2422;
  --orange: #E08A4B;
}
body.dark .type-deduction{ background:#3A2E45; color:#C6A6E0; }
body.dark .type-corporate{ background:#233047; color:#8FAEDD; }
body.dark .type-legacy{ background:#3A434A; color:#C7CDD0; }
body.dark .tab.active{ background:var(--brass); color:#1B2226; border-color:var(--brass); }
body.dark .seg{ background:#3A434A; }
body.dark .deadline-bar{ background:#3A434A; }
body.dark .snooze-btn{ background:var(--surface); border-color:var(--rust) !important; }
body.dark .add-btn.secondary{ background:var(--brass); color:#1B2226; }
body.dark{ color-scheme: dark; }
body{ color-scheme: light; }
body.dark{ transition: background-color .2s, color .2s; }
body.dark .card, body.dark .stat, body.dark .form-card, body.dark .banner, body.dark .reminder-card{ transition: background-color .2s, border-color .2s; }

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  background: var(--bg);
  color: var(--ink);
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  min-height: 100vh;
  padding: 28px 20px 60px;
}
.mono{ font-family:'JetBrains Mono','Vazirmatn',monospace; }

.wrap{ max-width: 880px; margin: 0 auto; }

/* Header */
header{ display:flex; align-items:flex-end; justify-content:space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.brand{ display:flex; align-items:center; gap: 12px; }
.gauge-icon{ width:44px; height:44px; flex-shrink:0; }
h1{ font-size: 26px; font-weight: 800; margin:0; letter-spacing:-0.5px; }
.sub{ color: var(--muted); font-size: 13.5px; margin-top: 3px; }

/* Stats */
.stats{ display:grid; grid-template-columns: repeat(4,1fr); gap:10px; margin-bottom:20px; }
.stat{ background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:12px 14px; }
.stat .num{ font-family:'JetBrains Mono'; font-size:22px; font-weight:700; }
.stat .lbl{ font-size:12px; color:var(--muted); margin-top:2px; }
.stat.overdue .num{ color: var(--rust); }
.stat.done .num{ color: var(--green); }
.stat.progress .num{ color: var(--brass); }

/* Controls */
.controls{ display:flex; gap:10px; margin-bottom:16px; flex-wrap:wrap; align-items:center; }
input[type=text], textarea{
  font-family:'Vazirmatn'; border:1px solid var(--line); border-radius:10px; padding:9px 12px;
  background:var(--surface); color:var(--ink); font-size:14px;
}
input[type=text]:focus, textarea:focus{ outline:2px solid var(--brass); outline-offset:1px; }
.search{ flex:1; min-width:180px; }
.tabs{ display:flex; gap:6px; }
.tab{ padding:8px 14px; border-radius:999px; border:1px solid var(--line); background:var(--surface); font-size:13px; cursor:pointer; color:var(--muted); }
.tab.active{ background:var(--ink); color:#fff; border-color:var(--ink); }
.add-btn{ background:var(--brass); color:#fff; border:none; border-radius:10px; padding:9px 18px; font-family:'Vazirmatn'; font-weight:600; font-size:14px; cursor:pointer; }
.add-btn:hover{ filter:brightness(1.05); }

/* Add form */
.form-card{ background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:16px; margin-bottom:18px; display:none; }
.form-card.show{ display:block; }
.form-row{ display:flex; gap:10px; margin-bottom:10px; flex-wrap:wrap; }
.form-row input, .form-row textarea{ flex:1; min-width:160px; }
.form-actions{ display:flex; gap:8px; justify-content:flex-start; }
.save-btn{ background:var(--green); color:#fff; border:none; border-radius:8px; padding:8px 16px; cursor:pointer; font-family:'Vazirmatn'; font-weight:600; }
.cancel-btn{ background:transparent; color:var(--muted); border:1px solid var(--line); border-radius:8px; padding:8px 16px; cursor:pointer; font-family:'Vazirmatn'; }

/* Cards */
.card{ background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:14px 16px; margin-bottom:12px; cursor:pointer; transition:box-shadow .15s; }
.card:hover{ box-shadow:0 2px 10px rgba(0,0,0,0.06); }
.card.overdue{ border-color: var(--rust); }
.card-top{ display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
.card-name{ font-weight:700; font-size:15.5px; }
.card-meta{ font-size:12.5px; color:var(--muted); margin-top:2px; }
.badge{ font-size:11px; padding:3px 9px; border-radius:999px; white-space:nowrap; }
.badge.overdue{ background:var(--rust-soft); color:var(--rust); }
.badge.done{ background:var(--green-soft); color:var(--green); }
.badge.progress{ background:var(--brass-soft); color:var(--brass); }

/* Gauge */
.gauge{ display:flex; gap:4px; margin-top:10px; }
.seg{ flex:1; height:8px; border-radius:4px; background:#E4E7E5; position:relative; }
.seg.filled{ background: var(--brass); }
.seg.filled.done-all{ background: var(--green); }

/* Expand */
.expand{ margin-top:14px; padding-top:14px; border-top:1px dashed var(--line); display:none; }
.expand.show{ display:block; }
.stage-row{ display:flex; align-items:center; gap:10px; padding:6px 0; font-size:14px; }
.stage-row input[type=checkbox]{ width:18px; height:18px; accent-color: var(--brass); cursor:pointer; }
.stage-row.done{ color: var(--muted); text-decoration: line-through; }
.stage-date{ margin-right:auto; font-size:11.5px; color:var(--muted); }
.notes-area{ width:100%; margin-top:10px; min-height:50px; resize:vertical; font-size:13.5px; }
.card-actions{ display:flex; justify-content:flex-end; gap:8px; margin-top:10px; }
.del-btn{ background:transparent; border:none; color:var(--rust); font-size:12.5px; cursor:pointer; }

.empty{ text-align:center; color:var(--muted); padding:40px 10px; font-size:14px; }

/* Reminders */
.add-btn.secondary{ background:var(--ink); }
.banner{ background:var(--rust-soft); border:1px solid var(--rust); border-radius:12px; padding:12px 16px; margin-bottom:18px; display:none; }
.banner.show{ display:block; }
.banner-title{ font-weight:700; color:var(--rust); margin-bottom:8px; font-size:14px; }
.banner-item{ display:flex; justify-content:space-between; align-items:center; gap:10px; padding:7px 0; border-top:1px solid rgba(168,50,50,0.18); }
.banner-item:first-of-type{ border-top:none; }
.banner-text{ font-size:13.5px; }
.banner-when{ font-size:11.5px; color:var(--muted); }
.banner-actions{ display:flex; gap:6px; flex-shrink:0; }
.banner-actions button{ font-family:'Vazirmatn'; font-size:11.5px; border:none; border-radius:7px; padding:5px 10px; cursor:pointer; white-space:nowrap; }
.snooze-btn{ background:#fff; color:var(--rust); border:1px solid var(--rust) !important; }
.done-btn{ background:var(--green); color:#fff; }

.section-head{ display:flex; justify-content:space-between; align-items:center; margin:28px 0 12px; }
.section-head h2{ font-size:16px; margin:0; }

select{ font-family:'Vazirmatn'; border:1px solid var(--line); border-radius:10px; padding:9px 12px; background:var(--surface); color:var(--ink); font-size:14px; }
input[type=datetime-local]{ font-family:'Vazirmatn'; border:1px solid var(--line); border-radius:10px; padding:9px 12px; background:var(--surface); color:var(--ink); font-size:14px; }

.reminder-card{ background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:12px 14px; margin-bottom:10px; display:flex; justify-content:space-between; align-items:center; gap:10px; }
.reminder-card.due{ border-color:var(--rust); }
.reminder-card.done{ opacity:0.5; }
.reminder-text{ font-size:14px; }
.reminder-text.strike{ text-decoration:line-through; }
.reminder-link{ font-size:12px; color:var(--brass); margin-top:2px; }
.reminder-when{ font-size:12px; color:var(--muted); margin-top:2px; }
.reminder-actions{ display:flex; gap:6px; flex-shrink:0; }
.icon-btn{ background:transparent; border:1px solid var(--line); border-radius:8px; padding:5px 9px; cursor:pointer; font-size:12px; font-family:'Vazirmatn'; }
.quick-remind-btn{ background:transparent; border:none; color:var(--brass); font-size:12.5px; cursor:pointer; }

.toast{ position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:var(--toast-bg); color:var(--toast-fg); padding:11px 20px; border-radius:10px; font-size:13.5px; box-shadow:0 4px 18px rgba(0,0,0,0.2); z-index:999; display:none; max-width:90%; text-align:center; }
.toast.show{ display:block; }
.confirm-btn{ background:var(--rust); color:#fff; border:none; border-radius:8px; padding:6px 12px; font-size:12px; cursor:pointer; font-family:'Vazirmatn'; font-weight:600; }

.deadline-bar{ height:6px; border-radius:3px; background:#E4E7E5; margin-top:8px; overflow:hidden; }
.deadline-fill{ height:100%; border-radius:3px; transition:width .3s; }
.deadline-label{ font-size:11.5px; margin-top:4px; font-weight:600; }

.type-badge{ font-size:11px; padding:3px 10px; border-radius:999px; white-space:nowrap; font-weight:600; }
.type-invoice{ background:var(--brass-soft); color:var(--brass); }
.type-deduction{ background:#EBDFF5; color:#6B4C93; }
.type-daily{ background:var(--green-soft); color:var(--green); }
.type-corporate{ background:#DCE3F2; color:#34508A; }
.type-legacy{ background:#eee; color:var(--muted); }

.stage-row-block{ margin-bottom:4px; }
.stage-subfields{ padding-inline-start:28px; display:flex; flex-direction:column; gap:6px; margin:2px 0 10px; }
.stage-subfields input, .stage-subfields textarea{ font-size:13px; width:100%; }
.stage-subfields textarea{ min-height:44px; resize:vertical; }

.login-overlay{
  position:fixed; inset:0; z-index:2000;
  background:linear-gradient(160deg, #16242B 0%, #2b3d47 100%);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.login-card{
  background:var(--surface); border-radius:20px; padding:36px 30px 30px;
  width:100%; max-width:340px; text-align:center; box-shadow:0 24px 60px rgba(0,0,0,0.4);
}
.login-logo{ width:72px; height:72px; object-fit:contain; margin-bottom:12px; }
.login-card h2{ font-size:19px; margin:0 0 4px; font-weight:800; }
.login-sub{ font-size:13px; color:var(--muted); margin-bottom:24px; }
.login-field{ text-align:right; margin-bottom:14px; }
.login-field label{ font-size:12.5px; color:var(--muted); display:block; margin-bottom:5px; }
.login-field select, .login-field input{ width:100%; }
.login-hint{ font-size:11.5px; color:var(--brass); min-height:16px; margin-bottom:8px; text-align:right; }
.login-error{ font-size:12.5px; color:var(--rust); min-height:16px; margin-top:8px; font-weight:600; }
.login-btn{
  width:100%; background:var(--brass); color:#fff; border:none; border-radius:10px;
  padding:11px; font-family:'Vazirmatn'; font-weight:700; font-size:14.5px; cursor:pointer; margin-top:4px;
}
.login-btn:hover{ filter:brightness(1.06); }

.theme-toggle{
  position:fixed; top:14px; left:14px; z-index:1500;
  background:var(--surface); border:1px solid var(--line); border-radius:999px;
  width:40px; height:40px; font-size:18px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 2px 10px rgba(0,0,0,0.12);
  transition: background-color .2s, border-color .2s;
}

.popup-overlay{
  position:fixed; inset:0; z-index:1900;
  background:rgba(0,0,0,0.45);
  display:none; align-items:center; justify-content:center; padding:20px;
}
.popup-card{
  background:var(--surface); border-radius:18px; padding:30px 26px 24px;
  width:100%; max-width:360px; text-align:center;
  box-shadow:0 20px 55px rgba(0,0,0,0.35);
  border-top:5px solid var(--rust);
}
.popup-title{ font-size:17px; font-weight:800; margin-bottom:10px; }
.popup-text{ font-size:14.5px; margin-bottom:6px; line-height:1.7; }
.popup-when{ font-size:12px; color:var(--muted); margin-bottom:20px; }
.popup-actions{ display:flex; flex-direction:column; gap:8px; }
.popup-actions .save-btn, .popup-actions .snooze-btn, .popup-actions .cancel-btn{ width:100%; }
