:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #e6e8ec;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #6c5ce7;
  --accent-2: #00b894;
  --warn: #e17055;
  --good: #00b894;
  --neutral: #74b9ff;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { padding-bottom: 80px; }

header.app {
  background: linear-gradient(135deg, #6c5ce7 0%, #00b894 100%);
  color: white; padding: 18px 16px 14px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
header.app h1 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -0.2px; }
header.app .sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }

.block-switch {
  display: flex; gap: 6px;
  margin: 12px 16px 0; padding: 4px;
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
  position: sticky; top: 64px; z-index: 40;
}
.block-switch button {
  flex: 1; border: 0; padding: 10px 12px;
  font-size: 13px; font-weight: 600; border-radius: 9px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: all .15s ease;
}
.block-switch button.active { background: var(--accent); color: white; }

.tabs {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 12px 16px 0;
  scrollbar-width: none; -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto; border: 1px solid var(--border);
  background: var(--card); padding: 8px 13px; border-radius: 18px;
  font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer;
  white-space: nowrap; transition: all .15s ease;
}
.tabs button.active { background: var(--text); color: white; border-color: var(--text); }

.panel { padding: 14px 16px 30px; display: none; }
.panel.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
.card .desc { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: #f9fafb; border-radius: 10px;
  padding: 10px 12px; border-left: 3px solid var(--accent);
}
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; font-weight: 600; }
.stat .value { font-size: 16px; font-weight: 700; margin-top: 2px; }
.stat .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat.good { border-color: var(--good); }
.stat.warn { border-color: var(--warn); }
.stat.neutral { border-color: var(--neutral); }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table th, table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border); }
table th { font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; }
table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
table tr:last-child td { border-bottom: 0; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10.5px; font-weight: 600; }
.pill.good { background: #d1f7eb; color: #006e54; }
.pill.warn { background: #ffe1d5; color: #a8431d; }
.pill.neutral { background: #dfeeff; color: #0a4d8c; }
.pill.muted { background: #e9ecef; color: #495057; }
.pill.freeze { background: #e0e7ff; color: #3730a3; }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 12.5px; }
.bar-row .name { width: 130px; font-weight: 500; }
.bar-row .bar { flex: 1; height: 8px; background: #eef0f4; border-radius: 4px; overflow: hidden; }
.bar-row .bar > div { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s ease; }
.bar-row .bar > div.good { background: var(--good); }
.bar-row .bar > div.warn { background: var(--warn); }
.bar-row .val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 60px; text-align: right; }

input[type="number"], input[type="text"], input[type="month"] {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; background: white; color: var(--text);
  font-variant-numeric: tabular-nums;
}
input[type="number"]:focus, input[type="text"]:focus, input[type="month"]:focus { outline: none; border-color: var(--accent); }

select {
  width: 100%; padding: 10px 8px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; background: white; color: var(--text);
}

label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 10px; }

.field-row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; align-items: end; margin-bottom: 8px; }
.field-row label { margin-bottom: 0; }
.field-row .delta { font-size: 12px; padding: 8px 10px; border-radius: 8px; text-align: center; font-weight: 600; }
.field-row .delta.ok { background: #d1f7eb; color: #006e54; }
.field-row .delta.over { background: #ffe1d5; color: #a8431d; }

ul.tips { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.65; color: var(--text); }
ul.tips li { margin-bottom: 4px; }
ul.tips li strong { color: var(--accent); }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; margin: 10px 0; }
.alert.info { background: #eef2ff; color: #3730a3; border-left: 3px solid #6366f1; }
.alert.good { background: #ecfdf5; color: #065f46; border-left: 3px solid var(--good); }
.alert.warn { background: #fef3e7; color: #92400e; border-left: 3px solid var(--warn); }

.chart-wrap { height: 260px; margin-top: 6px; }

.month-card { background: #f9fafb; border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.month-card .hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.month-card .mname { font-weight: 600; font-size: 14px; }
.month-card .mtotal { font-size: 13px; color: var(--accent); font-weight: 700; }
.month-card ul { margin: 4px 0 0; padding-left: 16px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.month-card ul li strong { color: var(--text); }
.month-card.highlight { background: linear-gradient(135deg, #fff5e6 0%, #ffe1d5 100%); border-left: 3px solid var(--warn); }
.month-card.next { background: linear-gradient(135deg, #e8f5e9 0%, #d1f7eb 100%); border-left: 3px solid var(--good); }

.asset-card { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.asset-card:last-child { border-bottom: 0; }
.asset-card .info .ticker { font-weight: 700; font-size: 14px; }
.asset-card .info .desc-mini { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.asset-card .right { text-align: right; }
.asset-card .right .val { font-size: 13.5px; font-weight: 600; }
.asset-card .right .target { font-size: 11px; color: var(--muted); }

.progress { height: 6px; background: #eef0f4; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 3px; }

.footer-note { font-size: 11px; color: var(--muted); text-align: center; padding: 20px 16px 8px; line-height: 1.5; }

@media (min-width: 720px) {
  body { padding-bottom: 30px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .container { max-width: 760px; margin: 0 auto; }
}
