:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f2430;
  --border: #2a3040;
  --text: #f5f6f8;
  --muted: #9aa4b6;
  --accent: #6366f1;
  --accent-hover: #4f52e0;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(15, 17, 21, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.user-slot { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); }

.app { max-width: 720px; margin: 0 auto; padding: 18px; }
.view { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* Login hero */
.hero { text-align: center; padding: 48px 16px; }
.hero h1 { font-size: 28px; line-height: 1.2; margin: 0 0 12px; }
.hero p { color: var(--muted); max-width: 42ch; margin: 0 auto 24px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15px;
  cursor: pointer; text-decoration: none; transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn-small { padding: 7px 12px; font-size: 13px; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-google { background: #fff; color: #1f2430; }
.btn-google:hover { background: #eceef3; }
.linklike { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 6px 0; }
.assistant-actions { display: flex; gap: 18px; align-items: center; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 26px 0 12px; }

/* Banner */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; font-size: 14px; margin-top: 8px;
}

/* Ribbon calendar: horizontal, colored red (soon) -> green (far) */
.ribbon {
  display: flex; gap: 12px; overflow-x: auto; padding: 6px 2px 14px;
  scroll-snap-type: x proximity;
}
.ribbon::-webkit-scrollbar { height: 8px; }
.ribbon::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.ribbon-empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }

.chip {
  scroll-snap-align: start;
  flex: 0 0 auto; width: 132px;
  border-radius: var(--radius); padding: 14px; color: #0b0d12;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.chip .chip-when { font-size: 12px; font-weight: 700; opacity: 0.8; }
.chip .chip-name { font-size: 17px; font-weight: 700; margin: 6px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .chip-date { font-size: 12px; font-weight: 600; opacity: 0.75; }
.chip .chip-amount { margin-top: 10px; font-size: 15px; font-weight: 800; }

/* Assistant */
.assistant-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { padding: 10px 13px; border-radius: 12px; font-size: 14px; max-width: 90%; white-space: pre-wrap; }
.msg-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg-bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-card { align-self: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.msg-card h4 { margin: 0 0 8px; }
.msg-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: 14px; }
.msg-card dt { color: var(--muted); }
.msg-card .card-actions { display: flex; gap: 8px; }

.assistant-form { display: flex; gap: 8px; }
.assistant-form input {
  flex: 1; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 15px;
}
.assistant-form input:focus { outline: none; border-color: var(--accent); }

/* Subscription list */
.subs-list { display: flex; flex-direction: column; gap: 10px; }
.sub-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.sub-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.sub-main { flex: 1; min-width: 0; }
.sub-name { font-weight: 600; }
.sub-meta { font-size: 13px; color: var(--muted); }
.sub-amount { font-weight: 700; text-align: right; }
.sub-actions { display: flex; gap: 2px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }
.error { color: var(--danger); font-size: 14px; }

/* Dialog */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 20px;
  width: min(460px, 92vw); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h3 { margin: 0 0 16px; }
dialog label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
dialog input, dialog select {
  padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 15px;
}
dialog input:focus, dialog select:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 12px; }
.row label { flex: 1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
