:root{
  --bg:#f3f6fb;
  --panel:#ffffff;
  --panel-2:#f8fafc;
  --text:#111827;
  --sub:#6b7280;
  --line:#e5e7eb;
  --primary:#4f46e5;
  --primary-2:#6366f1;
  --success:#10b981;
  --danger:#ef4444;
  --warning:#f59e0b;
  --shadow:0 12px 32px rgba(15,23,42,.08);
  --radius:18px;
  --heat-0:#ebedf0;
  --heat-1:#c6f6d5;
  --heat-2:#86efac;
  --heat-3:#22c55e;
  --heat-4:#15803d;
  --cal-empty:#f3f4f6;
  --cal-partial:#fef3c7;
  --cal-done:#d1fae5;
}

body.dark{
  --bg:#0b1220;
  --panel:#111827;
  --panel-2:#0f172a;
  --text:#f3f4f6;
  --sub:#94a3b8;
  --line:#243041;
  --primary:#7c83ff;
  --primary-2:#6366f1;
  --success:#34d399;
  --danger:#f87171;
  --warning:#fbbf24;
  --shadow:0 18px 40px rgba(0,0,0,.35);
  --heat-0:#1f2937;
  --heat-1:#164e2c;
  --heat-2:#166534;
  --heat-3:#16a34a;
  --heat-4:#22c55e;
  --cal-empty:#17202e;
  --cal-partial:#5c4212;
  --cal-done:#123d31;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:"PingFang SC","Microsoft YaHei",Arial,sans-serif;
  background:linear-gradient(180deg,var(--bg),var(--bg));
  color:var(--text);
}

button,input,select,textarea{font:inherit}

.app-shell{
  min-height:100vh;
  display:grid;
  grid-template-columns:260px 1fr;
  overflow:hidden;
}

.sidebar{
  border-right:1px solid var(--line);
  background:linear-gradient(180deg,var(--panel),var(--panel-2));
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:16px;
}

.brand{
  padding:10px 8px 4px;
  display:flex;
  gap:12px;
  align-items:flex-start;
}

.brand-mark{
  width:42px;
  height:42px;
  border-radius:14px;
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  color:#fff;
  display:grid;
  place-items:center;
  font-weight:700;
  box-shadow:var(--shadow);
}

.brand h1{
  margin:0;
  font-size:22px;
  line-height:1.2;
}

.brand p{
  margin:8px 0 0;
  color:var(--sub);
  font-size:13px;
  line-height:1.5;
}

.nav{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.nav-btn,.tabbar-btn{
  border:none;
  cursor:pointer;
  transition:.2s;
}

.nav-btn{
  width:100%;
  text-align:left;
  background:transparent;
  color:var(--text);
  padding:12px 14px;
  border-radius:14px;
  font-size:14px;
}

.nav-btn:hover{background:rgba(99,102,241,.08)}
.nav-btn.active,
.tabbar-btn.active{
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  color:#fff;
  box-shadow:var(--shadow);
}

.side-card,
.card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:16px;
  box-shadow:var(--shadow);
}

.side-card{padding:14px}
.side-title{
  font-size:13px;
  color:var(--sub);
  margin-bottom:8px;
}

.quick-stats{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.mini-stat{
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
}
.mini-stat .k{
  color:var(--sub);
  font-size:12px;
  margin-bottom:6px;
}
.mini-stat .v{
  font-size:20px;
  font-weight:700;
}

.side-note,
.info-text,
.help-text{
  font-size:13px;
  line-height:1.7;
}

.main-shell{
  display:flex;
  flex-direction:column;
  overflow:hidden;
  min-width:0;
}

.topbar{
  min-height:72px;
  border-bottom:1px solid var(--line);
  background:rgba(255,255,255,.5);
  backdrop-filter:blur(10px);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 20px;
  gap:16px;
}
body.dark .topbar{background:rgba(17,24,39,.6)}

.topbar-left h2{
  margin:4px 0 0;
  font-size:22px;
}
.topbar-left p{
  margin:6px 0 0;
  color:var(--sub);
  font-size:13px;
}

.eyebrow{
  color:var(--primary);
  font-size:12px;
  font-weight:700;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.mobile-summary-card{
  display:none;
  align-items:center;
  gap:10px;
  margin:12px 20px 0;
  padding:10px 12px;
  border:1px solid rgba(99,102,241,.12);
  border-radius:16px;
  background:linear-gradient(135deg,rgba(99,102,241,.05),rgba(16,185,129,.04));
  box-shadow:0 8px 20px rgba(15,23,42,.05);
}

.mobile-summary-pill{
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:52px;
  height:28px;
  padding:0 10px;
  border-radius:999px;
  background:rgba(99,102,241,.12);
  color:var(--primary);
  font-size:11px;
  font-weight:700;
  letter-spacing:.04em;
}

.mobile-summary-copy{
  min-width:0;
}

.mobile-summary-card strong{
  display:block;
  margin:0;
  font-size:13px;
  line-height:1.35;
}

.mobile-summary-card p{
  margin:2px 0 0;
  font-size:12px;
  line-height:1.45;
}

.offline-banner{
  margin:16px 20px 0;
  padding:12px 16px;
  border:1px solid rgba(245,158,11,.35);
  border-radius:16px;
  background:rgba(245,158,11,.12);
  color:var(--text);
  font-size:13px;
  line-height:1.7;
}

.dashboard-stack{
  display:flex;
  flex-direction:column;
  gap:18px;
}
.dashboard-grid{
  display:grid;
  grid-template-columns:1.2fr 1fr;
  gap:18px;
}
.dashboard-hero{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:center;
  background:linear-gradient(135deg,rgba(99,102,241,.16),rgba(16,185,129,.1));
}
.dashboard-hero-copy h3{
  margin:6px 0 10px;
  font-size:28px;
}
.dashboard-hero-copy p{
  margin:0;
  color:var(--sub);
  line-height:1.7;
}
.dashboard-hero-pill{
  display:flex;
  flex-direction:column;
  gap:10px;
  min-width:180px;
}
.dashboard-hero-pill span,
.dashboard-badge,
.dashboard-suggestion-card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:16px;
  box-shadow:var(--shadow);
}
.dashboard-hero-pill span{
  padding:12px 14px;
  font-weight:700;
}
.dashboard-cards{
  margin-bottom:0;
}
.dashboard-suggestion{
  display:flex;
  flex-direction:column;
}
.dashboard-suggestion-card{
  padding:16px;
}
.dashboard-suggestion-card p{
  margin:10px 0 12px;
  color:var(--sub);
  line-height:1.8;
}
.dashboard-suggestion-meta{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.dashboard-badges{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.dashboard-badge{
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px;
}
.dashboard-badge p{
  margin:6px 0 0;
  color:var(--sub);
  font-size:13px;
}
.dashboard-badge-icon{
  width:44px;
  height:44px;
  border-radius:14px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  color:#fff;
  font-size:20px;
  flex:0 0 auto;
}
.dashboard-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}
.dashboard-link{
  width:100%;
}
.task-view-switch{
  display:flex;
  gap:10px;
  padding:6px;
  border-radius:16px;
  background:var(--panel-2);
  border:1px solid var(--line);
}
.task-view-btn{
  flex:1;
  border:none;
  background:transparent;
  color:var(--sub);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  transition:.2s;
}
.task-view-btn.active{
  color:#fff;
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  box-shadow:var(--shadow);
}
.week-view-grid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:12px;
  margin-bottom:18px;
}
.week-day-card{
  border:1px solid var(--line);
  background:var(--panel-2);
  border-radius:18px;
  padding:14px;
  text-align:left;
  cursor:pointer;
  color:var(--text);
  transition:.2s;
}
.week-day-card.active{
  background:linear-gradient(135deg,rgba(99,102,241,.14),rgba(16,185,129,.1));
  border-color:rgba(99,102,241,.35);
}
.week-day-top,
.week-day-stats{
  display:flex;
  justify-content:space-between;
  gap:10px;
}
.week-day-label{
  font-size:13px;
  color:var(--sub);
  margin-bottom:4px;
}
.week-day-date{
  font-size:18px;
  font-weight:700;
}
.week-day-stats{
  margin:14px 0 10px;
}
.week-day-stats div{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.week-day-stats span,
.week-day-preview{
  color:var(--sub);
  font-size:12px;
}
.week-day-preview{
  display:flex;
  flex-direction:column;
  gap:6px;
  line-height:1.5;
}
.timeline-list{
  display:flex;
  flex-direction:column;
  gap:14px;
}
.timeline-item{
  display:grid;
  grid-template-columns:78px 24px 1fr;
  gap:12px;
  align-items:stretch;
}
.timeline-time{
  font-size:16px;
  font-weight:700;
  color:var(--text);
  padding-top:14px;
}
.timeline-line{
  display:flex;
  justify-content:center;
}
.timeline-line span{
  width:2px;
  background:linear-gradient(180deg,var(--primary),transparent);
  border-radius:999px;
  position:relative;
}
.timeline-line span::before{
  content:"";
  position:absolute;
  top:16px;
  left:50%;
  width:12px;
  height:12px;
  border-radius:50%;
  transform:translateX(-50%);
  background:var(--primary);
  box-shadow:0 0 0 4px rgba(99,102,241,.12);
}
.timeline-card{
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:18px;
  padding:14px;
}
.timeline-card-top{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
}
.timeline-check{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  color:var(--sub);
  font-size:12px;
}
.timeline-item.overdue .timeline-line span::before{background:var(--danger)}
.timeline-item.upcoming .timeline-line span::before{background:var(--warning)}
.timeline-item.done .timeline-line span::before{background:var(--success)}

.row,
.toolbar,
.form-row,
.filter-toolbar,
.weekday-picker{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.form-stack{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.topbar-tools{
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  align-items:flex-end;
  gap:10px;
  width:min(100%, 640px);
}

.topbar-mobile-entry{
  display:none;
}

.topbar-actions{
  justify-content:flex-end;
  gap:12px;
  width:min(100%, 640px);
}

.topbar-action-group{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px;
  border-radius:18px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(255,255,255,.7);
  box-shadow:0 10px 24px rgba(15,23,42,.06);
  backdrop-filter:blur(14px) saturate(1.1);
}

body.dark .topbar-action-group{
  background:rgba(15,23,42,.72);
  border-color:rgba(148,163,184,.14);
  box-shadow:0 14px 28px rgba(0,0,0,.24);
}

.topbar-action-group-neutral{
  background:linear-gradient(180deg,rgba(255,255,255,.72),rgba(248,250,252,.88));
}

.topbar-action-group-accent{
  background:linear-gradient(180deg,rgba(99,102,241,.08),rgba(79,70,229,.12));
  border-color:rgba(99,102,241,.16);
}

body.dark .topbar-action-group-neutral{
  background:linear-gradient(180deg,rgba(15,23,42,.78),rgba(17,24,39,.92));
}

body.dark .topbar-action-group-accent{
  background:linear-gradient(180deg,rgba(99,102,241,.16),rgba(79,70,229,.22));
  border-color:rgba(129,140,248,.22);
}

.topbar-tool-btn{
  min-height:42px;
  padding:0 16px;
  border-radius:14px;
  font-size:13px;
  font-weight:600;
  letter-spacing:.01em;
  box-shadow:none;
  white-space:nowrap;
}

.topbar-tool-btn.btn,
.topbar-tool-btn.btn-success{
  box-shadow:0 10px 20px rgba(99,102,241,.16);
}

.topbar-tool-btn.btn{
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
}

.topbar-tool-btn.btn-success{
  background:linear-gradient(135deg,rgba(79,70,229,.12),rgba(99,102,241,.18));
  color:var(--primary);
  border:1px solid rgba(99,102,241,.18);
}

body.dark .topbar-tool-btn.btn-success{
  background:linear-gradient(135deg,rgba(124,131,255,.18),rgba(99,102,241,.28));
  color:#eef2ff;
  border-color:rgba(129,140,248,.26);
}

.topbar-tool-btn.btn-ghost{
  background:transparent;
  border:1px solid transparent;
  color:var(--text);
}

.topbar-tool-btn.btn-ghost:hover{
  background:rgba(99,102,241,.08);
  border-color:rgba(99,102,241,.12);
}

.topbar-status-btn{
  color:var(--sub);
}

.topbar-status-btn:disabled{
  cursor:default;
  opacity:1;
  color:var(--sub);
  background:rgba(148,163,184,.1);
  border-color:rgba(148,163,184,.14);
  box-shadow:none;
}

body.dark .topbar-status-btn:disabled{
  background:rgba(148,163,184,.08);
  border-color:rgba(148,163,184,.12);
}

.import-label{
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.topbar-mobile-entry{
  align-items:center;
  justify-content:space-between;
  gap:10px;
  width:100%;
}

.topbar-mobile-entry-main{
  min-width:0;
  display:flex;
  align-items:center;
  gap:8px;
}

.topbar-mobile-entry-badge{
  display:inline-flex;
  align-items:center;
  height:28px;
  padding:0 10px;
  border-radius:999px;
  background:rgba(99,102,241,.1);
  color:var(--primary);
  font-size:11px;
  font-weight:700;
  letter-spacing:.04em;
  white-space:nowrap;
}

.topbar-mobile-entry-summary{
  min-width:0;
  color:var(--sub);
  font-size:12px;
  font-weight:600;
  white-space:nowrap;
}

.topbar-mobile-toggle-icon{
  flex:0 0 auto;
  font-size:14px;
  line-height:1;
  transition:transform .28s ease;
}

.btn,.btn-ghost,.btn-danger,.btn-success,.btn-warning{
  border:none;
  border-radius:12px;
  padding:10px 14px;
  cursor:pointer;
  transition:.2s;
}
.btn{
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  color:#fff;
}
.btn:hover{transform:translateY(-1px)}
.btn-ghost{
  background:var(--panel);
  color:var(--text);
  border:1px solid var(--line);
}
.btn-success{background:var(--success);color:#fff}
.btn-danger{background:var(--danger);color:#fff}
.btn-warning{background:var(--warning);color:#111827}

.content{
  overflow:auto;
  padding:20px;
  padding-bottom:100px;
}

.tab{display:none}
.tab.active{display:block}

.cards{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:14px;
  margin-bottom:18px;
}

.card{
  border-radius:var(--radius);
  padding:16px;
}

.card-title{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:12px;
}
.card-title h3{
  margin:0;
  font-size:17px;
}
.card-title .sub{
  color:var(--sub);
  font-size:12px;
}

.stat-card .k{
  color:var(--sub);
  font-size:13px;
  margin-bottom:8px;
}
.stat-card .v{
  font-size:28px;
  font-weight:700;
}

.grid-2{
  display:grid;
  grid-template-columns:1.25fr .95fr;
  gap:18px;
}
.grid-2-eq,
.habit-grid,
.report-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px;
}

input[type="date"],
input[type="month"],
input[type="time"],
input[type="text"],
select,
textarea{
  background:var(--panel-2);
  color:var(--text);
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
}
input[type="text"]{flex:1;min-width:180px}
.check-inline{
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:42px;
  padding:0 4px;
  color:var(--text);
}
.check-inline input{
  width:16px;
  height:16px;
  margin:0;
}
.filter-toolbar{
  margin-top:14px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--panel-2);
}
.weekday-picker{
  gap:8px;
}
.weekday-picker label{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--panel-2);
  font-size:12px;
  color:var(--sub);
}
textarea{
  width:100%;
  min-height:130px;
  resize:vertical;
}
.color-input{
  width:56px;
  padding:6px;
}

.progress-wrap{margin:14px 0 10px}
.progress-label{
  display:flex;
  justify-content:space-between;
  font-size:13px;
  color:var(--sub);
  margin-bottom:8px;
}
.progress{
  height:14px;
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:999px;
  overflow:hidden;
}
.progress-inner{
  height:100%;
  width:0;
  background:linear-gradient(90deg,var(--success),var(--primary));
  transition:.25s;
}

.section-gap{margin-top:16px}
.section-inline-gap{margin-bottom:10px}

.group-title{
  margin:14px 0 10px;
  color:var(--sub);
  font-size:13px;
  font-weight:700;
  letter-spacing:.5px;
}

.list,
.report-list,
.history,
.habit-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.item,
.history-item,
.report-item{
  background:var(--panel-2);
  border:1px solid var(--line);
}

.item{
  display:flex;
  gap:12px;
  align-items:flex-start;
  border-radius:16px;
  padding:12px;
}
.item.completed{background:rgba(16,185,129,.08)}

.item-main{
  flex:1;
  min-width:0;
}

.item-title{
  font-weight:700;
  line-height:1.5;
  word-break:break-all;
}
.completed .item-title{
  text-decoration:line-through;
  color:var(--sub);
}

.item-meta{
  color:var(--sub);
  font-size:12px;
  margin-top:6px;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}

.tag{
  display:inline-flex;
  align-items:center;
  padding:4px 10px;
  border-radius:999px;
  background:rgba(99,102,241,.1);
  color:var(--primary);
  font-size:12px;
}

.item-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.tiny{
  padding:7px 10px;
  border-radius:10px;
  font-size:12px;
  border:none;
  cursor:pointer;
}
.tiny.edit{background:rgba(99,102,241,.12);color:var(--primary)}
.tiny.del{background:rgba(239,68,68,.12);color:var(--danger)}

.calendar-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:12px;
  flex-wrap:wrap;
}

.calendar{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:8px;
}
.week{
  text-align:center;
  color:var(--sub);
  font-size:12px;
  font-weight:700;
  padding:4px 0;
}
.day{
  min-height:86px;
  border:1px solid var(--line);
  border-radius:16px;
  padding:8px;
  background:var(--cal-empty);
  cursor:pointer;
  transition:.15s;
}
.day:hover{transform:translateY(-1px)}
.day.other{opacity:.35}
.day.done{background:var(--cal-done)}
.day.partial{background:var(--cal-partial)}
.day.active{outline:2px solid var(--primary)}
.day .d{font-weight:700;margin-bottom:6px}
.day .m{font-size:12px;color:var(--sub);line-height:1.4}
.calendar-tip{font-size:12px}

.history{max-height:420px;overflow:auto}
.history-item{
  padding:12px;
  border-radius:14px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
}

.habit-list{
  max-height:560px;
  overflow:auto;
  padding-right:2px;
}
.habit-card{
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px;
}
.habit-top{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
}
.habit-name{
  font-size:16px;
  font-weight:700;
  line-height:1.5;
}
.habit-badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  margin-top:8px;
  color:var(--sub);
}
.habit-badge::before{
  content:"";
  width:10px;
  height:10px;
  border-radius:50%;
  background:var(--dot,#4f46e5);
  display:inline-block;
}
.habit-reminder-text{
  margin-top:8px;
  color:var(--sub);
  font-size:12px;
}

.habit-stats{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:10px;
  margin-top:14px;
}
.habit-stat{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
}
.habit-stat .k{
  color:var(--sub);
  font-size:11px;
  margin-bottom:5px;
}
.habit-stat .v{
  font-size:18px;
  font-weight:700;
}

.heatmap-wrap{
  overflow:auto;
  padding-bottom:6px;
}
.heatmap{
  display:grid;
  grid-auto-flow:column;
  grid-template-rows:repeat(7,14px);
  grid-auto-columns:14px;
  gap:4px;
  align-items:center;
  min-width:max-content;
  padding:8px 0;
}
.heat{
  width:14px;
  height:14px;
  border-radius:4px;
  background:var(--heat-0);
  border:1px solid rgba(0,0,0,.04);
  cursor:pointer;
}
.lv0{background:var(--heat-0)}
.lv1{background:var(--heat-1)}
.lv2{background:var(--heat-2)}
.lv3{background:var(--heat-3)}
.lv4{background:var(--heat-4)}

.report-item{
  padding:12px;
  border-radius:14px;
}

.chart-box{
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--panel-2);
  padding:12px;
}
canvas{
  width:100%;
  max-width:100%;
  display:block;
}

.muted{color:var(--sub)}
.empty{
  color:var(--sub);
  text-align:center;
  padding:28px 0;
}

.modal-mask{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.45);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:999;
  padding:20px;
}
.modal-mask.show{display:flex}
.modal{
  width:min(560px,100%);
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:0 30px 80px rgba(0,0,0,.25);
  overflow:hidden;
}
.modal-head{
  padding:18px 18px 12px;
  border-bottom:1px solid var(--line);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}
.modal-head h3{
  margin:0;
  font-size:18px;
}
.modal-body{
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:14px;
}
.modal-foot{
  padding:0 18px 18px;
  display:flex;
  justify-content:flex-end;
  gap:10px;
}
.field{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.field label{
  font-size:13px;
  color:var(--sub);
}
.close-x{
  border:none;
  background:transparent;
  color:var(--sub);
  font-size:20px;
  cursor:pointer;
}

.mobile-tabbar{
  display:none;
  position:fixed;
  left:12px;
  right:12px;
  bottom:12px;
  z-index:100;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(255,255,255,.92);
  backdrop-filter:blur(20px) saturate(1.2);
  border-radius:26px;
  padding:10px 10px calc(10px + env(safe-area-inset-bottom));
  box-shadow:0 16px 40px rgba(15,23,42,.16);
  grid-template-columns:repeat(5,1fr);
  gap:8px;
}
body.dark .mobile-tabbar{
  background:rgba(17,24,39,.94);
  box-shadow:0 18px 40px rgba(0,0,0,.45);
}

.tabbar-btn{
  background:transparent;
  color:var(--sub);
  border-radius:18px;
  padding:10px 6px 8px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  font-size:11px;
  min-height:58px;
}
.tabbar-btn.active{
  transform:translateY(-2px);
}
.tabbar-icon{
  font-size:18px;
  line-height:1;
}

@media (max-width:1100px){
  .app-shell{grid-template-columns:1fr}
  .sidebar{display:none}
  .cards{grid-template-columns:repeat(2,1fr)}
  .grid-2,.grid-2-eq,.habit-grid,.report-grid,.dashboard-grid{grid-template-columns:1fr}
  .week-view-grid{grid-template-columns:repeat(2,1fr)}
  .mobile-summary-card{display:block}
  .mobile-tabbar{display:grid}
}

@media (max-width:720px){
  .content{padding:14px;padding-bottom:124px}
  .topbar{
    height:auto;
    padding:10px 14px;
    align-items:flex-start;
    flex-direction:column;
    gap:8px;
  }
  .topbar-left h2{
    font-size:20px;
  }
  .topbar-left p{
    margin-top:4px;
    font-size:12px;
  }
  .cards{grid-template-columns:1fr}
  .toolbar,.form-row,.row,.dashboard-hero,.timeline-card-top{flex-direction:column;align-items:stretch}
  input,select,textarea,.btn,.btn-ghost,.btn-danger,.btn-success,.btn-warning,.import-label{width:100%}
  .topbar-tools{
    width:100%;
    align-items:stretch;
    gap:6px;
    padding:5px 6px;
    border:1px solid rgba(148,163,184,.16);
    border-radius:16px;
    background:rgba(255,255,255,.7);
    box-shadow:0 8px 18px rgba(15,23,42,.05);
    backdrop-filter:blur(12px) saturate(1.06);
  }
  body.dark .topbar-tools{
    background:rgba(15,23,42,.76);
    border-color:rgba(148,163,184,.14);
    box-shadow:0 14px 28px rgba(0,0,0,.24);
  }
  .topbar-mobile-entry{
    display:flex;
    align-items:center;
    justify-content:space-between;
    min-height:36px;
    padding:4px 6px 4px 4px;
    border:none;
    border-radius:12px;
    background:transparent;
    box-shadow:none;
    color:var(--text);
    text-align:left;
    gap:8px;
  }
  .topbar-mobile-entry:hover{
    background:rgba(99,102,241,.05);
    border-color:transparent;
  }
  .topbar-tools.is-mobile-collapsed{
    padding-bottom:4px;
    background:rgba(255,255,255,.78);
  }
  body.dark .topbar-tools.is-mobile-collapsed{
    background:rgba(15,23,42,.8);
  }
  .topbar-tools.is-mobile-expanded{
    padding-bottom:8px;
  }
  .topbar-tools[data-mobile-collapsed="false"] .topbar-mobile-toggle-icon,
  .topbar-tools.is-mobile-expanded .topbar-mobile-toggle-icon{
    transform:rotate(180deg);
  }
  .topbar-mobile-entry-main{
    flex:1;
    min-width:0;
    gap:10px;
  }
  .topbar-mobile-entry-badge{
    justify-content:center;
    min-width:50px;
    padding:0 10px;
    background:rgba(99,102,241,.1);
    color:var(--primary);
  }
  .topbar-mobile-entry-summary{
    flex:1;
    min-width:0;
    color:color-mix(in srgb, var(--text) 58%, var(--sub) 42%);
  }
  .topbar-mobile-toggle-icon{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:24px;
    height:24px;
    margin-right:2px;
    border-radius:999px;
    background:rgba(99,102,241,.08);
    color:var(--primary);
    font-size:12px;
    line-height:1;
    text-align:center;
  }
  body.dark .topbar-mobile-toggle-icon{
    background:rgba(129,140,248,.16);
    color:#c7d2fe;
  }
  .topbar-actions{
    width:100%;
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:6px;
    overflow:hidden;
    border-top:1px solid rgba(148,163,184,.12);
    transition:max-height .28s ease,opacity .22s ease,transform .28s ease,padding-top .28s ease,margin-top .28s ease,border-color .22s ease;
    max-height:208px;
    opacity:1;
    transform:translateY(0);
    margin-top:4px;
    padding-top:6px;
  }
  .topbar-tools[data-mobile-collapsed="true"] .topbar-actions{
    max-height:0;
    opacity:0;
    transform:translateY(-6px);
    margin-top:0;
    padding-top:0;
    border-top-color:transparent;
    pointer-events:none;
  }
  .topbar-action-group{
    width:100%;
    display:contents;
  }
  .topbar-tool-btn,
  .import-label.topbar-tool-btn{
    width:100%;
    min-height:32px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:6px;
    padding:0 10px;
    border-radius:12px;
    font-size:12px;
    font-weight:600;
    color:var(--text);
    background:rgba(255,255,255,.72);
    border:1px solid rgba(99,102,241,.12);
  }
  .topbar-tool-btn.btn,
  .topbar-tool-btn.btn-success{
    box-shadow:none;
  }
  .topbar-tool-btn.btn{
    background:linear-gradient(135deg,var(--primary),var(--primary-2));
    border-color:transparent;
    color:#fff;
  }
  .topbar-tool-btn.btn-success{
    background:linear-gradient(135deg,rgba(99,102,241,.1),rgba(79,70,229,.16));
    border:1px solid rgba(99,102,241,.16);
    color:var(--primary);
  }
  .topbar-tool-btn.btn-ghost{
    background:rgba(255,255,255,.68);
    border:1px solid rgba(99,102,241,.12);
    color:color-mix(in srgb, var(--text) 82%, var(--sub) 18%);
  }
  body.dark .topbar-tool-btn,
  body.dark .import-label.topbar-tool-btn{
    background:rgba(15,23,42,.84);
    border-color:rgba(129,140,248,.14);
    color:#e5e7eb;
  }
  body.dark .topbar-tool-btn.btn-success{
    background:linear-gradient(135deg,rgba(124,131,255,.18),rgba(99,102,241,.24));
    border-color:rgba(129,140,248,.2);
    color:#e0e7ff;
  }
  body.dark .topbar-tool-btn.btn-ghost{
    background:rgba(15,23,42,.78);
    border-color:rgba(129,140,248,.12);
    color:#dbe4f3;
  }
  .topbar-status-btn:disabled{
    color:var(--sub);
    background:rgba(148,163,184,.08);
    border-color:rgba(148,163,184,.1);
  }
  .mobile-summary-card{
    display:flex;
    margin:8px 14px 0;
    padding:8px 10px;
    border-radius:14px;
  }
  .mobile-summary-pill{
    min-width:48px;
    height:26px;
    padding:0 9px;
    font-size:10px;
  }
  .mobile-summary-card strong{
    font-size:12px;
  }
  .mobile-summary-card p{
    font-size:11px;
    line-height:1.4;
  }
  .habit-stats,.dashboard-actions,.week-view-grid{grid-template-columns:1fr}
  .day{min-height:74px}
  .timeline-item{
    grid-template-columns:64px 16px 1fr;
    gap:8px;
  }
  .timeline-time{
    font-size:14px;
    padding-top:12px;
  }
  .mobile-tabbar{
    left:10px;
    right:10px;
    bottom:10px;
  }
  .offline-banner{
    margin:14px 14px 0;
  }
}