:root {
  --paper: #F7F8F5;
  --card: #FFFFFF;
  --ink: #1B2A41;
  --muted: #64707F;
  --line: #E4E7E1;
  --amber: #C97B2D;
  --amber-soft: #F6E8D6;
  --red: #C0392B;
  --red-soft: #F9E2DF;
  --green: #2E7D5B;
  --green-soft: #E0EFE8;
  --radius: 14px;
  --display: "Sora", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: 96px;
}

main { max-width: 680px; margin: 0 auto; padding: 0 16px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 680px; margin: 0 auto; padding: 18px 16px 10px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--ink); color: var(--amber);
  font-size: 24px; font-weight: 700;
}
.brand h1 { font-family: var(--display); font-size: 22px; margin: 0; letter-spacing: -0.02em; }
.tagline { margin: 0; color: var(--muted); font-size: 12px; }

.avatar-btn { border: 2px solid var(--amber); background: none; border-radius: 50%; padding: 0; cursor: pointer; }
.avatar-btn img { width: 34px; height: 34px; border-radius: 50%; display: block; }

/* ---------- Banners ---------- */
.banner {
  max-width: 648px; margin: 8px auto; padding: 10px 14px;
  border-radius: 10px; font-size: 13px;
}
.banner-setup { background: var(--amber-soft); border: 1px solid var(--amber); }
.banner-warn { background: var(--red-soft); border: 1px solid var(--red); color: #7A241B; font-weight: 500; }
.banner code { background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 4px; }

/* ---------- Runway (signature) ---------- */
.runway-card {
  background: var(--ink); color: #EDF0F4;
  border-radius: var(--radius); padding: 16px 16px 12px; margin-top: 8px;
}
.runway-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.runway-head h2 { font-family: var(--display); font-size: 15px; margin: 0; color: var(--amber); }
.runway-legend { font-size: 11px; color: #A9B3C0; display: flex; align-items: center; gap: 4px; }
.runway-legend .dot { margin-left: 8px; }

.runway {
  position: relative; height: 46px; margin-top: 14px;
  border-bottom: 1px solid #35455E;
}
.runway .tick {
  position: absolute; top: 0; bottom: 0; width: 1px; background: #2A3A54;
}
.runway .marker {
  position: absolute; bottom: 6px; transform: translateX(-50%);
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--ink); cursor: pointer;
}
.runway-months {
  display: grid; grid-template-columns: repeat(12, 1fr);
  font-size: 9.5px; color: #8A95A5; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.06em;
}

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot-overdue, .marker.overdue { background: var(--red); }
.dot-critical, .marker.critical { background: #E67E22; }
.dot-soon, .marker.soon { background: var(--amber); }
.dot-ok, .marker.ok { background: var(--green); }

/* ---------- Summary ---------- */
.summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: var(--display); font-size: 17px; font-weight: 600; }

/* ---------- List ---------- */
.list-section { margin-top: 20px; }
.list-head { display: flex; justify-content: space-between; align-items: center; }
.list-head h2 { font-family: var(--display); font-size: 16px; margin: 0 0 8px; }

.group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 16px 2px 6px; font-weight: 600;
}

.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  transition: border-color 0.15s;
}
.item:hover { border-color: var(--amber); }
.item-emoji { font-size: 22px; }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12px; color: var(--muted); }
.item-right { text-align: right; flex-shrink: 0; }
.item-amount { font-family: var(--display); font-weight: 600; font-size: 14px; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; margin-top: 2px;
}
.badge.overdue { background: var(--red-soft); color: var(--red); }
.badge.critical { background: #FBE9D9; color: #B35B0E; }
.badge.soon { background: var(--amber-soft); color: var(--amber); }
.badge.ok { background: var(--green-soft); color: var(--green); }

.renew-btn {
  border: 1px solid var(--green); color: var(--green); background: var(--green-soft);
  border-radius: 8px; font-size: 11px; font-weight: 600; padding: 4px 8px; cursor: pointer;
}

/* ---------- Empty state ---------- */
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.empty-big { font-family: var(--display); font-size: 17px; color: var(--ink); margin-bottom: 6px; }
.chip {
  border: 1px solid var(--amber); background: var(--amber-soft); color: var(--amber);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; margin: 2px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--body); font-size: 14px; font-weight: 600;
  border-radius: 10px; padding: 9px 16px; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2A3D5C; }
.btn-ghost { background: none; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--amber); }
.btn-danger { background: none; border-color: var(--red); color: var(--red); }
.btn-sm { font-size: 12px; padding: 6px 10px; }

.fab {
  position: fixed; right: 20px; bottom: 24px;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--amber); color: #fff; font-size: 30px; line-height: 1;
  border: none; cursor: pointer; box-shadow: 0 6px 18px rgba(201,123,45,0.4);
}
.fab:hover { transform: scale(1.05); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(27,42,65,0.55);
  display: grid; place-items: end center; z-index: 50;
}
@media (min-width: 560px) { .modal-backdrop { place-items: center; } }
.modal {
  background: var(--card); border-radius: 18px 18px 0 0; width: 100%; max-width: 520px;
  padding: 20px 20px 24px; max-height: 90vh; overflow-y: auto;
}
@media (min-width: 560px) { .modal { border-radius: 18px; } }
.modal h2 { font-family: var(--display); font-size: 18px; margin: 0 0 14px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; flex: 1; }
.field span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select {
  font-size: 15px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--amber); border-color: var(--amber); }
.field-row { display: flex; gap: 10px; }

.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.spacer { flex: 1; }

button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- ExSimplify additions ---------- */
.brand-mark { font-family: var(--display); font-size: 16px; letter-spacing: -0.02em; }

body { padding-bottom: 140px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}
.tabbar .tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  font-size: 11px; font-weight: 600; color: var(--muted);
  padding: 4px 10px; border-radius: 10px; min-width: 56px;
}
.tabbar .tab .tab-icon { font-size: 20px; }
.tabbar .tab.active { color: var(--amber); background: var(--amber-soft); }

.fab { bottom: 84px; }

.summary-2 { grid-template-columns: 2fr 1fr; margin-top: 12px; }

.section-title { font-family: var(--display); font-size: 16px; margin: 0 0 2px; }
.section-hint { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.all-clear { color: var(--green); font-weight: 600; padding: 12px 2px; }
[hidden] { display: none !important; }
.modal-backdrop[hidden] { display: none !important; }
