:root {
  color-scheme: light;
  --ink: #113d33;
  --quiet: #547066;
  --line: #dce9e1;
  --mint: #e5f3eb;
  --surface: #fff;
  --green: #116950;
  --canvas: #f1f6f2;
  font-family: "Source Sans 3", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; padding: 18px clamp(14px, 2vw, 32px) 24px; min-width: 320px; }
a { color: inherit; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { opacity: .56; cursor: wait; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #267d68; outline-offset: 3px; }

.brand, .top-actions, .sidebar, .panel, .summary-item { background: var(--surface); border: 1px solid var(--line); }
.brand, .top-actions { align-self: stretch; min-height: 60px; border-radius: 15px; }
.brand {
  display: flex; align-items: center; gap: 9px; padding: 10px 14px;
  text-decoration: none; font-size: 19px; font-weight: 750;
}
.brand-name { white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  color: white; background: #105646; font-size: 23px; line-height: 1;
}
.top-actions { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: 9px; padding: 8px 13px; }
.layout { display: grid; grid-template-columns: 195px minmax(0, 1fr); gap: 12px 19px; align-items: start; }
.sidebar {
  border-radius: 17px; padding: 12px 12px 15px; min-height: min(620px, calc(100vh - 110px));
  display: flex; flex-direction: column; position: sticky; top: 16px;
}
nav { display: grid; gap: 5px; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px;
  color: var(--quiet); font-size: 14px; font-weight: 600; text-decoration: none;
}
nav a span { min-width: 18px; text-align: center; font-size: 17px; line-height: 1; }
nav a:hover, nav a[aria-current="page"] { background: var(--mint); color: #0c5945; }
.schedule { margin: auto 0 0; padding: 23px 10px 2px; color: var(--quiet); font-size: 12px; white-space: nowrap; }
.schedule span { display: inline-block; background: #459272; width: 6px; height: 6px; border-radius: 50%; margin: 0 7px 2px 0; }
main { min-width: 0; }
.page-head { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 7px 2px 16px; }
.eyebrow { margin: 0 0 5px; color: var(--quiet); font-size: 12px; font-weight: 650; letter-spacing: .06em; }
h1, h2 { margin: 0; line-height: 1.3; }
h1 { font-size: clamp(23px, 3vw, 30px); }
h2 { font-size: 17px; }
.subtle { color: var(--quiet); font-size: 13px; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; margin-bottom: 15px; }
.summary-item { border-radius: 13px; padding: 14px 17px; }
.summary-item span { display: block; font-size: 12px; color: var(--quiet); margin-bottom: 6px; }
.summary-item strong { font-size: clamp(18px, 2vw, 24px); font-variant-numeric: tabular-nums; }
.panel { border-radius: 15px; overflow: hidden; }
.panel-title { padding: 15px 17px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px;
  background: #f7faf8; border-block: 1px solid var(--line); padding: 10px 16px;
}
.toolbar label, .inline-field { font-size: 13px; color: var(--quiet); display: inline-flex; align-items: center; gap: 7px; }
input, select, .button { padding: 7px 10px; border: 1px solid #c5dbce; border-radius: 8px; background: white; color: var(--ink); }
.button { font-size: 13px; min-height: 34px; white-space: nowrap; }
.button:hover { background: #f0f8f3; }
.button.primary { color: white; background: var(--green); border-color: var(--green); }
.button.primary:hover { background: #0e5944; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 5px; width: fit-content; border-radius: 99px; padding: 4px 8px; font-size: 11px; white-space: nowrap; background: var(--mint); color: #15563f; }
.badge.amber { background: #fbefd5; color: #744a13; }
.badge.gray { background: #edf1ef; color: #51665d; }
.badge.red { background: #f9e8e3; color: #963b28; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 12px 14px; vertical-align: middle; }
th { background: #eef5f0; color: #375e51; white-space: nowrap; font-size: 12px; }
td { border-top: 1px solid #e9f0eb; }
tbody tr:hover td { background-color: #f8fcfa; }
tr.fresh td { background-color: #f1f9f4; }
tr.fresh td:first-child { box-shadow: inset 3px 0 #57a583; }
.video { display: flex; align-items: center; gap: 10px; min-width: 235px; }
.thumb { width: 45px; height: 55px; border-radius: 7px; flex: 0 0 45px; object-fit: cover; background: #e6f0e9; display: grid; place-items: center; color: #54806d; }
.video-title { display: block; max-width: 340px; overflow-wrap: anywhere; font-weight: 650; }
.video-link { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.video-link:hover { color: var(--ink); }
.caption { display: block; margin-top: 4px; font-size: 11px; color: var(--quiet); }
.numeric { white-space: nowrap; min-width: 64px; }
.delta { display: block; color: #117355; font-weight: 700; margin-top: 3px; font-size: 12px; }
.delta.negative { color: #9b4232; }
.delta.muted { color: var(--quiet); font-weight: 400; }
.manual-value { display: block; margin-top: 4px; color: #74521b; font-size: 11px; white-space: nowrap; }
.empty { padding: 41px 18px; text-align: center; color: var(--quiet); font-size: 14px; }
.add-form { display: flex; align-items: end; flex-wrap: wrap; gap: 9px; padding: 15px 16px; border-bottom: 1px solid var(--line); }
.add-form label { display: grid; gap: 6px; flex: 1 1 300px; min-width: 0; font-size: 13px; color: var(--quiet); }
.add-form input { width: 100%; }
.settings-help { margin: 10px 16px; color: var(--quiet); font-size: 13px; line-height: 1.55; }
.notice { padding: 10px 14px; margin-bottom: 12px; border-radius: 9px; font-size: 13px; background: var(--mint); color: var(--ink); }
.notice.error { background: #fbece6; color: #8b3724; }
dialog { border: 1px solid var(--line); border-radius: 16px; color: var(--ink); width: min(1040px, calc(100% - 26px)); max-height: 88vh; padding: 0; box-shadow: 0 18px 62px #123c3338; }
dialog::backdrop { background: #143b3163; }
.dialog-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: 16px;
  position: sticky; top: 0; z-index: 1; background: white; border-bottom: 1px solid var(--line);
}
.dialog-head h2 { overflow-wrap: anywhere; }
#dialog-body { padding: 15px 16px 18px; }
.history-controls, .history-custom { display: flex; align-items: end; flex-wrap: wrap; gap: 7px 10px; }
.history-controls { margin-bottom: 16px; }
.history-controls label { display: grid; gap: 4px; color: var(--quiet); font-size: 12px; }
.history-period-label { margin: 0; padding: 0 0 6px; color: var(--quiet); font-size: 12px; }
.trend-group + .trend-group, .history-table { margin-top: 17px; }
.trend-group h3, .history-table h3 { margin: 0 0 6px; font-size: 15px; }
.trend-caption { color: var(--quiet); font-size: 12px; margin: 0 0 9px; }
.trend-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.trend-card { margin: 0; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 9px; }
.trend-card-title { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-size: 13px; font-weight: 650; }
.trend-card-title strong { font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; }
.trend-canvas { display: block; width: 100%; height: 94px; margin-top: 5px; }
.trend-card-note, .trend-empty { color: var(--quiet); font-size: 11px; margin: 4px 0 0; }
.trend-empty { display: grid; place-items: center; min-height: 105px; text-align: center; }
.history-table .table-scroll { border: 1px solid var(--line); border-radius: 8px; }

@media (max-width: 740px) {
  .trend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
  .layout { grid-template-columns: 148px minmax(0, 1fr); gap: 12px; }
  .sidebar { min-height: auto; padding: 12px 7px; }
  .brand { font-size: 16px; gap: 6px; }
  .brand-mark { width: 31px; height: 31px; font-size: 18px; }
  .schedule { padding-inline: 3px; font-size: 11px; }
}
@media (max-width: 540px) {
  body { padding-inline: 9px; }
  .layout { grid-template-columns: 96px minmax(0, 1fr); gap: 8px; }
  .brand { justify-content: center; padding: 8px 4px; font-size: 13px; }
  .schedule { display: none; }
  nav a { gap: 4px; padding: 9px 5px; font-size: 12px; white-space: nowrap; }
  nav a span { min-width: 13px; font-size: 14px; }
  .top-actions { gap: 4px; padding-inline: 6px; }
  .top-actions .button { font-size: 11px; padding-inline: 6px; }
  .summary-item { padding: 9px 7px; }
  .summary-item strong { font-size: 16px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .summary-item:last-child { grid-column: 1 / -1; }
  .toolbar { padding-inline: 9px; }
  .toolbar select { max-width: 125px; }
}
