:root {
  --ink: #183432;
  --muted: #72817f;
  --subtle: #96a29f;
  --canvas: #edf3f0;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --border: #dce6e1;
  --grid: #e8efeb;
  --teal-950: #064845;
  --teal-800: #075b57;
  --teal-600: #0d8880;
  --teal-400: #35aaa1;
  --lime: #8da94f;
  --orange: #d77a45;
  --violet: #8174b9;
  --red: #c95e56;
  --shadow: 0 12px 35px rgba(27, 66, 61, 0.07);
}

[data-theme="dark"] {
  --ink: #e7f0ed;
  --muted: #9caeaa;
  --subtle: #778a86;
  --canvas: #10201f;
  --surface: #172a28;
  --surface-soft: #1c302e;
  --border: #2c403d;
  --grid: #2a3c39;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.19);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 90% 5%, rgba(53, 170, 161, 0.1), transparent 23rem),
    var(--canvas);
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  font-size: 14px;
  transition: background 0.25s ease, color 0.25s ease;
}

button, select, input { font: inherit; }
button { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.page-shell { min-height: 100vh; }

.topbar {
  color: #eef8f6;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 46px 46px,
    linear-gradient(160deg, var(--teal-950), var(--teal-800));
  box-shadow: 0 14px 35px rgba(4, 56, 53, 0.16);
}

.topbar__inner, .status-strip__inner, main, footer {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar__inner {
  min-height: 116px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 22px 0;
}

.brand-block { display: flex; align-items: center; gap: 17px; }
.brand-mark {
  position: relative;
  width: 51px;
  height: 51px;
  flex: 0 0 51px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 15px 15px 15px 5px;
  background: rgba(255,255,255,.1);
  overflow: hidden;
}
.brand-mark span { position: absolute; display: block; background: #c7d875; transform: rotate(-34deg); border-radius: 10px 10px 2px 10px; }
.brand-mark span:nth-child(1) { width: 26px; height: 10px; left: 6px; top: 15px; }
.brand-mark span:nth-child(2) { width: 29px; height: 10px; left: 15px; top: 25px; }
.brand-mark span:nth-child(3) { width: 21px; height: 4px; left: 15px; top: 24px; background: #e8f3bb; transform: rotate(90deg); }
.eyebrow { margin: 0 0 5px; font-size: 9px !important; font-weight: 800; letter-spacing: .17em; opacity: .62; }
.brand-block h1 { margin: 0; color: #fff; font-size: clamp(20px, 2vw, 27px); letter-spacing: -.035em; line-height: 1.1; }
.brand-block p { margin: 7px 0 0; font-size: 12px; color: rgba(238,248,246,.69); }
.header-actions { display: flex; align-items: center; gap: 9px; }
.icon-button, .export-button, .sync-button {
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
  transition: .2s ease;
}
.icon-button:hover, .export-button:hover, .sync-button:hover { background: rgba(255,255,255,.15); transform: translateY(-1px); }
.icon-button { width: 41px; height: 41px; border-radius: 11px; display: grid; place-items: center; }
.icon-button svg { width: 19px; }
.export-button, .sync-button { height: 41px; border-radius: 11px; padding: 0 15px; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
.export-button svg, .sync-button svg { width: 16px; }

.status-strip { background: rgba(0, 20, 18, .17); border-top: 1px solid rgba(255,255,255,.08); }
.status-strip__inner { min-height: 54px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 34px; }
.system-status { display: flex; align-items: center; gap: 10px; min-width: 0; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #b6d667; box-shadow: 0 0 0 5px rgba(182,214,103,.12); }
.system-status div { display: flex; align-items: center; gap: 12px; min-width: 0; }
.system-status strong { font-size: 9px; letter-spacing: .13em; color: #cfe894; }
.system-status span { font-size: 10px; color: rgba(238,248,246,.58); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-date { text-align: right; padding-right: 3px; }
.status-date span { display: block; font-family: "DM Mono", monospace; font-size: 13px; letter-spacing: .04em; }
.status-date small { color: rgba(238,248,246,.55); font-size: 9px; }
.sync-button { height: 32px; border-radius: 8px; padding: 0 12px; font-size: 10px; }
.sync-button.loading svg { animation: spin .7s linear infinite; }

main { padding: 24px 0 35px; }
.filter-bar {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) repeat(3, minmax(150px, 205px)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}
.filter-heading { display: flex; align-items: center; gap: 11px; align-self: center; }
.filter-heading small { display: block; color: var(--teal-600); font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.filter-heading strong { display: block; margin-top: 3px; font-size: 12px; }
.filter-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; color: var(--teal-600); background: color-mix(in srgb, var(--teal-600) 10%, transparent); }
.filter-icon svg { width: 17px; }
.select-field span { display: block; margin: 0 0 5px 2px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.select-field select {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 600;
}
.select-field select:focus, .search-field:focus-within { border-color: var(--teal-400); box-shadow: 0 0 0 3px rgba(53,170,161,.12); }
.reset-button { height: 40px; padding: 0 16px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; font-weight: 700; }
.reset-button:hover { color: var(--teal-600); border-color: var(--teal-400); }

.kpi-grid { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 14px; }
.kpi-card, .panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.kpi-card { min-height: 178px; padding: 18px; overflow: hidden; }
.kpi-card--hero { position: relative; color: #f1faf8; border-color: transparent; background: linear-gradient(145deg, #075b57, #0b7770); }
.kpi-card--hero::after { content: ""; position: absolute; width: 190px; height: 190px; right: -70px; bottom: -112px; border: 32px solid rgba(255,255,255,.055); border-radius: 50%; }
.kpi-card__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .055em; }
.kpi-card--hero .kpi-card__top { color: rgba(241,250,248,.71); }
.kpi-icon { width: 31px; height: 31px; border-radius: 9px; display: grid; place-items: center; }
.kpi-icon svg { width: 16px; }
.kpi-icon--teal { color: #dbe994; background: rgba(255,255,255,.1); }
.kpi-icon--lime { color: var(--lime); background: rgba(141,169,79,.11); }
.kpi-icon--orange { color: var(--orange); background: rgba(215,122,69,.11); }
.kpi-icon--red { color: var(--red); background: rgba(201,94,86,.11); }
.hero-value { margin-top: 11px; display: flex; align-items: baseline; gap: 7px; }
.hero-value strong { font-size: clamp(35px, 3.2vw, 49px); line-height: 1; letter-spacing: -.055em; }
.hero-value span { color: rgba(241,250,248,.67); font-size: 12px; font-weight: 600; }
.target-line { display: flex; justify-content: space-between; gap: 15px; margin-top: 13px; color: rgba(241,250,248,.62); font-size: 9px; }
.target-line b { color: rgba(241,250,248,.88); }
.target-line strong { color: #ddeb9d; font-family: "DM Mono", monospace; font-size: 11px; }
.progress-track { position: relative; height: 5px; margin-top: 7px; overflow: hidden; border-radius: 5px; background: rgba(255,255,255,.13); }
.progress-track span { position: absolute; inset: 0 auto 0 0; width: 94.9%; border-radius: 5px; background: #c8db77; transition: width .5s ease; }
.progress-track i { position: absolute; left: 100%; top: -2px; bottom: -2px; border-left: 1px solid rgba(255,255,255,.7); }
.kpi-card p { margin: 13px 0 0; color: var(--muted); font-size: 9px; }
.kpi-card p b { color: var(--ink); }
.kpi-card--hero p { color: rgba(241,250,248,.58); }
.metric-value { display: flex; align-items: baseline; gap: 6px; margin-top: 17px; }
.metric-value strong { font-size: clamp(25px, 2vw, 33px); line-height: 1; letter-spacing: -.045em; }
.metric-value span { color: var(--muted); font-size: 10px; font-weight: 600; }
.trend-pill { display: inline-flex; margin-top: 14px; padding: 4px 7px; border-radius: 20px; font-size: 8px; font-weight: 700; }
.trend-pill--up { color: #648131; background: rgba(141,169,79,.12); }
.trend-pill--down { color: var(--teal-600); background: rgba(53,170,161,.11); }

.dashboard-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; margin-top: 14px; }
.panel { padding: 20px; min-width: 0; }
.panel--wide { min-height: 410px; }
.panel--narrow { min-height: 410px; }
.panel--half { min-height: 340px; }
.panel--full { grid-column: 1 / -1; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-kicker { margin: 0 0 5px !important; color: var(--teal-600) !important; font-size: 8px !important; font-weight: 800; letter-spacing: .14em; }
.panel-header h2 { margin: 0; font-size: 15px; letter-spacing: -.02em; }
.panel-header p { margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.segment-control { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-soft); border: 1px solid var(--border); }
.segment-control button { height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 9px; font-weight: 700; }
.segment-control button.active { color: #fff; background: var(--teal-600); box-shadow: 0 4px 10px rgba(13,136,128,.2); }
.chart-legend { display: flex; gap: 17px; margin-top: 19px; color: var(--muted); font-size: 9px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot--teal { background: var(--teal-600); }
.legend-line { width: 13px; border-top: 2px solid; }
.legend-line--orange { border-color: var(--orange); }
.legend-line--violet { border-color: var(--violet); border-style: dashed; }
.chart-wrap { min-height: 275px; margin-top: 10px; }
.chart-wrap svg { width: 100%; height: 275px; overflow: visible; }
.chart-grid { stroke: var(--grid); stroke-width: 1; }
.chart-axis-text { fill: var(--subtle); stroke: none; font: 8px "DM Mono", monospace; }
.chart-area { fill: url(#areaGradient); stroke: none; }
.chart-line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-line--actual { stroke: var(--teal-600); }
.chart-line--target { stroke: var(--orange); }
.chart-line--projection { stroke: var(--violet); stroke-dasharray: 4 5; }
.chart-point { fill: var(--surface); stroke: var(--teal-600); stroke-width: 2; cursor: pointer; transition: r .15s ease; }
.chart-point:hover { r: 5; }

.ranking-list { display: grid; gap: 13px; margin-top: 22px; }
.rank-row { display: grid; grid-template-columns: 25px minmax(80px, .85fr) 1.5fr 42px; gap: 10px; align-items: center; }
.rank-number { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 7px; color: var(--teal-600); background: rgba(53,170,161,.09); font: 500 9px "DM Mono", monospace; }
.rank-label strong { display: block; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-label small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.rank-track { height: 6px; overflow: hidden; border-radius: 5px; background: var(--grid); }
.rank-track span { display: block; height: 100%; border-radius: 5px; background: var(--teal-400); }
.rank-value { text-align: right; font: 500 9px "DM Mono", monospace; color: var(--muted); }
.rank-value.good { color: #78973b; }
.rank-value.attention { color: var(--orange); }

.bar-chart { display: grid; gap: 11px; margin-top: 24px; }
.bar-row { display: grid; grid-template-columns: 91px 1fr 58px; align-items: center; gap: 10px; }
.bar-label { color: var(--muted); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 17px; border-radius: 4px; background: var(--surface-soft); overflow: hidden; }
.bar-track span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--teal-800), var(--teal-400)); transform-origin: left; animation: grow .55s ease both; }
.bar-value { text-align: right; color: var(--ink); font: 500 9px "DM Mono", monospace; }

.insight-list { display: grid; gap: 10px; margin-top: 20px; }
.insight-item { display: grid; grid-template-columns: 35px 1fr auto; align-items: center; gap: 11px; padding: 11px; border-radius: 11px; background: var(--surface-soft); border: 1px solid transparent; }
.insight-item:hover { border-color: var(--border); }
.insight-symbol { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 9px; }
.insight-symbol svg { width: 16px; }
.insight-symbol--warning { color: var(--orange); background: rgba(215,122,69,.11); }
.insight-symbol--positive { color: var(--lime); background: rgba(141,169,79,.12); }
.insight-symbol--info { color: var(--teal-600); background: rgba(53,170,161,.1); }
.insight-copy strong { display: block; font-size: 10px; }
.insight-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.45; }
.insight-badge { padding: 4px 7px; border-radius: 20px; color: var(--muted); background: var(--surface); font: 500 8px "DM Mono", monospace; }

.panel-header--table { align-items: center; }
.search-field { width: min(240px, 100%); height: 37px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); }
.search-field svg { width: 15px; color: var(--muted); }
.search-field input { min-width: 0; width: 100%; border: 0; outline: none; color: var(--ink); background: transparent; font-size: 10px; }
.search-field input::placeholder { color: var(--subtle); }
.table-wrap { margin-top: 18px; overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th { padding: 10px 12px; color: var(--teal-600); background: var(--surface-soft); font-size: 8px; text-align: left; text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; }
td { padding: 11px 12px; border-top: 1px solid var(--grid); color: var(--muted); white-space: nowrap; }
td:first-child { color: var(--ink); font-weight: 700; }
.align-right { text-align: right; }
.table-progress { display: flex; justify-content: flex-end; align-items: center; gap: 7px; }
.table-progress span { width: 35px; height: 4px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.table-progress i { display: block; height: 100%; border-radius: 4px; background: var(--teal-400); }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 20px; font-size: 8px; font-weight: 700; }
.status-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-badge--good { color: #78973b; background: rgba(141,169,79,.12); }
.status-badge--watch { color: var(--orange); background: rgba(215,122,69,.12); }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 0 0 25px; color: var(--subtle); font-size: 8px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; padding: 11px 15px; border-radius: 10px; color: #fff; background: var(--teal-950); box-shadow: 0 16px 35px rgba(0,0,0,.2); font-size: 10px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes grow { from { transform: scaleX(0); } }

@media (max-width: 1100px) {
  .filter-bar { grid-template-columns: repeat(4, 1fr); }
  .filter-heading { grid-column: 1 / -1; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel--full { grid-column: auto; }
}

@media (max-width: 720px) {
  .topbar__inner, .status-strip__inner, main, footer { width: min(100% - 28px, 1500px); }
  .topbar__inner { min-height: auto; align-items: flex-start; padding: 19px 0; }
  .brand-block p, .export-button { display: none; }
  .status-strip__inner { grid-template-columns: 1fr auto; gap: 12px; }
  .status-date { display: none; }
  .system-status div { display: block; }
  .system-status strong, .system-status span { display: block; }
  .system-status span { margin-top: 2px; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-heading { grid-column: 1 / -1; }
  .select-field:first-of-type { grid-column: 1 / -1; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 0; }
  .panel { padding: 16px; }
  .panel-header { flex-direction: column; }
  .panel-header--table { align-items: stretch; }
  .search-field { width: 100%; }
  .rank-row { grid-template-columns: 24px 80px 1fr 38px; gap: 7px; }
  footer { flex-direction: column; gap: 5px; }
}

@media (max-width: 430px) {
  .brand-mark { width: 43px; height: 43px; flex-basis: 43px; }
  .brand-block { gap: 11px; }
  .brand-block h1 { font-size: 18px; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-heading, .select-field:first-of-type { grid-column: auto; }
  .reset-button { width: 100%; }
  .chart-legend { gap: 10px; flex-wrap: wrap; }
  .bar-row { grid-template-columns: 75px 1fr 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
