/* Grafik page. Colours: Okabe-Ito categorical set (colour-blind safe), light and dark variants.
   Series are told apart by colour, legend and the data table; the median line is dashed grey. */
:root {
  --s0: #0072B2; --s1: #D55E00; --s2: #009E73; --s3: #CC79A7; --s4: #B8860B; --sm: #6B7280;
  --grid: #E4E6EA;
}
@media (prefers-color-scheme: dark) {
  :root { --s0: #56B4E9; --s1: #F08C4A; --s2: #35C79A; --s3: #E3A0C8; --s4: #E5B93C; --sm: #A9B0BA; --grid: #2B2F36; }
}
.appbar-right a + a { margin-left: var(--space-md); }
.gmain { max-width: 1040px; margin-inline: auto; padding: var(--space-lg) var(--space-md) var(--space-xl); }
.gmain h1 { font-size: 1.5rem; }
.panel { margin-top: var(--space-md); outline: none; }
.panel h2 { font-size: 1.25rem; margin-bottom: var(--space-sm); }
.lede { color: var(--on-surface-variant); font-size: 0.9375rem; margin-bottom: var(--space-md); }
.note { background: var(--surface-container-low); border: 1px solid var(--outline-variant); border-radius: 6px; padding: var(--space-sm) var(--space-md); font-size: 0.875rem; margin-bottom: var(--space-md); max-width: none; }
.empty { padding: var(--space-lg) var(--space-md); color: var(--on-surface-variant); }

.seg { display: inline-flex; flex-wrap: wrap; }
.seg button, .btn, .controls select, .chip {
  font: inherit; font-size: 0.875rem; color: var(--on-surface); background: var(--surface);
  border: 1px solid var(--outline); border-radius: 6px; min-height: 40px; padding: 4px 12px; cursor: pointer;
}
.seg button { border-radius: 0; margin: 0 -1px -1px 0; }
.seg button[aria-pressed="true"] { background: var(--primary-container); color: var(--on-primary-container); border-color: var(--primary); position: relative; z-index: 1; }
.seg button:hover, .btn:hover, .chip:hover { background: var(--surface-container); }
.switcher { display: flex; gap: var(--space-sm); }
.switcher button { border-radius: 6px; margin: 0; }

.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-md); margin-bottom: var(--space-md); }
.field { display: flex; flex-direction: column; gap: 2px; font-size: 0.8125rem; color: var(--on-surface-variant); }
.controls select { min-width: 200px; max-width: 100%; }
.picker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; min-height: 36px; }
.chip .x { color: var(--on-surface-variant); font-size: 1.125rem; line-height: 1; }

.fig { margin: 0; }
.figwrap { position: relative; border: 1px solid var(--outline-variant); border-radius: 8px; padding: var(--space-sm); background: var(--surface); }
.plot { min-width: 0; }
.chart { display: block; max-width: 100%; touch-action: pan-y; font-family: inherit; }
.chart:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--outline); stroke-width: 1; }
.chart .tick { fill: var(--on-surface-variant); font-size: 12px; stroke: none; }
.chart .guide { stroke: var(--outline); stroke-width: 1; }
.chart .catch { fill: transparent; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .mk { stroke: var(--surface); stroke-width: 1.5; }
.s0 { stroke: var(--s0); fill: var(--s0); } .s1 { stroke: var(--s1); fill: var(--s1); } .s2 { stroke: var(--s2); fill: var(--s2); }
.s3 { stroke: var(--s3); fill: var(--s3); } .s4 { stroke: var(--s4); fill: var(--s4); } .sm { stroke: var(--sm); fill: var(--sm); }
.chart .ln { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .gapline { stroke: var(--outline); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .gapnote { fill: var(--on-surface-variant); font-size: 11px; stroke: none; }
.chart .ln.dash { stroke-dasharray: 6 4; }

.bars .blabel { fill: var(--on-surface); font-size: 13px; stroke: none; }
.bars .btrack { fill: var(--surface-container); stroke: none; }
.bars .bar { stroke: var(--surface); stroke-width: 1; }
.bars .segv { fill: #fff; font-size: 12px; stroke: none; font-weight: 500; }
.bars .bval { fill: var(--on-surface); font-size: 13px; font-weight: 600; stroke: none; }
.bars .brow { cursor: default; outline: none; }
.bars .brow:focus-visible .btrack { stroke: var(--primary); stroke-width: 2; }
@media (prefers-color-scheme: dark) { .bars .segv { fill: #0C0D0F; } }

.tip {
  position: absolute; z-index: 3; pointer-events: none; max-width: min(300px, calc(100% - 8px));
  background: var(--surface); color: var(--on-surface); border: 1px solid var(--outline); border-radius: 6px;
  padding: var(--space-sm) 10px; font-size: 0.8125rem; line-height: 1.4;
}
.tip[hidden] { display: none; }
.tip strong { display: block; margin-bottom: 4px; }
.tip-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.tip-row b { font-weight: 600; text-align: right; }
.tip-note { color: var(--on-surface-variant); margin-top: 4px; }

.sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; flex: none; }
.s0.sw { background: var(--s0); } .s1.sw { background: var(--s1); } .s2.sw { background: var(--s2); }
.s3.sw { background: var(--s3); } .s4.sw { background: var(--s4); } .sm.sw { background: var(--sm); }
.sw.dash { background: repeating-linear-gradient(90deg, var(--sm) 0 5px, transparent 5px 8px); height: 4px; border-radius: 0; width: 18px; }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-md); margin-top: var(--space-sm); font-size: 0.8125rem; color: var(--on-surface-variant); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.fig-actions { margin-top: var(--space-md); }
.dt-wrap { margin-top: var(--space-md); }
.dt-wrap[hidden] { display: none; }
.dt-scroll { overflow: auto; max-height: 420px; border: 1px solid var(--outline-variant); border-radius: 8px; }
.dt { font-size: 0.8125rem; }
.dt caption { text-align: left; padding: var(--space-sm) 12px; color: var(--on-surface-variant); caption-side: top; }
.dt th, .dt td { white-space: nowrap; }
.dt .num { text-align: right; }
.dt thead th { position: sticky; top: 0; }
.source { margin-top: var(--space-md); font-size: 0.8125rem; color: var(--on-surface-variant); max-width: none; }

/* holiday calendar */
.cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--space-md); padding: var(--space-xs); }
.cal-m h3 { font-size: 0.875rem; margin-bottom: 4px; }
.cal-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-h { font-size: 0.6875rem; color: var(--on-surface-variant); }
.cal-d { font: inherit; font-size: 0.75rem; line-height: 26px; height: 28px; border-radius: 4px; border: 1px solid transparent; background: none; color: var(--on-surface); padding: 0; }
.cal-d.wk { color: var(--on-surface-variant); }
button.cal-d { cursor: pointer; font-weight: 600; }
.cal-d.nat { background: var(--s1); color: #fff; }
.cal-d.cuti { background: var(--surface); color: var(--on-surface); border: 2px dashed var(--s0); line-height: 24px; }
@media (prefers-color-scheme: dark) { .cal-d.nat { color: #0C0D0F; } }
.sw.cal-nat { background: var(--s1); }
.sw.cal-cuti { background: var(--surface); border: 2px dashed var(--s0); }
.sw.cal-wk { background: var(--surface-container); border: 1px solid var(--outline); }

@media (max-width: 520px) {
  .controls select { min-width: 0; width: 100%; }
  .field { width: 100%; }
  .switcher button { flex: 1 1 auto; }
}

/* keep real tables on phones (site.css stacks rows into cards below 768px) */
@media (max-width: 767px) {
  .dt { display: table; width: max-content; min-width: 100%; }
  .dt thead { display: table-header-group; }
  .dt tbody { display: table-row-group; }
  .dt tr { display: table-row; padding: 0; border-bottom: none; width: auto; }
  .dt th, .dt td { display: table-cell; width: auto; padding: var(--space-sm) 12px; border-bottom: 1px solid var(--outline-variant); }
  .dt td::before { content: none; }
}
