/* ==========================================================
   Shift log
   Two-tone idea: amber = day shift, midnight = night shift.
   ========================================================== */

:root {
  --bg: #f2effb;
  --surface: #ffffff;
  --surface-2: #f7f5fd;
  --ink: #211843;
  --muted: #655d8a;
  --line: #e1dbf1;

  --accent: #5a2ad8;
  --accent-ink: #ffffff;

  --day: #f4a90f;
  --day-ink: #35230a;
  --night: #231a63;
  --night-ink: #ffffff;

  --pos: #0b8563;
  --neg: #c2314f;

  --band: #231a63;
  --band-night: #948dff;

  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

:root[data-theme='dark'] {
  --bg: #0e0a20;
  --surface: #181236;
  --surface-2: #201948;
  --ink: #f0ebff;
  --muted: #a99fd6;
  --line: #2e2660;

  --accent: #a58bff;
  --accent-ink: #160e3a;

  --day: #f7b733;
  --day-ink: #2e1d00;
  --night: #5b52f0;
  --night-ink: #ffffff;

  --pos: #4fdcae;
  --neg: #ff7d9c;

  --band: #1b1355;
  --band-night: #8f88ff;
}

[data-shift='day']   { --shift: var(--day);   --shift-ink: var(--day-ink); }
[data-shift='night'] { --shift: var(--night); --shift-ink: var(--night-ink); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-size: .92em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.band :focus-visible { outline-color: var(--day); }

.wrap { width: min(1180px, 100%); margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
svg.ico { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; line-height: 1.2; background: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { border-color: var(--line); background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sun { background: var(--day); color: var(--day-ink); }
.btn--sun:hover { filter: brightness(1.06); }
.btn--band { color: #fff; border-color: rgba(255, 255, 255, .28); }
.btn--band:hover { background: rgba(255, 255, 255, .12); }
.btn--danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 45%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--neg) 10%, transparent); }
.btn--danger-solid { background: var(--neg); color: #fff; }
.btn--danger-solid:hover { filter: brightness(1.08); }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid transparent; background: none; color: var(--muted);
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn--band { color: #fff; border-color: rgba(255, 255, 255, .28); }
.icon-btn--band:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.icon-btn--danger:hover { color: var(--neg); background: color-mix(in srgb, var(--neg) 12%, transparent); }

/* ---------- Top band ---------- */
.band {
  background: var(--band); color: #fff;
  border-radius: 0 0 36px 36px;
  padding-bottom: 20px;
}
.top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; padding-block: 18px 6px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(90deg, var(--day) 50%, var(--band-night) 50%);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .16);
}
.brand__name { font: 800 19px/1.1 var(--font-display); letter-spacing: -.01em; }
.brand__sub { font-size: 13px; color: rgba(255, 255, 255, .68); }
.top__actions { display: flex; align-items: center; gap: 8px; }

/* Year picker: the active year is the headline */
.years {
  display: flex; align-items: baseline; gap: clamp(16px, 3.5vw, 40px);
  overflow-x: auto; padding: 14px 4px 18px; scrollbar-width: none;
}
.years::-webkit-scrollbar { display: none; }
.year {
  position: relative; background: none; border: 0; padding: 4px 0; border-radius: 6px;
  font: 700 clamp(28px, 5vw, 44px)/1 var(--font-display);
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .45);
  transition: color .15s;
}
.year:hover { color: rgba(255, 255, 255, .85); }
.year.is-active {
  color: #fff; font-weight: 800; font-size: clamp(60px, 12vw, 120px); letter-spacing: -.04em;
}
.year.is-active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -6px; height: 7px; border-radius: 4px;
  background: linear-gradient(90deg, var(--day) 50%, var(--band-night) 50%);
}

/* Year figures */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid rgba(255, 255, 255, .16); margin-top: 8px;
}
.stat { padding: 16px 12px 4px 0; }
.stat + .stat { padding-left: 20px; border-left: 1px solid rgba(255, 255, 255, .16); }
.stat b { display: block; font: 700 clamp(26px, 4vw, 42px)/1.1 var(--font-display); letter-spacing: -.02em; }
.stat span { font-size: 14px; color: rgba(255, 255, 255, .7); }

/* ---------- Layout ---------- */
main { padding-top: 26px; display: flex; flex-direction: column; gap: 26px; }
main.is-loading > *:not(.banner) { opacity: .55; transition: opacity .15s; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: clamp(16px, 2.4vw, 24px);
}
.panel__head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 6px 16px; margin-bottom: 14px;
}
.panel__head h2 { font: 700 21px/1.2 var(--font-display); letter-spacing: -.01em; }
.panel__sub { font-size: 14px; color: var(--muted); }

.charts { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
.month__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 4px; background: var(--shift); display: inline-block; }
.legend i.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.banner {
  background: color-mix(in srgb, var(--neg) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--neg) 45%, transparent);
  border-radius: 16px; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

.foot { padding-block: 28px 40px; color: var(--muted); font-size: 14px; }

/* ---------- Charts ---------- */
.chart {
  --plot-h: 230px;
  display: grid; grid-template-columns: 38px minmax(0, 1fr); grid-template-rows: var(--plot-h) auto;
  column-gap: 8px; margin-top: 22px;
}
.chart__axis { position: relative; }
.chart__axis span {
  position: absolute; right: 0; transform: translateY(-50%);
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.chart__plot { position: relative; }
.chart__line { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.chart__line--zero { height: 2px; background: color-mix(in srgb, var(--muted) 55%, transparent); }
.chart__cols {
  position: absolute; inset: 0; display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: clamp(2px, .8vw, 8px);
}
.chart__col {
  position: relative; border: 0; padding: 0; background: none; border-radius: 10px;
  transition: background-color .15s;
}
.chart__col:hover, .chart__col.is-selected { background: color-mix(in srgb, var(--accent) 9%, transparent); }

.chart__labels {
  grid-column: 2; display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: clamp(2px, .8vw, 8px); margin-top: 6px;
}
.chart__lbl {
  border: 0; background: none; border-radius: 8px; padding: 6px 0;
  font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.chart__lbl .l1 { display: none; }
.chart__lbl:hover { color: var(--ink); }
.chart__lbl.is-selected { color: var(--accent-ink); background: var(--accent); font-weight: 700; }

/* stacked bars */
.chart__stack {
  position: absolute; bottom: 0; left: 0; right: 0; margin-inline: auto;
  width: min(68%, 54px); height: var(--h);
  display: flex; flex-direction: column;
  border-radius: 8px 8px 0 0; overflow: hidden; transform-origin: bottom;
}
.chart__seg { display: block; flex: var(--w) 1 0; min-height: 0; background: var(--shift); }
.chart__val {
  position: absolute; left: 0; right: 0; bottom: var(--h); padding-bottom: 4px;
  text-align: center; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* diverging bars */
.chart__bar {
  position: absolute; left: 0; right: 0; margin-inline: auto;
  width: min(62%, 28px); height: var(--h);
}
.chart__bar--pos { bottom: 50%; background: var(--pos); border-radius: 6px 6px 0 0; transform-origin: bottom; }
.chart__bar--neg { top: 50%; background: var(--neg); border-radius: 0 0 6px 6px; transform-origin: top; }
.chart__dval {
  position: absolute; left: -4px; right: -4px; text-align: center;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.chart__dval--pos { bottom: calc(50% + var(--h) + 3px); color: var(--pos); }
.chart__dval--neg { top: calc(50% + var(--h) + 3px); color: var(--neg); }

/* the one orchestrated moment: bars rise when a year is loaded */
@keyframes rise { from { transform: scaleY(0); } }
@keyframes fade { from { opacity: 0; } }
.chart.is-animated .chart__stack,
.chart.is-animated .chart__bar { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: calc(var(--i) * 40ms); }
.chart.is-animated .chart__val,
.chart.is-animated .chart__dval { animation: fade .35s ease backwards; animation-delay: calc(var(--i) * 40ms + 450ms); }

/* ---------- Month tabs ---------- */
.months {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; margin-bottom: 18px;
}
.month-tab {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 9px 4px 8px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 14px;
  transition: background-color .15s, border-color .15s;
}
.month-tab small { font-size: 12px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.month-tab:hover { border-color: var(--accent); }
.month-tab.is-active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.month-tab.is-active small { color: inherit; opacity: .8; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal__dow { text-align: center; font-size: 12.5px; font-weight: 600; color: var(--muted); padding-bottom: 4px; }

.cell {
  position: relative; aspect-ratio: 1 / 1; min-height: 0; padding: 6px 7px;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2);
  text-align: left; color: var(--ink);
  transition: transform .12s, border-color .15s;
}
.cell:hover { border-color: var(--accent); transform: translateY(-1px); }
.cell--blank { visibility: hidden; }
.cell--shift { background: var(--shift); color: var(--shift-ink); border-color: transparent; }
.cell--shift:hover { border-color: transparent; filter: brightness(1.08); }
.cell.is-today { outline: 2px solid var(--accent); outline-offset: 2px; }
.cell__num { font-weight: 700; font-size: 14px; line-height: 1; font-variant-numeric: tabular-nums; }
.cell__extra { position: absolute; top: 6px; right: 7px; font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.cell__icon { align-self: flex-end; font-size: 17px; line-height: 0; }
.cell__dot { position: absolute; left: 8px; bottom: 8px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.hint { font-size: 13.5px; color: var(--muted); }
.hint--foot { margin-top: 14px; }

/* ---------- List ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 4px 14px; align-items: center;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; padding-top: 4px; }
.row__date {
  text-align: center; border-radius: 14px; padding: 7px 0 6px; line-height: 1.1;
  background: var(--shift); color: var(--shift-ink);
}
.row__date b { display: block; font: 800 22px/1.05 var(--font-display); }
.row__date span { font-size: 12px; font-weight: 600; opacity: .85; }
.row__main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row__title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.row__title svg { color: var(--shift); }
.row__meta { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row__acts { display: flex; gap: 2px; }
.row__note {
  grid-column: 2 / -1; font-size: 14px; color: var(--muted);
  background: var(--surface-2); border-radius: 12px; padding: 8px 12px; overflow-wrap: anywhere; white-space: pre-wrap;
}

.delta {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--muted);
}
.delta--pos { color: var(--pos); background: color-mix(in srgb, var(--pos) 14%, transparent); }
.delta--neg { color: var(--neg); background: color-mix(in srgb, var(--neg) 14%, transparent); }

.empty { padding: 22px 6px 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.empty b { font: 700 18px var(--font-display); }
.empty p { color: var(--muted); }
.empty .btn { margin-top: 10px; }

/* ---------- Dialogs ---------- */
dialog {
  border: 0; padding: 0; margin: auto; color: var(--ink); background: var(--surface);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  border-radius: 26px; box-shadow: 0 30px 80px -20px rgba(12, 6, 44, .6);
  overflow: auto;
}
dialog.wide { width: min(780px, calc(100vw - 24px)); }
dialog.narrow { width: min(430px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(14, 8, 44, .62); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .2s cubic-bezier(.2, .9, .3, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.sheet { padding: 22px clamp(18px, 4vw, 26px) 22px; display: flex; flex-direction: column; gap: 18px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet h2 { font: 700 24px/1.15 var(--font-display); letter-spacing: -.01em; }
.sheet__foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.spacer { flex: 1; }
.confirm__text { color: var(--muted); margin-top: -8px; }

.field { display: flex; flex-direction: column; gap: 7px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field__label { font-size: 14px; font-weight: 600; padding: 0; }
input[type='date'], input[type='time'], input[type='password'], textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); color-scheme: light;
}
:root[data-theme='dark'] input, :root[data-theme='dark'] textarea { color-scheme: dark; }
textarea { resize: vertical; min-height: 84px; }
input:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--accent); }

.shift-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shift-opt {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  border-radius: 16px; border: 2px solid var(--line); background: var(--surface-2); cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.shift-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.shift-opt:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.shift-opt__icon { font-size: 24px; line-height: 0; color: var(--shift); }
.shift-opt__text { display: flex; flex-direction: column; line-height: 1.25; }
.shift-opt__text small { font-size: 13px; opacity: .8; }
.shift-opt.is-checked { background: var(--shift); color: var(--shift-ink); border-color: transparent; }
.shift-opt.is-checked .shift-opt__icon { color: inherit; }

.leave-hint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--muted); min-height: 26px; }
.form-error {
  color: var(--neg); background: color-mix(in srgb, var(--neg) 11%, transparent);
  padding: 10px 14px; border-radius: 12px; font-size: 14.5px;
}

/* ---------- Yearly dialog ---------- */
.ytable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ytable th { text-align: right; font-size: 13px; font-weight: 600; color: var(--muted); padding: 8px 10px; }
.ytable td { text-align: right; padding: 12px 10px; border-top: 1px solid var(--line); }
.ytable th:first-child, .ytable td:first-child { text-align: left; padding-left: 0; }
.ytable td:first-child button {
  background: none; border: 0; padding: 0; font: 800 22px var(--font-display); letter-spacing: -.02em; text-decoration: underline transparent;
}
.ytable td:first-child button:hover { text-decoration-color: currentColor; }
.ytable tr.is-current td:first-child button { color: var(--accent); }
.ytable tfoot td { font-weight: 700; }
.table-scroll { overflow-x: auto; }

/* ---------- Tooltip & toast ---------- */
.tip {
  position: fixed; left: 0; top: 0; z-index: 2000; pointer-events: none; opacity: 0;
  background: var(--ink); color: var(--bg); padding: 6px 11px; border-radius: 10px;
  font-size: 13px; line-height: 1.35; max-width: 280px; transition: opacity .1s;
}
.tip.show { opacity: 1; }
.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 3000; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px;
  font-weight: 600; font-size: 14.5px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .charts, .month__grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .months { display: flex; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .month-tab { flex: 0 0 64px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { padding-left: 0; border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid rgba(255, 255, 255, .16); margin-top: 12px; padding-top: 16px; }
  .band { border-radius: 0 0 28px 28px; }
}
@media (max-width: 520px) {
  .top__actions .btn--band span { display: none; }
  .cell { padding: 4px 5px; border-radius: 10px; }
  .cell__num { font-size: 12.5px; }
  .cell__extra { top: 4px; right: 5px; font-size: 9.5px; }
  .cell__icon { font-size: 13px; }
  .cell__dot { left: 5px; bottom: 5px; width: 5px; height: 5px; }
  .cal { gap: 4px; }
  .chart { --plot-h: 200px; grid-template-columns: 32px minmax(0, 1fr); }
  .chart__val { font-size: 11px; }
  .chart__lbl { font-size: 11.5px; }
  .chart__lbl .l3 { display: none; }
  .chart__lbl .l1 { display: inline; }
  .shift-pick { grid-template-columns: 1fr; }
  .row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 4px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
