:root {
  --paper: #e9edf0; --panel: #ffffff; --ink: #1b252d; --steel: #5a6873; --rule: #c7d0d6;
  --amber: #e09a12; --amber-ink: #1e1500; --lamp: #ffb92e; --ok: #1f7a4d; --bad: #b3261e;
  --key: #f4f6f8; --key-edge: #b9c3ca;
  color-scheme: light dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12181d; --panel: #1a2229; --ink: #e2e8ec; --steel: #93a1ab; --rule: #2d3841;
    --amber: #f0a928; --amber-ink: #1e1500; --lamp: #ffc24a; --ok: #5fc38f; --bad: #ff8a80;
    --key: #222c34; --key-edge: #36434d;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.45 Barlow, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-underline-offset: 3px; }
h1 { font-size: 1.45rem; line-height: 1.2; margin: 0 0 .75rem; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; font-weight: 600; }
.muted { color: var(--steel); font-weight: 400; }
.center { text-align: center; display: block; }

.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem max(1rem, env(safe-area-inset-left)); background: #1d2a33; color: #e8eef2;
}
.mark { font-weight: 700; letter-spacing: .01em; }
.tabs { display: flex; gap: .25rem; }
.tabs a { text-decoration: none; padding: .35rem .7rem; border-radius: 6px; color: #b9c7d0; }
.tabs a[aria-current] { color: #fff; background: #2f404c; box-shadow: inset 0 -3px 0 var(--lamp); }

main { max-width: 640px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 1.1rem; margin-bottom: 1rem; }
.narrow { max-width: 400px; margin: 3rem auto; }

label { display: block; font-weight: 500; margin: .8rem 0 0; }
input:not([type=radio]), select, textarea {
  display: block; width: 100%; margin-top: .3rem; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: .6rem .7rem; min-height: 46px;
}
input[type=file] { padding: .5rem; }
textarea { resize: vertical; }
:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }
fieldset { border: 0; padding: 0; margin: .8rem 0 0; }
legend { font-weight: 500; padding: 0; margin-bottom: .3rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
[hidden] { display: none !important; }

button, .primary, .ghost {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: .65rem 1rem;
  border: 1px solid var(--key-edge); background: var(--key); color: var(--ink); margin-top: 1rem; text-decoration: none; display: inline-block;
}
.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.big { display: block; width: 100%; text-align: center; padding: .9rem; font-size: 1.05rem; }
.disabled { opacity: .45; cursor: not-allowed; }
.ghost { background: transparent; border-color: transparent; text-decoration: underline; }
button.link { background: none; border: 0; padding: 0; margin: 0; font-weight: 500; color: var(--bad); text-decoration: underline; }

/* Segmented controls, styled like panel pushbuttons with an indicator lamp */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .4rem; margin-top: .8rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  margin: 0; text-align: center; padding: .6rem .3rem .7rem; border-radius: 8px; cursor: pointer;
  background: var(--key); border: 1px solid var(--key-edge); box-shadow: 0 2px 0 var(--key-edge);
  position: relative; user-select: none; -webkit-tap-highlight-color: transparent;
}
.seg label::after {
  content: ""; position: absolute; left: 30%; right: 30%; bottom: 4px; height: 3px; border-radius: 2px; background: var(--rule);
}
.seg input:checked + label { background: var(--panel); border-color: var(--amber); transform: translateY(2px); box-shadow: none; }
.seg input:checked + label::after { background: var(--lamp); box-shadow: 0 0 8px var(--lamp); }
.seg input:focus-visible + label { outline: 3px solid var(--lamp); outline-offset: 2px; }
.kinds label { font-weight: 600; font-size: 1.05rem; }
.seg.small label { padding: .45rem .3rem .6rem; }
.codes { grid-auto-flow: row; grid-template-columns: repeat(5, 1fr); }
.codes label { display: flex; flex-direction: column; gap: .1rem; padding: .7rem .2rem .85rem; }
.codes b { font-size: 1.15rem; }
.codes small { font-size: .7rem; line-height: 1.15; color: var(--steel); }
@media (max-width: 420px) { .codes { grid-template-columns: repeat(3, 1fr); } }

.flash { padding: .7rem .9rem; border-radius: 8px; border-left: 5px solid; background: var(--panel); margin: 0 0 1rem; }
.flash.ok { border-color: var(--ok); }
.flash.err { border-color: var(--bad); }

.weekhead { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.weekhead h1 { margin: 0; text-align: center; }
.step { text-decoration: none; font-size: 1.8rem; line-height: 1; padding: .2rem .7rem; border-radius: 8px; border: 1px solid var(--rule); background: var(--panel); }
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: .75rem 0 1rem; }
.totals div { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: .5rem .6rem; }
.totals dt { font-size: .8rem; color: var(--steel); }
.totals dd { margin: 0; font-weight: 600; font-size: 1.1rem; }
@media (max-width: 420px) { .totals { grid-template-columns: repeat(2, 1fr); } }
.problems { border: 2px solid var(--bad); border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; background: var(--panel); }
.problems ul { margin: 0; padding-left: 1.1rem; }

.day { margin: 1.1rem 0; }
.day h2 { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--rule); padding-bottom: .3rem; }
.day h2 a { text-decoration: none; }
.day.empty h2 { color: var(--steel); font-weight: 500; }
.dayhrs { font-weight: 600; }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li {
  display: grid; grid-template-columns: auto 1fr auto; gap: .2rem .7rem; align-items: baseline;
  padding: .55rem 0; border-bottom: 1px dashed var(--rule);
}
.tag { font-size: .8rem; font-weight: 600; padding: .1rem .45rem; border-radius: 4px; background: var(--key); border: 1px solid var(--key-edge); white-space: nowrap; }
.tag.k-time { border-color: var(--amber); }
.what small { display: block; color: var(--steel); font-size: .85rem; }
.amt { font-weight: 600; text-align: right; }
.acts { grid-column: 2 / -1; display: flex; gap: 1rem; font-size: .9rem; }
.acts form { display: inline; }
.export { display: grid; gap: .25rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
label.check input { width: 1.2rem; height: 1.2rem; min-height: 0; margin: 0; accent-color: var(--amber); }
.preview h3 { font-size: 1rem; margin: .75rem 0 .25rem; }
.preview ol { margin: 0; padding-left: 1.4rem; }
.preview li { overflow-wrap: anywhere; }
@media (max-width: 440px) { .mark { display: none; } .bar { justify-content: center; } }

/* iOS Safari gives date/time inputs an intrinsic width wider than the form; reset it */
input[type=date], input[type=time] {
  -webkit-appearance: none; appearance: none;
  min-width: 0; max-width: 100%; text-align: left;
}
input[type=date]::-webkit-date-and-time-value,
input[type=time]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.two > * { min-width: 0; }
