/* ============================================================
   Roan's Life Dashboard — design tokens & base styles
   Light & calm (Notion-like), warm paper, coral accent.
   ============================================================ */

:root {
  /* Apple-like neutral light theme — soft, low-vibrance */
  --bg:            #F5F5F7;
  --bg-2:          #ECECEF;
  --surface:       #FFFFFF;
  --surface-2:     #FAFAFB;
  --surface-3:     #F0F0F3;
  --border:        #E7E7EA;
  --border-strong: #D9D9DE;
  --text:          #1D1D1F;
  --text-2:        #6E6E73;
  --text-3:        #A7A7AC;
  --accent:        #E27A5E;
  --accent-deep:   #CF6A4E;
  --accent-weak:   rgba(226,122,94,0.11);
  --accent-soft:   rgba(226,122,94,0.055);

  /* category palette — very muted, almost grey-tinted */
  --sage:   #7aaa93;
  --blue:   #7a9ec4;
  --amber:  #c9a05a;
  --lilac:  #9e8fc0;
  --rose:   #c28fa2;
  --teal:   #6aa0a8;

  --good:   #7aaa93;
  --warn:   #c9a05a;
  --bad:    #c97a6b;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.025);
  --shadow:    0 1px 3px rgba(0,0,0,0.03), 0 8px 32px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.05), 0 24px 50px rgba(0,0,0,0.06);

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 22px;

  --font: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --sidebar-w: 76px;
  --maxw: 1380px;
}

[data-theme="dark"] {
  /* Apple-like neutral dark theme */
  --bg:            #1C1C1E;
  --bg-2:          #242426;
  --surface:       #2C2C2E;
  --surface-2:     #323234;
  --surface-3:     #3A3A3C;
  --border:        #3A3A3C;
  --border-strong: #48484A;
  --text:          #F5F5F7;
  --text-2:        #9E9EA4;
  --text-3:        #6E6E73;
  --accent:        #FF8A6B;
  --accent-deep:   #FF9D81;
  --accent-weak:   rgba(255,138,107,0.16);
  --accent-soft:   rgba(255,138,107,0.08);

  --sage:   #74BBA0;
  --blue:   #7FA8E8;
  --amber:  #E0B068;
  --lilac:  #AE9BD8;
  --rose:   #E29DB2;
  --teal:   #76BAC2;

  --good:   #74BBA0;
  --warn:   #E0B068;
  --bad:    #E58A78;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow:    0 1px 3px rgba(0,0,0,0.45), 0 8px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.5), 0 24px 50px rgba(0,0,0,0.45);
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.4s ease, color 0.4s ease;
}

::selection { background: var(--accent-weak); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; letter-spacing: -0.02em; }

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 20;
}
.sb-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px;
  margin-bottom: 14px;
  letter-spacing: -0.03em;
}
.sb-item {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: var(--text-3);
  position: relative;
  transition: color 0.18s, background 0.18s;
}
.sb-item:hover { color: var(--text); background: var(--surface-3); }
.sb-item.active { color: var(--accent); background: var(--accent-weak); }
.sb-item svg { width: 21px; height: 21px; }
.sb-tip {
  position: absolute; left: 56px; top: 50%; transform: translateY(-50%) translateX(-6px);
  background: var(--text); color: var(--bg);
  padding: 5px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: all 0.16s; z-index: 40;
}
.sb-item:hover .sb-tip { opacity: 1; transform: translateY(-50%) translateX(0); }
.sb-spacer { flex: 1; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px clamp(20px, 4vw, 48px) 64px;
}
.main-inner { max-width: var(--maxw); margin: 0 auto; }

/* ============================================================
   Topbar / greeting
   ============================================================ */
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 26px;
  flex-wrap: wrap;
}
.greet-eyebrow { font-size: 13px; color: var(--text-2); font-weight: 600; letter-spacing: 0.01em; }
.greet-title { font-size: clamp(26px, 3.4vw, 36px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.08; margin-top: 3px; }
.greet-title .wave { display: inline-block; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  box-shadow: var(--shadow-sm);
}
.pill svg { width: 16px; height: 16px; color: var(--text-3); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text-2);
  box-shadow: var(--shadow-sm); transition: all 0.18s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; }
.avatar {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--lilac));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Bento grid + cards
   ============================================================ */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
  align-items: stretch;
}
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: box-shadow 0.3s, background 0.4s;
}
.card:hover { box-shadow: var(--shadow); }
.card-accent { background: linear-gradient(160deg, var(--accent) 0%, var(--accent-deep) 100%); border-color: transparent; color: #fff; }
.card-accent .wh-title, .card-accent .wh-sub { color: rgba(255,255,255,0.9); }

.wh { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.wh-l { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.wh-ico {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3);
}
.wh-ico svg { width: 15px; height: 15px; }
.wh-title { font-size: 13.5px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wh-sub { font-size: 11.5px; color: var(--text-3); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wh-action {
  font-size: 12.5px; font-weight: 600; color: var(--text-3); flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 8px; transition: all 0.16s;
}
.wh-action:hover { color: var(--accent); background: var(--accent-weak); }
.wh-action svg { width: 15px; height: 15px; }

/* chips & badges */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  background: var(--surface-3); color: var(--text-2);
}
.chip.up { background: rgba(79,166,138,0.14); color: var(--good); }
.chip.down { background: rgba(221,107,91,0.14); color: var(--bad); }
.chip svg { width: 12px; height: 12px; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* generic small label */
.lbl { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.big-num { font-family: var(--mono); font-weight: 600; letter-spacing: -0.03em; }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  font-size: 12px; font-weight: 650; color: var(--text-2);
  padding: 5px 11px; border-radius: 7px; transition: all 0.16s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* progress bar */
.bar { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; transition: width 0.5s cubic-bezier(.4,0,.2,1); opacity: 0.85; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  font-size: 13.5px; font-weight: 650; transition: all 0.16s;
  background: var(--surface-3); color: var(--text);
}
.btn:hover { background: var(--border); }
.btn svg { width: 16px; height: 16px; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-deep); }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.round-btn {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2); transition: all 0.15s;
}
.round-btn:hover { background: var(--border); color: var(--text); }
.round-btn svg { width: 16px; height: 16px; }

/* entrance: translate-only so paused/throttled iframes never hide content */
.fade-in { animation: fadeUp 0.55s cubic-bezier(.2,.7,.3,1) both; }
@keyframes fadeUp { from { transform: translateY(12px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } }

/* ============================================================
   Habit / task row delete affordance
   ============================================================ */
.habit-row { position: relative; }
.row-del {
  width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center; color: var(--text-3);
  background: transparent; opacity: 0; transition: all 0.15s; margin-left: 2px;
}
.habit-row:hover .row-del, .todo-row:hover .todo-del { opacity: 1; }
.row-del:hover, .todo-del:hover { background: rgba(210,122,107,0.14); color: var(--bad); }
.todo-del { opacity: 0; transition: opacity 0.15s; }

/* ============================================================
   Settings modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10,10,14,0.62); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: grid; place-items: center; padding: 24px;
  animation: ovIn 0.2s ease;
}
@keyframes ovIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: var(--shadow-lg); animation: modIn 0.26s cubic-bezier(.2,.7,.3,1);
}
@keyframes modIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 14px; position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.modal-title { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.modal-body { padding: 4px 22px 24px; display: grid; gap: 22px; }
.set-group { display: grid; gap: 2px; }
.set-group-lbl { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 4px 8px; }
.set-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 16px; min-height: 54px;
}
.set-row + .set-row { border-top: 1px solid var(--border); }
.set-row-label { font-size: 14px; font-weight: 600; }
.set-row-sub { font-size: 12px; color: var(--text-3); font-weight: 500; margin-top: 1px; }
.set-input {
  height: 38px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 0 12px; font-size: 14px; font-weight: 600; outline: none; min-width: 0; flex: 1; max-width: 200px;
}
.set-input:focus { border-color: var(--accent); }
.swatches { display: flex; gap: 10px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; position: relative; transition: transform 0.15s;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}
.swatch:hover { transform: scale(1.1); }
.swatch.on { box-shadow: 0 0 0 2.5px var(--surface), 0 0 0 4.5px currentColor; }
.swatch.on::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 9px; height: 9px;
  border-radius: 50%; background: #fff; box-shadow: 0 0 2px rgba(0,0,0,0.3);
}
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-3); border-radius: 10px; padding: 3px; }
.stepper button { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); }
.stepper button:hover { background: var(--surface); color: var(--text); }
.stepper .val { min-width: 34px; text-align: center; font-weight: 700; font-family: var(--mono); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  .col-7, .col-8 { grid-column: span 12; }
  .col-5 { grid-column: span 6; }
  .col-4 { grid-column: span 6; }
  .col-3 { grid-column: span 6; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .bento { grid-template-columns: repeat(6, 1fr); }
  .col-3, .col-4, .col-5, .col-6, .col-7, .col-8 { grid-column: span 6; }
  .main { padding: 20px 16px 48px; }
}

/* ============================================================
   Skeletons & spinners (loading states for async data)
   ============================================================ */
.skel {
  background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -40% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  display: inline-block; animation: spin 0.7s linear infinite; vertical-align: -2px;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; color: var(--text-3); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Wide modal + detail content
   ============================================================ */
.modal-lg { max-width: 660px; }
.detail-hero {
  display: flex; gap: 24px; align-items: flex-end; flex-wrap: wrap;
  padding: 18px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px;
}
.detail-sec-lbl {
  font-size: 11.5px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px;
}
.detail-list { display: flex; flex-direction: column; }

/* transaction rows */
.txn-row { display: flex; align-items: center; gap: 11px; padding: 9px 14px; }
.txn-row + .txn-row { border-top: 1px solid var(--border); }
.txn-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.txn-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-sub { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.txn-amt { font-size: 13px; font-weight: 600; flex-shrink: 0; }

/* expandable account / category blocks */
.acc-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; transition: border-color .15s; }
.acc-head, .cat-head {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: none; text-align: left; transition: background .15s;
}
.acc-head:hover, .cat-head:hover { background: var(--surface-3); }
.cat-head { gap: 10px; }

/* budget summary stats */
.budget-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bstat { padding: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; }
.bstat .lbl { margin-bottom: 6px; }
@media (max-width: 560px) { .budget-stats { grid-template-columns: repeat(2, 1fr); } }

/* event detail rows */
.evt-row { display: flex; align-items: flex-start; gap: 12px; }
.evt-row > svg { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; margin-top: 1px; }
.evt-main { font-size: 14px; font-weight: 600; }
.evt-sub { font-size: 12px; color: var(--text-3); font-weight: 600; margin-top: 1px; }

/* accounts mini-card hover (dashboard) */
.acc-mini:hover { border-color: var(--border-strong) !important; }

/* ============================================================
   Google Calendar — connect state, button, legend
   ============================================================ */
.cal-connect {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 36px 24px; min-height: 320px; gap: 4px;
}
.cal-connect-glyph {
  width: 66px; height: 66px; border-radius: 18px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.cal-connect-title { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.cal-connect-sub { font-size: 13px; color: var(--text-2); font-weight: 500; max-width: 340px; line-height: 1.45; margin: 6px 0 18px; }
.cal-connect-note { font-size: 11.5px; color: var(--text-3); font-weight: 600; margin-top: 12px; }

.g-btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 22px; border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 650;
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); transition: all 0.16s;
}
.g-btn:hover:not(:disabled) { background: var(--surface-2); transform: translateY(-1px); box-shadow: var(--shadow); }
.g-btn:disabled { opacity: 0.7; cursor: default; }
.g-btn-sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 9px; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cal-toggle-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 240px; }
.cal-leg {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 650; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); transition: all 0.15s;
}
.cal-leg:hover { border-color: var(--border-strong); }
.cal-leg.off { color: var(--text-3); opacity: 0.55; text-decoration: line-through; }
.cal-leg-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
