:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  color: #1c1c1e;
  background: #f2f2f7;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  --blue: #0a84ff;
  --blue-dark: #0a5bd8;
  --green: #30d158;
  --red: #ff453a;
  --muted: #6e6e73;
  --line: #dedee3;
  --card: #fff;
  --radius: 14px;
}
html {
  min-width: 320px;
  min-height: 100%;
  background: #f2f2f7;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f2f2f7;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
button, select {
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button { -webkit-appearance: none; appearance: none; }
.app-shell { min-height: 100vh; min-height: 100dvh; }
.topbar {
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid rgba(60,60,67,.18);
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
}
.topbar-main { min-height: 64px; padding: 10px 22px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); box-shadow: 0 4px 14px #0a84ff33; }
.brand-title { font-size: 18px; font-weight: 700; letter-spacing: -.25px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; padding: 10px 13px; border-radius: 9px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab:hover { background: #f2f2f7; color: #1c1c1e; }
.tab.active { background: #e8f3ff; color: #007aff; font-weight: 600; }
.year-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.year-control select {
  border: 1px solid #c7c7cc;
  background: white;
  color: #1c1c1e;
  border-radius: 9px;
  padding: 7px 28px 7px 9px;
}
.status-bar { display: flex; justify-content: space-between; align-items: center; padding: 5px 22px 8px; font-size: 11px; color: var(--muted); }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--green); }
main { padding: 18px 22px 36px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.page-title { margin: 0; font-size: 23px; font-weight: 700; letter-spacing: -.45px; }
.page-desc { margin-top: 4px; color: var(--muted); font-size: 13px; }
.card { background: var(--card); border: 1px solid rgba(60,60,67,.12); border-radius: var(--radius); box-shadow: 0 1px 3px #0000000a, 0 8px 24px #00000005; }
.chart-card { padding: 12px 14px 8px; }
.chart-title { font-size: 14px; font-weight: 650; margin: 2px 2px 8px; }
.chart { width: 100%; height: 430px; touch-action: manipulation; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { padding: 15px 16px; min-height: 95px; }
.kpi-label { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.5px; }
.kpi-foot { font-size: 11px; color: var(--muted); margin-top: 7px; }
.good { color: var(--green); }
.bad { color: var(--red); }
.table-card { overflow: hidden; }
.table-wrap { width: 100%; overflow: auto; max-height: 430px; -webkit-overflow-scrolling: touch; touch-action: manipulation; }
table { border-collapse: collapse; width: 100%; font-size: 12px; background: white; }
th { position: sticky; top: 0; z-index: 2; background: #f2f2f7; text-align: right; color: #3a3a3c; font-weight: 650; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: inherit; z-index: 1; }
th:first-child { z-index: 3; background: #f2f2f7; }
th, td { padding: 8px 10px; border-bottom: 1px solid #e5e5ea; white-space: nowrap; text-align: right; }
tbody tr:hover { background: #f8fbff; }
tfoot td { background: #f2f2f7; font-weight: 700; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.fixed { background: #e8f3ff; color: #007aff; }
.badge.variable { background: #f2f2f7; color: #6e6e73; }
.month-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.month-chip { border: 1px solid #c7c7cc; background: white; border-radius: 999px; padding: 6px 10px; font-size: 11px; cursor: pointer; touch-action: manipulation; }
.month-chip.active { border-color: var(--blue); background: #e8f3ff; color: #007aff; }
.gauge-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.gauge-card { padding: 8px; min-height: 180px; }
.gauge { height: 150px; width: 100%; touch-action: manipulation; }
.section-gap { margin-top: 14px; }
.notice { background: #fff4ce; color: #5c4b00; border: 1px solid #f0d676; padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 13px; }
.error { background: #fde7e9; color: #8f1d2c; border-color: #f1aeb5; }
.loading { min-height: 55vh; display: grid; place-items: center; color: var(--muted); }
.mini-list { padding: 0; margin: 8px 0 0; list-style: none; font-size: 12px; }
.mini-list li { display: flex; justify-content: space-between; gap: 15px; padding: 7px 0; border-bottom: 1px solid #e5e5ea; }
.mini-list li:last-child { border-bottom: 0; }

@media (max-width: 1050px) {
  .topbar-main { flex-wrap: wrap; }
  .brand { min-width: auto; }
  .tabs { order: 3; flex-basis: 100%; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .gauge-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  body { background: #f2f2f7; }
  .app-shell { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .topbar { border-bottom-color: rgba(60,60,67,.12); }
  .topbar-main {
    min-height: 58px;
    padding: 8px 14px;
    flex-wrap: nowrap;
  }
  .status-bar {
    padding: 0 14px 8px;
    min-height: 23px;
    gap: 12px;
    overflow: hidden;
  }
  .status-bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand { min-width: 0; flex: 1; }
  .brand-mark { width: 32px; height: 32px; flex: 0 0 32px; }
  .brand-title { font-size: 18px; }
  .brand-sub { display: none; }
  .year-control { font-size: 12px; flex: 0 0 auto; }
  .year-control select {
    min-height: 38px;
    font-size: 16px;
    line-height: 1.2;
    padding: 7px 27px 7px 10px;
    border-radius: 10px;
  }
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    overflow: visible;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(249,249,249,.92);
    border-top: 1px solid rgba(60,60,67,.18);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
  }
  .tab {
    min-width: 0;
    min-height: 50px;
    padding: 6px 4px;
    border-radius: 10px;
    font-size: 10px;
    line-height: 1.15;
    white-space: normal;
    text-align: center;
    color: #8e8e93;
  }
  .tab:hover { background: transparent; }
  .tab.active { background: transparent; color: #007aff; font-weight: 650; }
  main { padding: 14px 10px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .page-head { align-items: flex-start; }
  .page-title { font-size: 24px; }
  .page-desc { font-size: 13px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .gauge-grid { grid-template-columns: repeat(2, 1fr); }
  .chart { height: 350px; }
  .kpi { min-height: 90px; padding: 14px; }
  .kpi-value { font-size: 25px; }
  .card { border-radius: 16px; }
  .month-chip {
    min-height: 36px;
    padding: 7px 11px;
    font-size: 13px;
  }
  button, select, .chart, .gauge, .table-wrap, .card {
    touch-action: manipulation;
  }
}

@media (display-mode: standalone) and (max-width: 700px) {
  .topbar { padding-top: max(env(safe-area-inset-top, 0px), 2px); }
}
