:root {
  --navy: #10233f;
  --navy-2: #18345b;
  --ink: #172235;
  --muted: #667085;
  --line: #e6eaf0;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --yellow: #f7c967;
  --coral: #ec6f55;
  --teal: #147d75;
  --blue: #3c73c7;
  --danger: #c6423a;
  --radius: 18px;
  --shadow: 0 12px 34px rgba(16, 35, 63, .08);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; min-width: 320px; overflow-x: hidden; touch-action: manipulation; background: radial-gradient(circle at 90% -10%, rgba(247,201,103,.22), transparent 25rem), var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(60,115,199,.3); outline-offset: 2px; }

.shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { background: var(--navy); color: white; padding: 28px 16px 20px; display: flex; flex-direction: column; gap: 28px; }
.brand { padding: 0 12px; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 32px; height: 32px; background: var(--yellow); border-radius: 10px; color: var(--navy); display: grid; place-items: center; font-weight: 850; }
.brand strong { font-size: 18px; letter-spacing: .03em; }
.brand span { display: block; font-size: 12px; color: #b7c5d9; margin-top: 2px; }
.nav { display: grid; gap: 4px; }
.nav button { color: #cbd7e8; background: transparent; border: 0; text-align: left; padding: 11px 12px; border-radius: 10px; display: flex; align-items: center; gap: 11px; font-size: 15px; }
.nav button:hover, .nav button.active { background: rgba(255,255,255,.1); color: #fff; }
.nav .badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; background: var(--coral); color: white; font-size: 12px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; color: #b7c5d9; font-size: 12px; line-height: 1.6; }
.sidebar-foot b { color: var(--yellow); font-weight: 700; }
.sync-status { margin-top: 10px; border: 0; border-radius: 999px; padding: 6px 9px; background: rgba(255,255,255,.1); color: inherit; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.sync-status i { width: 7px; height: 7px; border-radius: 50%; background: #f1bd55; }
.sync-status[data-state="synced"] i { background: #64d59a; }
.sync-status[data-state="syncing"] i { background: #78a9ee; animation: sync-pulse 1s ease-in-out infinite; }
.sync-status[data-state="offline"] i, .sync-status[data-state="error"] i { background: #f1bd55; }
.sync-status[data-state="needs-key"] i { background: #ec6f55; }
.eyebrow .sync-status { display: none; margin: 0 0 0 7px; padding: 4px 7px; background: #e8eef7; color: #66768a; vertical-align: 1px; }
@keyframes sync-pulse { 50% { opacity: .35; } }

.main { min-width: 0; padding: 30px clamp(20px, 4vw, 56px) 88px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 28px; }
.page-title { min-width: 0; }
.back-button { display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; color: var(--blue); padding: 0 0 10px; margin: -3px 0 0 -4px; font-size: 15px; font-weight: 650; }
.back-button:first-letter { font-size: 25px; line-height: 12px; }
.eyebrow { color: var(--blue); font-size: 13px; font-weight: 700; margin-bottom: 7px; }
h1 { margin: 0; font-size: clamp(26px, 3vw, 35px); letter-spacing: -.04em; line-height: 1.18; }
.topbar p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.quick-add, .primary { border: 0; color: white; background: var(--navy); padding: 11px 15px; border-radius: 11px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.quick-add:hover, .primary:hover { background: var(--navy-2); }
.quick-add::before { content: "+"; font-size: 19px; vertical-align: -1px; margin-right: 6px; }
.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 10px 13px; border-radius: 10px; font-weight: 650; font-size: 14px; }
.secondary:hover { border-color: #a8b5c8; }
.danger { color: var(--danger); }

.summary-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 24px; }
.summary { background: rgba(255,255,255,.88); backdrop-filter: blur(18px); box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.75); border-radius: var(--radius); padding: 18px; min-height: 136px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s; }
.summary:hover { transform: translateY(-2px) scale(1.008); box-shadow: 0 16px 36px rgba(16,35,63,.11); }
.summary:active, .entry:active, .primary:active, .secondary:active { transform: scale(.975); }
.summary-main { background: var(--navy); color: white; border: 0; }
.summary label { font-size: 13px; color: var(--muted); font-weight: 650; }
.summary-main label { color: #b7c5d9; }
.summary strong { font-size: 35px; letter-spacing: -.05em; line-height: 1; }
.summary small { font-size: 13px; color: var(--muted); }
.summary-main small { color: #d5e1ef; }
.summary .accent { color: var(--coral); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(290px, .8fr); gap: 18px; align-items: start; }
.panel { background: rgba(255,255,255,.9); backdrop-filter: blur(18px); border: 1px solid rgba(255,255,255,.9); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 19px 20px 15px; }
.panel-header h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.panel-header span { color: var(--muted); font-size: 13px; }
.text-button { border: 0; color: var(--blue); background: none; padding: 3px; font-weight: 700; font-size: 13px; }

.task-list, .compact-list, .module-list { list-style: none; padding: 0; margin: 0; }
.task-row { display: flex; gap: 12px; align-items: center; padding: 13px 20px; border-top: 1px solid var(--line); }
.task-row:hover { background: #fafcff; }
.checkbox { appearance: none; width: 21px; height: 21px; border: 1.7px solid #b5c0cf; border-radius: 7px; flex: 0 0 auto; margin: 0; background: #fff; display: grid; place-content: center; }
.checkbox:checked { background: var(--teal); border-color: var(--teal); }
.checkbox:checked::after { content: "✓"; color: white; font-size: 14px; line-height: 1; }
.task-copy { min-width: 0; flex: 1; }
.task-title { display: block; font-size: 15px; font-weight: 650; line-height: 1.35; }
.task-title.done { color: #9aa7b7; text-decoration: line-through; }
.task-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 5px; font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; background: #edf3fc; color: #3863a6; font-size: 12px; font-weight: 650; }
.chip.overdue { color: #a92b27; background: #fff0ee; }
.chip.today { color: #9b6812; background: #fff8e7; }
.row-menu { border: 0; background: transparent; color: #9aa7b7; font-size: 19px; padding: 4px; }

.side-stack { display: grid; gap: 18px; }
.suggestion { padding: 15px 20px; border-top: 1px solid var(--line); }
.suggestion:first-of-type { border-top: 0; }
.suggestion strong { display: block; font-size: 14px; line-height: 1.45; }
.suggestion p { color: var(--muted); font-size: 12px; margin: 5px 0 10px; }
.suggestion .secondary { padding: 7px 10px; font-size: 12px; }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); font-size: 14px; line-height: 1.65; }

.entry-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); }
.entry { border: 0; background: white; text-align: left; padding: 17px; min-height: 98px; }
.entry:hover { background: #fbfdff; }
.entry-icon { font-size: 20px; margin-bottom: 10px; }
.entry b { display: block; font-size: 14px; }
.entry small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }

.view { display: none; }
.view.active { display: block; animation: page-in .28s cubic-bezier(.2,.85,.25,1); }
@keyframes page-in { from { opacity: 0; transform: translate3d(10px, 4px, 0); } to { opacity: 1; transform: translate3d(0, 0, 0); } }
.module-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.module-toolbar h2 { margin: 0; font-size: 22px; }
.module-toolbar p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter { border: 0; background: #e9eff7; color: #5f6d7d; padding: 7px 11px; border-radius: 999px; font-size: 13px; font-weight: 650; }
.filter.active { color: white; background: var(--navy); }

.form-card { padding: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 700; color: #4d5a6b; }
.voice-hint { color: var(--muted); font-size: 12px; margin-top: -2px; }
input, select, textarea { border: 1px solid #cfd8e5; border-radius: 12px; padding: 10px 13px; color: var(--ink); background: white; min-width: 0; }
input, select { height: 50px; }
select { appearance: none; padding-right: 42px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m4 6 4 4 4-4' stroke='%23172235' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; }
textarea { min-height: 120px; line-height: 1.6; resize: vertical; }
textarea.voice-listening { border-color: var(--coral); background: #fff9f7; box-shadow: 0 0 0 3px rgba(236,111,85,.14); }
textarea.voice-finishing { border-color: var(--yellow); background: #fffdf6; box-shadow: 0 0 0 3px rgba(247,201,103,.18); }
.form-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; margin-top: 16px; }
.form-note { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.form-note strong { color: var(--ink); }
.checklist { display: grid; gap: 9px; padding: 13px; margin-bottom: 14px; background: #f6f8fc; border-radius: 12px; }
.checklist label { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; line-height: 1.45; }
.checklist input { min-width: auto; margin: 2px 0 0; }
.prep-link { padding: 0; border: 0; background: transparent; color: var(--blue); font-size: 12px; font-weight: 700; }

.reflection-editor { padding: 20px; }
.reflection-editor textarea { min-height: min(52vh, 510px); width: 100%; border: 0; padding: 0; border-radius: 0; font-size: 16px; line-height: 1.8; }
.reflection-editor textarea:focus { outline: 0; }
.editor-foot { border-top: 1px solid var(--line); padding-top: 13px; display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; align-items: center; }

.expense-total { padding: 20px; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: white; border-radius: var(--radius); margin-bottom: 17px; }
.expense-total span { color: #cad8ea; font-size: 13px; }
.expense-total strong { display: block; font-size: 34px; margin-top: 7px; letter-spacing: -.05em; }
.expense-table { width: 100%; border-collapse: collapse; }
.expense-table th, .expense-table td { text-align: left; padding: 13px 18px; border-top: 1px solid var(--line); font-size: 14px; }
.expense-table th { color: var(--muted); font-size: 12px; font-weight: 650; background: #fbfcfe; }
.expense-table .amount { font-weight: 750; }
.expense-table input[type="checkbox"] { height: 18px; width: 18px; padding: 0; vertical-align: middle; }

.tool-list .tool-card:first-child { border-top: 0; }
.tool-card { display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 18px 20px; border-top: 1px solid var(--line); }
.tool-card b { display: block; }
.tool-card p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.tool-card small { color: #8b98a8; display: block; margin-top: 6px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 330px; }
.tool-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: #e9f0fa; color: var(--navy); font-size: 19px; font-weight: 800; flex: 0 0 auto; }
.tool-copy { min-width: 0; flex: 1; }
.tool-actions { display: flex; align-items: center; gap: 8px; }
.pending { color: #9b6812; background: #fff8e7; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; }

.modal { position: fixed; inset: 0; display: none; align-items: flex-end; justify-content: center; background: rgba(9,23,43,.36); padding: 20px; z-index: 20; backdrop-filter: blur(3px); overflow-y: auto; overscroll-behavior: contain; }
.modal.show { display: flex; }
.modal-box { width: min(560px, 100%); background: rgba(255,255,255,.98); border-radius: 25px; box-shadow: 0 30px 70px rgba(0,0,0,.22); overflow: hidden; max-height: min(90vh, 760px); max-height: min(calc(100dvh - 40px), 760px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; animation: sheet-in .3s cubic-bezier(.18,.88,.25,1); }
.modal-box::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 99px; background: #d9dfe7; margin: 9px auto -3px; }
@keyframes sheet-in { from { opacity: .2; transform: translateY(30px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-box header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-box header h2 { margin: 0; font-size: 18px; }
.close { border: 0; background: #edf1f6; height: 32px; width: 32px; border-radius: 50%; font-size: 18px; color: #506070; }

#toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); background: #122846; color: white; border-radius: 10px; padding: 10px 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.mobile-nav { display: none; }

@media (max-width: 1000px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { padding-bottom: 0; }
  .shell { min-height: 100dvh; display: block; }
  .sidebar { display: none; }
  .main { min-height: 100dvh; padding: 22px 16px calc(90px + env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 20px; align-items: center; }
  .eyebrow .sync-status { display: inline-flex; }
  .back-button { padding-bottom: 7px; font-size: 14px; }
  .topbar p { display: none; }
  .quick-add { width: 43px; height: 43px; padding: 0; border-radius: 50%; font-size: 0; }
  .quick-add::before { font-size: 26px; margin: 0; }
  .summary-grid { gap: 10px; margin-bottom: 16px; }
  .summary { border-radius: 15px; min-height: 114px; padding: 15px; }
  .summary strong { font-size: 29px; }
  .summary small { font-size: 12px; }
  .dashboard-grid, .side-stack { gap: 14px; }
  .panel { border-radius: 15px; }
  .panel-header, .task-row { padding-left: 16px; padding-right: 16px; }
  .entry-grid { grid-template-columns: 1fr 1fr; }
  .mobile-nav { position: fixed; inset: auto 0 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr); padding: 7px max(11px, env(safe-area-inset-left)) calc(7px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(14px); }
  .mobile-nav button { border: 0; background: transparent; color: #7b899b; padding: 4px 0; font-size: 11px; display: grid; gap: 2px; place-items: center; }
  .mobile-nav button i { font-style: normal; font-size: 18px; line-height: 20px; }
  .mobile-nav button.active { color: var(--navy); font-weight: 750; }
  .mobile-nav .capture { margin-top: -22px; background: var(--navy); color: white; width: 50px; height: 50px; border-radius: 50%; justify-self: center; display: grid; place-items: center; box-shadow: 0 8px 18px rgba(16,35,63,.26); font-size: 25px; }
  .mobile-nav .capture span { display: none; }
  .tool-card { padding: 15px 16px; align-items: flex-start; }
  .tool-icon { width: 36px; height: 36px; border-radius: 11px; }
  .tool-card small { max-width: 150px; }
  .tool-actions .primary { padding: 9px 11px; }
  .modal { padding: 8px; }
  .modal-box { max-height: calc(100dvh - 16px); border-radius: 23px 23px 18px 18px; }
  .form-grid { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }
  .field.full { grid-column: auto; }
  .expense-table th:nth-child(2), .expense-table td:nth-child(2) { display: none; }
  .expense-table { table-layout: fixed; }
  .expense-table th, .expense-table td { padding: 11px 8px; overflow-wrap: anywhere; }
  .expense-table th:first-child { width: 32%; }
  .expense-table th:nth-child(3) { width: 32%; }
  .expense-table th:nth-child(4) { width: 23%; }
  .expense-table th:last-child { width: 13%; }
  .editor-foot { flex-wrap: wrap; }
}
