/* TB completion tracker — visual system
   Apple-adjacent light theme: neutral surfaces, one accent, restrained motion. */

:root {
  --bg:          #f4f4f6;
  --bg-elev:     #ffffff;
  --text:        #1d1d1f;
  --text-2:      #4b4b52;
  --muted:       #86868b;
  --border:      rgba(0, 0, 0, .09);
  --border-soft: rgba(0, 0, 0, .055);

  --accent:      #0071e3;
  --accent-soft: #e8f1fd;
  --success:     #1d9d4e;
  --success-soft:#e7f6ec;
  --warn:        #b26a00;
  --warn-soft:   #fff4e0;
  --danger:      #d70015;
  --danger-soft: #ffe9e9;

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;

  --shadow:    0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.045);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.05), 0 18px 48px rgba(0,0,0,.07);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Author `display` declarations outrank the UA sheet's [hidden] rule, so
   elements like .notice{display:flex} would ignore the hidden attribute.
   This keeps the attribute authoritative. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.015em; }

code { font-family: var(--mono); font-size: .88em; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  position: relative;
  width: 84px; height: 44px; flex: 0 0 84px;
  overflow: hidden;
}
.brand-mark img {
  position: absolute; left: 50%; top: 50%;
  width: 92px; height: auto; max-width: none;
  transform: translate(-50%, -50%);
  display: block;
}

.brand h1 { font-size: 17px; }
.sub { margin: 1px 0 0; font-size: 11.5px; color: var(--muted); letter-spacing: .01em; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

/* language switch: 中文 / English / Español */
.lang-switch {
  display: inline-flex; gap: 2px; padding: 2px;
  background: rgba(118,118,128,.11); border-radius: 9px;
}
.lang-switch button {
  font-family: inherit; font-size: 11.5px; font-weight: 500;
  border: 0; background: transparent; color: var(--text-2);
  padding: 4px 10px; border-radius: 7px; cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.on {
  background: #fff; color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.10), 0 0 0 .5px rgba(0,0,0,.04);
}
.lang-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.asof { text-align: right; line-height: 1.25; }
.asof-label { display: block; font-size: 10.5px; color: var(--muted); }
.asof-value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- layout */
.wrap { max-width: 1320px; margin: 0 auto; padding: 22px 28px 56px; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- buttons */
.btn {
  font-family: inherit; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 980px;
  cursor: pointer; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover { background: #f7f7f9; }
.btn:active { transform: scale(.975); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 2px 8px rgba(0,113,227,.26);
}
.btn-primary:hover { background: #0063c9; }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.045); }

.btn-small { font-size: 12px; padding: 5px 11px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  font-size: 17px; line-height: 1; display: grid; place-items: center;
  color: var(--text-2);
}
.btn-danger { color: var(--danger); border-color: rgba(215,0,21,.25); }
.btn-danger:hover { background: var(--danger-soft); }

.input {
  font-family: inherit; font-size: 13px;
  padding: 7px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: #fff; color: var(--text);
  min-width: 0;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* ---------------------------------------------------------------- controls */
.controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}

.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: rgba(118,118,128,.10);
  border-radius: 11px;
}
.segmented button {
  font-family: inherit; font-size: 13px; font-weight: 500;
  border: 0; background: transparent; color: var(--text-2);
  padding: 6px 17px; border-radius: 8px; cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.on {
  background: #fff; color: var(--text); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.10), 0 0 0 .5px rgba(0,0,0,.04);
}

.period-nav { display: flex; align-items: center; gap: 8px; }

/* ---------------------------------------------------------------- notice */
.notice {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 14px 17px; margin-bottom: 16px;
  background: var(--warn-soft);
  border: 1px solid rgba(178,106,0,.20);
  border-radius: var(--r-md);
}
.notice-icon {
  flex: 0 0 21px; width: 21px; height: 21px; border-radius: 50%;
  background: var(--warn); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  margin-top: 1px;
}
.notice-body { flex: 1; min-width: 0; }
.notice-body strong { font-size: 13.5px; color: #6b4100; }
.notice-body p { margin: 3px 0 0; font-size: 12.5px; color: #7a5200; line-height: 1.55; }

/* ---------------------------------------------------------------- hero */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr);
  gap: 16px; margin-bottom: 16px;
}

.hero-main { padding: 24px 26px 20px; }
.hero-label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.hero-label-en {
  font-size: 10.5px; font-weight: 400; color: var(--muted);
  letter-spacing: .04em; text-transform: uppercase; margin-left: 7px;
}
.hero-value {
  display: flex; align-items: baseline; gap: 9px;
  margin: 6px 0 4px;
}
#gap-value {
  font-size: 62px; font-weight: 700; letter-spacing: -.035em;
  line-height: 1.02; font-variant-numeric: tabular-nums;
  color: var(--text);
}
#gap-value.met { color: var(--success); }
#gap-value.none { font-size: 30px; color: var(--muted); letter-spacing: -.02em; }
.hero-unit { font-size: 16px; color: var(--muted); font-weight: 500; }

.hero-meta { font-size: 12.5px; color: var(--muted); min-height: 18px; }

.progress {
  position: relative; height: 10px; margin: 16px 0 0;
  background: rgba(118,118,128,.13); border-radius: 5px; overflow: hidden;
}
.progress-fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg, #0a84ff, #0071e3);
  border-radius: 5px; transition: width .5s cubic-bezier(.4,0,.2,1);
}
.progress-fill.met { background: linear-gradient(90deg, #34c759, #1d9d4e); }
/* elapsed-time marker: shows how much of the period has passed */
.progress-elapsed {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: rgba(0,0,0,.34); border-radius: 1px;
  transition: left .5s cubic-bezier(.4,0,.2,1);
}
.progress-legend {
  display: flex; gap: 18px; flex-wrap: wrap;
  margin-top: 11px; font-size: 12px; color: var(--text-2);
}
.progress-legend b { font-variant-numeric: tabular-nums; }
.legend-elapsed { margin-left: auto; color: var(--muted); }
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 3px;
  margin-right: 6px; vertical-align: 1px;
}
.dot-done { background: var(--accent); }
.dot-left { background: rgba(118,118,128,.28); }

.hero-side {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.stat { padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value {
  font-size: 27px; font-weight: 650; letter-spacing: -.025em;
  margin: 3px 0 1px; font-variant-numeric: tabular-nums;
}
.stat-note { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* ---------------------------------------------------------------- chart */
.chart-card { margin-bottom: 16px; }
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 19px 22px 0; flex-wrap: wrap;
}
.card-head h2 { font-size: 15.5px; }
.card-sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.chart-toggle { display: inline-flex; gap: 2px; padding: 2px;
  background: rgba(118,118,128,.10); border-radius: 8px; }
.chart-toggle button {
  font-family: inherit; font-size: 12px; border: 0; background: transparent;
  color: var(--text-2); padding: 4px 11px; border-radius: 6px; cursor: pointer;
}
.chart-toggle button.on {
  background: #fff; color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.10);
}

.chart { padding: 14px 18px 16px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: rgba(0,0,0,.07); stroke-width: 1; }
.chart .axis-text { font-size: 10.5px; fill: var(--muted); font-family: var(--font); }
.chart .bar { fill: var(--accent); transition: opacity .15s ease; }
.chart .bar.dim { opacity: .34; }
.chart .bar-target { fill: rgba(118,118,128,.30); }
.chart .target-line { stroke: var(--warn); stroke-width: 1.6; stroke-dasharray: 4 3; }
.chart .target-dot { fill: var(--warn); }
.chart .empty-note { font-size: 12px; fill: var(--muted); font-family: var(--font); }
.chart-empty {
  text-align: center; color: var(--muted); font-size: 12.5px;
  margin: -8px 0 6px;
}
.chart-legend {
  display: flex; gap: 16px; font-size: 11.5px; color: var(--muted);
  padding: 0 4px 2px; flex-wrap: wrap;
}
.chart-legend i { display: inline-block; width: 9px; height: 9px;
  border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.sw-done   { background: var(--accent); }
.sw-target { background: var(--warn); }
.muted-text { color: var(--muted); }

/* table + target helpers */
.empty-cell { color: var(--muted); padding: 18px 12px !important; }
.pill-met { background: var(--success-soft); color: var(--success); }
.gap-warn { color: var(--warn); }

/* ---------------------------------------------------------------- table */
.table-scroll { overflow-x: auto; padding: 10px 6px 6px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; background: var(--bg-elev);
}
.table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(0,0,0,.017); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-compact td { padding: 7px 10px; font-size: 12.5px; }
.table-compact th { padding: 6px 10px; }

.col-code { min-width: 172px; }
.col-rate { min-width: 128px; }
.mono { font-family: var(--mono); font-size: 11.5px; }
.name-cell { max-width: 360px; }
.name-en { color: var(--text); }
.name-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }

.tag {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 5px; margin-right: 5px;
  vertical-align: 1px; letter-spacing: .02em;
}
.tag-S { background: var(--danger-soft); color: var(--danger); }
.tag-A { background: var(--warn-soft);   color: var(--warn); }
.tag-C { background: #eef0f3;            color: #5b6068; }
.tag-pri { background: var(--accent-soft); color: #0059c9; }

.rate-wrap { display: flex; align-items: center; gap: 8px; }
.rate-bar {
  flex: 1; height: 6px; min-width: 42px;
  background: rgba(118,118,128,.16); border-radius: 3px; overflow: hidden;
}
.rate-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.rate-bar i.high { background: var(--success); }
.rate-num { font-size: 11.5px; color: var(--text-2); width: 42px; text-align: right;
  font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 980px;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pill-zero { background: rgba(118,118,128,.12); color: var(--muted); }
.pill-some { background: var(--accent-soft); color: #0059c9; }

/* ---------------------------------------------------------------- two col */
.two-col {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}
.two-col > .card { padding-bottom: 14px; }

.target-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; padding: 18px 22px 6px; align-items: end;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.field select, .field input { width: 100%; }
.field select {
  font-family: inherit; font-size: 13px; padding: 7px 11px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background-color: #fff;
}
.field-actions { flex-direction: row; gap: 8px; flex-wrap: wrap; }
.hint { margin: 4px 22px 0; font-size: 11.5px; color: var(--muted); min-height: 16px; }
.hint.ok { color: var(--success); }
.hint.err { color: var(--danger); }

.target-list-scroll { max-height: 260px; overflow-y: auto; overflow-x: auto; }

/* ---------------------------------------------------------------- data panel */
.data-label { font-size: 11px; color: var(--muted); font-weight: 500; }





/* ---------------------------------------------------------------- misc */
.foot {
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-top: 26px; font-size: 11.5px; color: var(--muted);
}

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: rgba(29,29,31,.94); color: #fff;
  padding: 11px 20px; border-radius: 980px; font-size: 13px;
  box-shadow: var(--shadow-lg); z-index: 100;
  animation: toast-in .25s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.spinner {
  display: inline-block; width: 12px; height: 12px; vertical-align: -1px;
  border: 2px solid rgba(0,0,0,.16); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, rgba(118,118,128,.10), rgba(118,118,128,.18), rgba(118,118,128,.10));
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 6px; color: transparent !important;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .wrap { padding: 16px 14px 40px; }
  .topbar-inner { padding: 12px 14px; }
  .hero-side { grid-template-columns: 1fr 1fr; }
  #gap-value { font-size: 48px; }
  .controls { flex-direction: column; align-items: stretch; }
  .segmented { justify-content: space-between; }
  .segmented button { flex: 1; padding: 6px 8px; }
  .card-head { padding: 16px 16px 0; }
  .asof { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- i18n fit */
/* English and Spanish copy runs longer than Chinese; let the topbar and
   control rows wrap rather than clip, and give the brand subtitle room. */
@media (max-width: 1180px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 10px; }
  .topbar-right { flex-wrap: wrap; row-gap: 8px; }
}
@media (max-width: 900px) {
  .brand h1 { font-size: 15.5px; }
  .sub { font-size: 11px; }
}
@media (max-width: 720px) {
  .lang-switch button { padding: 4px 8px; font-size: 11px; }
  .hero-label-en { display: none; }   /* avoid doubling a long label on phones */
  .legend-elapsed { margin-left: 0; }
}

/* Long Spanish labels can force a grid track wider than its share; collapse
   the target editor to one column on narrow screens so nothing overflows. */
@media (max-width: 620px) {
  .target-editor { grid-template-columns: minmax(0, 1fr); }
  .hero-side { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .field select, .field input { max-width: 100%; }
}

/* Shared proportions and readable typography across all three locales. */
:root {
  --bg: #f5f5f7;
  --muted: #6e6e73;
  --success: #18783e;
  --warn: #925600;
  --r-lg: 22px;
  --shadow: 0 2px 8px rgba(29,29,31,.025), 0 12px 32px rgba(29,29,31,.035);
}
body { font-size: 14px; line-height: 1.6; }
h1, h2, h3 { text-wrap: balance; }
html:lang(zh-CN) h1, html:lang(zh-CN) h2 { letter-spacing: 0; }
.topbar-inner { padding: 18px 32px; gap: 24px; }
.brand { min-width: 0; gap: 14px; }
.brand h1 { font-size: 19px; line-height: 1.35; }

.sub { font-size: 12px; margin-top: 4px; letter-spacing: 0; }
.topbar-right { gap: 16px; }
.lang-switch, .segmented, .chart-toggle { padding: 3px; border-radius: 9px; background: #eaeaed; }
.lang-switch button, .segmented button, .chart-toggle button { min-height: 28px; border-radius: 7px; line-height: 1.3; }
.lang-switch button { font-size: 12px; padding: 5px 10px; }
.asof-label { font-size: 11px; }
.asof-value { white-space: nowrap; font-size: 12px; }
.wrap { padding: 28px 32px 48px; }
.controls { margin-bottom: 22px; gap: 18px; }
.segmented button { padding: 6px 17px; }
.btn { min-height: 34px; padding: 7px 13px; border-radius: 9px; line-height: 1.3; white-space: normal; text-align: center; }
.btn-small { min-height: 30px; padding: 5px 11px; font-size: 12px; }
.btn-icon { min-width: 30px; width: 30px; height: 30px; padding: 0; border-radius: 7px; font-size: 18px; }
.btn-primary { box-shadow: none; }
.btn:disabled { opacity: .45; cursor: default; }
.input, .field select { min-height: 34px; font-size: 13px; padding: 7px 10px; }
select, .field select { -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m5 6 3 3 3-3' fill='none' stroke='%236e6e73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-position: right 9px center; background-repeat: no-repeat; }
.field select { background-color: #fff; padding-right: 30px; }
.period-nav { min-width: 0; gap: 10px; }
.period-nav .btn { flex-shrink: 0; }
.period-picker { display: flex; align-items: center; min-width: 0; padding: 2px; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.025); }
.period-picker .btn-icon { border: 0; background: transparent; color: var(--text-2); }
.period-picker .btn-icon:hover { background: #f0f0f3; }
#btn-current { min-height: 32px; padding: 6px 9px; background: transparent; border-color: transparent; color: var(--accent); font-size: 12px; }
#btn-current:hover { background: var(--accent-soft); }
.notice { padding: 18px 20px; margin-bottom: 22px; background: #fff8eb; border-color: #eedfc4; border-radius: 16px; align-items: center; }
.notice-icon { align-self: flex-start; margin-top: 3px; }
.notice-body strong { font-size: 14px; font-weight: 600; }
.notice-body p { font-size: 13px; line-height: 1.65; margin-top: 5px; }
.notice .btn { flex-shrink: 0; background: rgba(255,255,255,.8); color: #704600; }
.hero { grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); gap: 20px; margin-bottom: 22px; }
.hero-main { padding: 28px 30px; background: linear-gradient(135deg,#ffffff 55%,#f3f8ff); display: flex; flex-direction: column; align-items: flex-start; }
.hero-label { font-size: 14px; }
.hero-value { margin: 14px 0 10px; max-width: 100%; flex-wrap: wrap; }
#gap-value { font-size: clamp(42px,4.4vw,64px); line-height: 1.15; overflow-wrap: anywhere; }
#gap-value.none, #gap-value.met { font-size: clamp(26px,2.7vw,36px); color: var(--text); font-weight: 600; letter-spacing: -.025em; }
#gap-value.met { color: var(--success); }
.hero-meta { font-size: 13px; line-height: 1.6; }
.hero-cta { margin-top: 18px; }
.progress { width: 100%; height: 8px; margin-top: 24px; }
.progress-legend { width: 100%; gap: 10px 18px; font-size: 12px; margin-top: 14px; }
.hero-side { gap: 16px; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.stat { padding: 21px 22px; min-width: 0; }
.stat-label { font-size: 12px; line-height: 1.5; }
.stat-value { font-size: 30px; margin: 6px 0 4px; line-height: 1.25; overflow-wrap: anywhere; }
.stat-note { font-size: 12px; line-height: 1.55; }
.card-head { padding: 24px 26px 0; gap: 16px 24px; }
.card-head > div:first-child { min-width: 0; flex: 1 1 260px; }
.card-head h2 { font-size: 18px; line-height: 1.4; }
.card-sub { font-size: 13px; margin-top: 6px; line-height: 1.6; }
.chart-card, .activities-card { margin-bottom: 22px; }
.chart-toggle { flex-shrink: 0; }
.chart-toggle button { padding: 5px 11px; }
.chart { padding: 20px 24px 22px; }
.chart.is-empty { padding-top: 18px; }
.chart-empty-state { min-height: 166px; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: #f8f9fb; border-radius: 16px; }
.chart-empty-state svg { width: 38px; height: 38px; color: #7b8a9e; margin-bottom: 10px; }
.chart-empty-state strong { font-size: 14px; color: var(--text-2); font-weight: 600; }
.chart-empty-state p { max-width: 520px; margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
#activity-filter { width: min(100%,260px); flex: 0 1 260px; background: #f8f8fa; }
.table-scroll { padding: 18px 14px 12px; }
.table th { font-size: 12px; letter-spacing: 0; text-transform: none; padding: 12px; background: #f8f8fa; position: static; white-space: normal; line-height: 1.5; }
.table td { padding: 14px 12px; font-size: 13px; }
#activity-table { min-width: 920px; }
.table .num { white-space: nowrap; }
.table th.num { white-space: normal; }
.name-cell { min-width: 240px; max-width: 360px; line-height: 1.55; overflow-wrap: anywhere; }
.name-meta { margin-top: 5px; font-size: 11.5px; line-height: 1.8; }
.tag { padding: 2px 7px; font-size: 10.5px; letter-spacing: 0; }
.rate-num { width: auto; min-width: 46px; white-space: nowrap; }
.two-col { gap: 22px; }
.two-col > .card { min-width: 0; padding-bottom: 22px; }
.target-editor { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 22px 26px 10px; gap: 16px; }
.field > span { font-size: 12px; }
.field-actions { grid-column: 1 / -1; }
.hint { margin: 4px 26px 0; line-height: 1.65; }
.data-label { font-size: 12px; line-height: 1.5; }
.foot { font-size: 12px; line-height: 1.7; }
.toast { border-radius: 16px; max-width: calc(100vw - 32px); width: max-content; text-align: center; }
@media (max-width:1180px) {
  .topbar-inner { row-gap: 16px; }
  .topbar-right { margin-left: auto; }
}
@media (max-width:1080px) {
  .hero, .two-col { grid-template-columns: minmax(0,1fr); }
  .hero-main { padding: 26px; }
  .notice { flex-wrap: wrap; }
  .notice-body { flex-basis: calc(100% - 40px); }
  .notice .btn { margin-left: 34px; }
  .target-editor { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width:720px) {
  .topbar { position: relative; }
  .topbar-inner { padding: 18px 18px 16px; }
  .brand h1 { font-size: 17px; }
  .sub { font-size: 12px; }
  .topbar-right { width: 100%; justify-content: space-between; margin-left: 0; gap: 8px; }
  .lang-switch button { font-size: 12px; padding: 5px 9px; }
  .wrap { padding: 22px 16px 36px; }
  .controls { gap: 14px; }
  .segmented { display: flex; }
  .segmented button { padding: 6px; font-size: 12px; min-width: 0; }
  .period-nav { display: flex; gap: 8px; }
  .period-picker { flex: 1; }
  #btn-current { max-width: 110px; }
  .notice { padding: 16px; gap: 10px; }
  .notice .btn { margin-left: 31px; max-width: calc(100% - 31px); }
  .hero-main { padding: 24px; }
  #gap-value.none, #gap-value.met { font-size: 28px; }
  .stat { padding: 18px 16px; }
  .stat-value { font-size: 27px; }
  .hero-side { gap: 12px; }
  .card-head { padding: 22px 20px 0; }
  .card-head > div:first-child { flex-basis: 100%; }
  .card-head h2 { font-size: 17px; }
  .chart { padding: 18px 16px; }
  .chart-empty-state { padding: 22px 16px; }
  #activity-filter { width: 100%; flex-basis: 100%; }
  .target-editor { grid-template-columns: minmax(0,1fr); padding: 22px 20px 10px; }
  .field-actions .btn { flex: 1; }
  .legend-elapsed { margin-left: 0; flex-basis: 100%; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
}


/* Automatic monthly reward progress. */
.reward-card { margin-bottom: 22px; padding: 22px 26px; }
.reward-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 16px; }
.reward-heading h2 { font-size: 17px; }
#reward-status { font-size: 12px; color: var(--muted); }
.reward-tiers { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.reward-step { border: 1px solid var(--border-soft); background: #f8f9fb; border-radius: 12px; padding: 14px 16px; }
.reward-step-top, .reward-step-bottom { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.reward-step-top span { font-size: 13px; color: var(--text-2); }
.reward-step-top b { font-size: 20px; color: var(--accent); font-variant-numeric: tabular-nums; }
.reward-step-bottom { margin-top: 7px; font-size: 12px; color: var(--muted); }
.reward-step.reached { background: var(--success-soft); border-color: rgba(24,120,62,.15); }
.reward-step.reached b { color: var(--success); }
@media (max-width:720px) {
  .reward-card { padding: 20px; }
  .reward-tiers { grid-template-columns: minmax(0,1fr); gap: 10px; }
}

/* ==========================================================================
   Hero v2 — one card carrying target progress AND the reward ladder on a
   single track. Replaces the old hero + 4 stat cards + separate reward card,
   which restated the same "0 of 60" fact six times.
   ========================================================================== */
.hero { grid-template-columns: minmax(0, 1fr); gap: 0; margin-bottom: 22px; }

.hero-main {
  display: block;
  align-items: stretch;
  padding: 24px 28px 20px;
  background: linear-gradient(135deg, #ffffff 52%, #f2f7ff);
  transition: background .25s ease, border-color .25s ease;
}
/* period is running out faster than units are landing */
.hero-main.at-risk {
  background: linear-gradient(135deg, #ffffff 46%, #fff6e8);
  border-color: rgba(178,106,0,.22);
}
.hero-main.is-met { background: linear-gradient(135deg, #ffffff 48%, #eefaf1); }

/* ---- header row ---- */
.hero-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px 18px; flex-wrap: wrap;
}
.hero-head-left { min-width: 0; }
.hero-title { font-size: 15px; letter-spacing: -.01em; }
.hero-sub {
  display: block; margin-top: 3px;
  font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.hero-head-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.hero-days { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.hero-flag {
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  padding: 3px 10px; border-radius: 980px;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid rgba(178,106,0,.22);
}
.hero-main.at-risk .hero-flag { background: var(--warn); color: #fff; }

/* ---- the headline metric ---- */
.hero-metric {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 0 10px; margin: 12px 0 2px;
}
.hero-done {
  font-size: clamp(46px, 5.2vw, 68px); font-weight: 700;
  letter-spacing: -.035em; line-height: 1.02;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.hero-main.is-met .hero-done { color: var(--success); }
.hero-slash { font-size: 30px; color: var(--muted); font-weight: 300; }
.hero-target {
  font-size: clamp(26px, 2.6vw, 34px); font-weight: 600; color: var(--text-2);
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.hero-unit { font-size: 15px; color: var(--muted); font-weight: 500; }
.hero-callout {
  margin-left: auto; align-self: center;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  padding: 6px 14px; border-radius: 980px;
  background: var(--accent-soft); color: #0059c9;
}
.hero-callout:empty { display: none; }
.hero-main.at-risk .hero-callout { background: #fdeee0; color: var(--warn); }

/* ---- the shared track ---- */
.track {
  position: relative; height: 14px; margin: 18px 0 0;
  background: rgba(118,118,128,.14); border-radius: 7px;
}
.track-fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg, #0a84ff, #0071e3);
  border-radius: 7px;
  transition: width .55s cubic-bezier(.4,0,.2,1);
}
.track-fill.met { background: linear-gradient(90deg, #34c759, #1d9d4e); }
/* reward milestone notches sitting on the bar */
.track .tick {
  position: absolute; top: -4px; bottom: -4px; width: 2px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.10);
  border-radius: 2px; transform: translateX(-1px);
}
.track .tick.reached { background: #fff; box-shadow: 0 0 0 1.5px rgba(29,157,78,.55); }
/* elapsed-time marker: deliberately reads as "time", not progress */
.track-elapsed {
  position: absolute; top: -7px; bottom: -7px; width: 2px;
  background: rgba(29,29,31,.42); border-radius: 1px;
  transition: left .55s cubic-bezier(.4,0,.2,1);
}
.track-elapsed::after {
  content: ''; position: absolute; left: 50%; top: -1px;
  width: 0; height: 0; transform: translateX(-50%);
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid rgba(29,29,31,.42);
}

/* ---- milestone scale under the track ---- */
.track-scale {
  position: relative; height: 34px; margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.scale-min, .scale-max {
  position: absolute; top: 0; font-size: 11.5px; color: var(--muted);
}
.scale-min { left: 0; }
.scale-max { right: 0; }
.scale-ms {
  position: absolute; top: -1px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
  line-height: 1.25; text-align: center;
}
.scale-ms b { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.scale-ms em {
  font-style: normal; font-size: 11px; font-weight: 600; color: var(--accent);
}
.scale-ms.reached b, .scale-ms.reached em { color: var(--success); }
.hero-main.at-risk .scale-ms em { color: var(--warn); }

/* ---- supporting numbers, each stated once ---- */
.hero-foot {
  display: flex; flex-wrap: wrap; gap: 8px 30px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.hero-foot-item { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; }
.hero-foot-item em {
  font-style: normal; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.hero-foot-item b {
  font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.basis-tag {
  font-style: normal; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 5px;
  background: rgba(118,118,128,.13); color: var(--muted);
}

/* ---- collapsed trend card while there is nothing to plot ---- */
.chart-card.collapsed { padding-bottom: 16px; }
.chart-card.collapsed .chart { padding: 10px 22px 0; }
.chart-empty-line {
  display: flex; align-items: center; gap: 10px;
  margin: 0; padding: 12px 16px;
  font-size: 12.5px; color: var(--muted);
  background: #f8f9fb; border-radius: 10px;
}
.chart-empty-line svg { width: 20px; height: 20px; flex-shrink: 0; color: #97a3b4; }

@media (max-width: 860px) {
  .hero-callout { margin-left: 0; width: 100%; text-align: center; }
  .hero-main { padding: 20px 20px 16px; }
}
@media (max-width: 620px) {
  .hero-metric { gap: 0 8px; }
  .hero-foot { gap: 8px 18px; }
  .track-scale { height: 38px; }
  .scale-ms em { font-size: 10px; }
}

/* Keyboard focus ring for interactive controls (this rule used to share a
   selector list with the removed .dropzone, so it must stay defined). */
button:focus-visible, summary:focus-visible, [role="button"]:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 3px;
}

/* ==========================================================================
   Period dropdown — replaces a native <select> whose popup the OS positioned
   upward, hiding the list behind the browser toolbar.
   ========================================================================== */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  min-width: 158px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: #fff; color: var(--text); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropdown-toggle:hover { background: #f7f7f9; }
.dropdown-toggle[aria-expanded="true"] { border-color: var(--accent); background: #fff; }
.dropdown-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dropdown-toggle #period-label { flex: 1; text-align: left; }
.dropdown-toggle .caret { color: var(--muted); transition: transform .18s ease; flex: 0 0 auto; }
.dropdown.open .dropdown-toggle .caret { transform: rotate(180deg); }

/* the panel always drops DOWN from the trigger */
.dropdown-panel {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 100%; max-height: 288px; overflow-y: auto;
  padding: 5px; z-index: 60;
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 34px rgba(0,0,0,.14), 0 2px 6px rgba(0,0,0,.06);
  animation: dd-in .13s ease-out;
}
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dropdown-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 8px 11px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; text-align: left;
  font-family: inherit; font-size: 13px; color: var(--text);
  white-space: nowrap;
}
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--accent-soft); outline: none; }
.dropdown-item.on { font-weight: 650; color: var(--accent); }
.dropdown-item .check { flex: 0 0 auto; color: var(--accent); }

/* ---- chart: hover columns + prominent tooltip ---- */
.chart { position: relative; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bar.hover { fill: #0059c9; }
.chart-tip {
  position: absolute; z-index: 20; pointer-events: none;
  min-width: 152px; padding: 10px 12px;
  background: rgba(28,28,30,.96); color: #fff;
  border-radius: 11px; font-size: 12.5px; line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  backdrop-filter: blur(6px);
}
.chart-tip::after {
  content: ''; position: absolute; left: var(--caret, 50%); bottom: -5px;
  width: 10px; height: 10px; transform: translateX(-50%) rotate(45deg);
  background: rgba(28,28,30,.96); border-radius: 2px;
}
.chart-tip .tip-period {
  font-size: 11.5px; font-weight: 600; color: #9ec5ff;
  letter-spacing: .02em; margin-bottom: 5px;
}
.chart-tip .tip-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
}
.chart-tip .tip-row span { color: rgba(255,255,255,.72); }
.chart-tip .tip-row b { font-variant-numeric: tabular-nums; font-weight: 650; }
.chart-tip .tip-gap { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.16); }
.chart-tip .tip-gap b { color: #ffcf70; }
.chart-tip .tip-gap.met b { color: #7ee2a0; }

/* tooltip arrow flips to the top edge when the tip sits below the bar */
.chart-tip.below::after {
  bottom: auto; top: -5px;
}
