/* ---------------------------------------------------------------------------
   Leave Ledger — editorial clinical almanac.
   Warm paper ground, ink serif display, tabular mono for every figure.
   Numbers carry the meaning here, so they get the most deliberate treatment.
   --------------------------------------------------------------------------- */

:root {
  --paper:        #f2eee4;
  --paper-raised: #faf8f3;
  --ink:          #1b1a17;
  --ink-soft:     #5d594f;
  --ink-faint:    #918b7d;
  --rule:         #d6d0c1;
  --rule-strong:  #b3ab97;

  /* Bucket palette — distinguishable in sequence and against warm paper.
     Each holds >=4.5:1 against --paper-raised for its text use. */
  --vacation:  #1f5f78;
  --cme:       #4f6b32;
  --floating:  #a85c1c;
  --sick:      #77406a;
  --holiday:   #46433c;
  --alarm:     #9c2f24;

  --shadow-plate: 0 1px 0 rgba(27,26,23,.04), 0 12px 28px -22px rgba(27,26,23,.5);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 Karla, "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "kern" 1;
}

/* Paper tooth. Kept very light — it should read as stock, not as noise. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

main, header, footer { position: relative; z-index: 1; }

/* ---------------------------------------------------------- masthead ----- */

.masthead {
  border-bottom: 1px solid var(--rule-strong);
  padding: clamp(2rem, 6vw, 4.5rem) 0 clamp(1.5rem, 3vw, 2.25rem);
}

.masthead-inner,
main,
footer > p {
  width: min(1240px, calc(100% - clamp(1.5rem, 5vw, 4rem)));
  margin-inline: auto;
}

.masthead-mark {
  font: 500 11px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 1.1rem;
}

.masthead h1 {
  font: 700 clamp(3rem, 11vw, 7.5rem)/0.86 Fraunces, "Iowan Old Style", Georgia, serif;
  font-variation-settings: "opsz" 144, "SOFT" 0;
  letter-spacing: -.035em;
  margin: 0;
  /* Faint letterpress bite. */
  text-shadow: 0 1px 0 rgba(250,248,243,.6);
}

.standfirst {
  max-width: 46ch;
  margin: 1.4rem 0 0;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------- plates ---- */

main { padding: clamp(1.75rem, 4vw, 3rem) 0 5rem; }

.plate {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: var(--shadow-plate);
  padding: clamp(1.1rem, 2.4vw, 1.9rem);
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
}

.plate-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: .7rem;
  margin-bottom: 1.25rem;
}

.plate-head h2,
.section-title {
  font: 600 1.15rem/1 Fraunces, Georgia, serif;
  font-variation-settings: "opsz" 24;
  letter-spacing: -.01em;
  margin: 0;
}

button.ghost {
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  color: var(--ink-soft);
  font: 500 11px/1 "IBM Plex Mono", monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: .45rem .7rem;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
button.ghost:hover { background: var(--ink); color: var(--paper-raised); border-color: var(--ink); }

/* -------------------------------------------------------------- form ----- */

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 1rem 1.15rem;
}

.field-group-title {
  grid-column: 1 / -1;
  font: 500 10px/1 "IBM Plex Mono", monospace;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: .45rem;
  border-bottom: 1px solid var(--rule);
  margin-top: .6rem;
}
.field-group-title:first-child { margin-top: 0; }

.field label {
  display: block;
  font-size: .76rem;
  letter-spacing: .01em;
  color: var(--ink-soft);
  margin-bottom: .3rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: .45rem .55rem;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  color: var(--ink);
  font: 400 .92rem/1.4 "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--vacation);
  box-shadow: 0 0 0 3px rgba(31,95,120,.13);
}
.field textarea { min-height: 5rem; resize: vertical; }

button.primary {
  margin-top: 1.5rem;
  padding: .7rem 1.5rem;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  color: var(--paper);
  font: 600 .8rem/1 "IBM Plex Mono", monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .12s ease, background .16s ease;
}
button.primary:hover { background: var(--vacation); border-color: var(--vacation); }
button.primary:active { transform: translateY(1px); }

/* ------------------------------------------------------------ budget ----- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 0;
}

.stat {
  padding: .1rem 1rem .1rem 0;
  border-right: 1px solid var(--rule);
}
.stat:last-child { border-right: 0; }

.stat .value {
  font: 500 clamp(1.6rem, 3.4vw, 2.3rem)/1 "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}
.stat .label {
  margin-top: .35rem;
  font: 400 10px/1.3 "IBM Plex Mono", monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.stat.is-good .value  { color: var(--cme); }
.stat.is-alarm .value { color: var(--alarm); }

.headline-figure {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.1rem;
  margin-bottom: 1.1rem;
}
.headline-figure .big {
  font: 600 clamp(2.6rem, 7vw, 4.4rem)/.95 Fraunces, Georgia, serif;
  font-variation-settings: "opsz" 96;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
}
.headline-figure .big span { font-size: .38em; color: var(--ink-faint); letter-spacing: 0; }
.headline-figure .caption {
  margin-top: .3rem;
  color: var(--ink-soft);
  font-size: .92rem;
  max-width: 54ch;
}

.warning {
  display: flex;
  gap: .7rem;
  margin-top: .7rem;
  padding: .65rem .8rem;
  background: var(--paper);
  border-left: 2px solid var(--alarm);
  font-size: .88rem;
  line-height: 1.5;
}
.warning::before {
  content: "!";
  flex: none;
  font: 600 .75rem/1.5 "IBM Plex Mono", monospace;
  color: var(--alarm);
}
.warning.info { border-left-color: var(--rule-strong); }
.warning.info::before { content: "i"; color: var(--ink-faint); }

/* ------------------------------------------------------------ ledger ----- */

.ledger-lede {
  max-width: 62ch;
  margin: 0 0 1.4rem;
  color: var(--ink-soft);
  font-size: .92rem;
}

.ledger {
  border-top: 1px solid var(--rule);
}

.ledger-month {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--paper);
  padding: 1.1rem 0 .35rem;
  border-bottom: 1px solid var(--rule-strong);
  font: 500 10px/1 "IBM Plex Mono", monospace;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.week-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto auto;
  align-items: center;
  gap: .75rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-raised);
}
.week-row.has-holiday { background: transparent; }
.week-row.is-blackout { opacity: .5; }

.week-label {
  font: 500 .82rem/1.3 "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  padding-left: .55rem;
}

.week-detail { display: flex; flex-wrap: wrap; gap: .3rem; }

.chip {
  display: inline-block;
  padding: .2rem .5rem;
  border-radius: 2px;
  font: 500 .72rem/1.25 Karla, sans-serif;
  border: 1px solid transparent;
}
.chip.holiday   { background: var(--holiday);  color: #f4f1e8; }
.chip.vacation  { background: var(--vacation); color: #f2f6f8; }
.chip.cme       { background: var(--cme);      color: #f3f6ee; }
.chip.floating  { background: var(--floating); color: #fdf4ea; }
.chip.sick-mdss { background: var(--sick);     color: #f8f0f6; }
.chip.muted     { background: transparent; color: var(--ink-faint); border-color: var(--rule); }
.chip.locked    { outline: 1.5px solid var(--ink); outline-offset: 1px; }

.week-hours {
  font: 500 .85rem/1 "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  min-width: 3rem;
  text-align: right;
}
.week-hours.is-good { color: var(--cme); }

.week-controls { display: flex; gap: .25rem; padding-right: .55rem; }

button.ghost.tiny {
  padding: .25rem .45rem;
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1;
  min-width: 1.85rem;
}
button.ghost.tiny:disabled {
  opacity: .28;
  cursor: default;
  background: none;
  color: var(--ink-soft);
  border-color: var(--rule);
}

@media (max-width: 620px) {
  .week-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "label hours" "detail detail" "controls controls";
    gap: .4rem;
    padding: .7rem .55rem;
  }
  .week-label    { grid-area: label; padding-left: 0; }
  .week-hours    { grid-area: hours; }
  .week-detail   { grid-area: detail; }
  .week-controls { grid-area: controls; padding-right: 0; }
  button.ghost.tiny { min-width: 2.6rem; padding: .4rem .5rem; }
}

/* ------------------------------------------------------------ footer ----- */

footer {
  border-top: 1px solid var(--rule-strong);
  padding: 1.6rem 0 3rem;
}
footer p {
  margin: 0;
  max-width: 62ch;
  font-size: .82rem;
  line-height: 1.6;
  color: var(--ink-faint);
}

@media (max-width: 560px) {
  .stat { border-right: 0; border-bottom: 1px solid var(--rule); padding: .6rem 0; }
  .stat:last-child { border-bottom: 0; }
}
