:root {
  --ink: #332f29;
  --ink-soft: #6d655b;
  --brand-orange: #ee7937;
  --accent: #ad5700;
  --accent-dark: #813d00;
  --accent-pale: #fff0c9;
  --surface: #ffffff;
  --surface-soft: #faf8f4;
  --surface-muted: #f4f0e8;
  --canvas: #f6f4ef;
  --line: #e2ddd2;
  --control-border: #81796f;
  --control-border-hover: #5f5951;
  --disabled-ink: #6d655b;
  --disabled-surface: #e8e3da;
  --green: #20775c;
  --green-pale: #e9f6f1;
  --amber: #976208;
  --amber-pale: #fff5d9;
  --red: #ad3543;
  --red-pale: #fff0f1;
  --shadow: 0 18px 50px rgba(51, 47, 41, .1);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--canvas); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
.visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 2px;
}

.login-page {
  background:
    radial-gradient(circle at 15% 10%, rgba(238, 121, 55, .2), transparent 34rem),
    linear-gradient(145deg, #f8f1df, #fbfaf7 55%, #f1eadb);
}
.login-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(100%, 440px);
  padding: clamp(28px, 6vw, 48px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}
.brand-mark {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px;
  color: white; background: linear-gradient(145deg, var(--accent), #e69a00);
  font-weight: 800; font-size: 24px; box-shadow: 0 8px 20px rgba(173, 87, 0, .24);
}
.brand-mark-error { background: var(--red); }
.eyebrow { margin: 22px 0 6px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(26px, 5vw, 36px); letter-spacing: -.035em; }
.intro { color: var(--ink-soft); line-height: 1.6; }
.login-form { display: grid; gap: 18px; margin-top: 28px; }
.login-form label, .field { display: grid; gap: 7px; min-width: 0; color: var(--ink-soft); font-size: 13px; font-weight: 700; }
input, select {
  width: 100%; min-width: 0; border: 1px solid var(--control-border); border-radius: 10px;
  padding: 10px 12px; color: var(--ink); background: var(--surface);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input, select { min-height: 43px; }
input:hover, select:hover { border-color: var(--control-border-hover); }
input:focus, select:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(173, 87, 0, .14); }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 10px 18px; border: 0; border-radius: 11px; font-weight: 700;
  text-decoration: none; transition: transform .15s, background .15s, box-shadow .15s;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--accent); box-shadow: 0 7px 18px rgba(173, 87, 0, .2); }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { color: var(--accent); background: var(--accent-pale); }
.button-quiet { color: var(--ink); background: #ece8df; }
.button-wide { width: 100%; }
.button-loading { display: none; }
.is-loading .button-label { display: none; }
.is-loading .button-loading { display: inline; }
.is-loading button[type="submit"] { pointer-events: none; opacity: .75; }

.alert { padding: 13px 16px; border: 1px solid; border-radius: 12px; line-height: 1.45; }
.alert-error { color: #842532; border-color: #efc3c8; background: var(--red-pale); }
.alert-warning { color: #76500e; border-color: #efd89d; background: var(--amber-pale); }
.alert-success { color: #175e48; border-color: #b9dfd1; background: var(--green-pale); }
.login-card .alert { margin: 20px 0 0; }
.error-card { text-align: center; }
.error-card .brand-mark { margin-inline: auto; }

.app-header { border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .94); }
.app-header-inner, .app-main { width: min(1500px, calc(100% - 40px)); margin-inline: auto; }
.app-header-inner {
  display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center; min-height: 66px; gap: 16px;
}
.wordmark {
  position: relative; display: grid; grid-template-columns: 42px auto;
  grid-template-rows: repeat(3, 13px); align-content: center; align-items: baseline;
  column-gap: 3px; width: max-content; height: 42px; margin: 0;
  color: var(--ink-soft); font-size: 12px; font-weight: 600;
  line-height: 13px; letter-spacing: .01em;
}
.wordmark-box {
  position: absolute; inset: 0 auto 0 0; z-index: 0;
  width: 42px; height: 42px; background: #24211d;
}
.wordmark-letter {
  z-index: 1; grid-column: 1; justify-self: end; align-self: baseline;
  width: 12px; margin-right: 2px; color: var(--brand-orange);
  font-size: 13px; font-weight: 900; line-height: 13px; text-align: left;
}
.wordmark-copy {
  grid-column: 2; align-self: baseline; line-height: 13px;
}
.wordmark-row-1 { grid-row: 1; }
.wordmark-row-2 { grid-row: 2; }
.wordmark-row-3 { grid-row: 3; }
.logout-form { justify-self: end; }
.app-page .button { min-height: 36px; padding: 7px 13px; border-radius: 8px; }
.app-page input, .app-page select {
  min-height: 36px; padding: 7px 9px; border-radius: 7px;
}
.app-page .button-primary { box-shadow: 0 3px 10px rgba(173, 87, 0, .16); }
.app-page .button:disabled {
  cursor: default; color: var(--disabled-ink); background: var(--disabled-surface);
  box-shadow: none; transform: none;
}
.app-main { padding-block: 12px 42px; }

.week-navigation {
  display: grid; grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: stretch; gap: 5px;
}
.app-header .week-navigation { justify-self: center; }
.week-current {
  display: grid; align-content: center; gap: 1px; min-width: 190px;
  padding: 5px 13px; border-radius: 7px; color: var(--ink);
  background: white; box-shadow: inset 0 2px var(--brand-orange), 0 2px 7px rgba(51, 47, 41, .08);
  text-align: center;
}
.week-current > span { font-size: 13px; font-weight: 800; }
.week-label-short { display: none; }
.week-current small { font-size: 11px; }
.week-nav-link { align-self: stretch; min-width: 88px; text-decoration: none; }
.week-nav-link.is-disabled { opacity: .45; }
.week-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.week-table {
  overflow: hidden; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); box-shadow: 0 3px 14px rgba(51, 47, 41, .045);
}
.day-row {
  display: grid; grid-template-columns: 78px 1fr; min-height: 0;
  border-bottom: 1px solid var(--line); transition: background .15s;
}
.day-row:last-child { border-bottom: 0; }
.day-row.is-dirty { background: #fffaf0; box-shadow: inset 3px 0 var(--brand-orange); }
.day-heading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 10px 7px; border-right: 1px solid var(--line); background: var(--surface-soft);
}
.day-heading strong { font-size: 24px; line-height: 1; letter-spacing: -.035em; }
.day-heading > span { margin-top: 3px; color: var(--ink-soft); font-size: 11px; }
.state-badge {
  min-height: 24px; margin-top: 6px; padding: 3px 7px; border-radius: 99px;
  font-size: 11px; font-style: normal; font-weight: 800; white-space: nowrap;
}
.badge-changed { color: var(--accent-dark); background: var(--accent-pale); }
.badge-irregular { color: var(--amber); background: var(--amber-pale); }
.status-reset { border: 0; cursor: pointer; }
.status-reset:hover { color: var(--accent-dark); background: #ffe4a3; }
.day-content { min-width: 0; padding: 9px 12px; }
.day-editor { display: grid; gap: 8px; }
.field-row {
  display: grid; grid-template-columns:
    165px 76px auto 76px 140px 170px minmax(260px, 1fr);
  align-items: center; gap: 7px;
}
.field { gap: 4px; }
.field-kind { grid-column: 1; }
.kind-select { color: var(--ink); }
.kind-select.is-empty-selection,
.kind-select option[value=""] { color: var(--ink-soft); }
.kind-select option:not([value=""]) { color: var(--ink); }
.field-time-start { grid-column: 2; }
.time-separator {
  grid-column: 3; color: var(--ink-soft); font-size: 12px; text-align: center;
}
.field-time-end { grid-column: 4; }
.field-break { grid-column: 5; }
.field-project { grid-column: 6; }
.field-activity { grid-column: 7; }
.work-fields { display: contents; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 70px; }
.input-suffix span {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); font-size: 11px; font-weight: 600; pointer-events: none;
}
.field-inline {
  display: flex; align-items: center; gap: 7px; min-height: 36px;
  overflow: hidden; padding-left: 9px; border: 1px solid var(--control-border);
  border-radius: 7px; background: var(--surface);
}
.field-inline:hover { border-color: var(--control-border-hover); }
.field-inline:focus-within {
  border-color: var(--accent-dark); box-shadow: 0 0 0 3px var(--accent-dark);
}
.field-inline > span:not(.visually-hidden) {
  flex: 0 0 auto; color: var(--ink-soft); font-size: 11px; font-weight: 700;
}
.field-inline input {
  flex: 1 1 0; width: auto; min-width: 0; min-height: 34px;
  padding: 6px 9px 6px 0; border: 0; border-radius: 0;
  background: transparent; box-shadow: none;
}
.field-inline input:hover, .field-inline input:focus { border: 0; box-shadow: none; }
.field-inline input:focus-visible { outline: 0; }
.field-inline .inline-picker {
  flex: 0 0 32px; width: 32px; min-width: 32px; min-height: 34px;
  padding: 0 3px; border: 0; border-left: 1px solid var(--line);
  border-radius: 0; color: var(--ink); background: transparent;
}
.field-inline .inline-picker:disabled { cursor: not-allowed; opacity: .45; }
.field-inline .inline-picker option { color: var(--ink); }
.reason-row { display: flex !important; align-items: center; gap: 8px; }
.field-reason { flex: 1; }
.raw-entries { display: grid; gap: 7px; }
.raw-entries[hidden], .day-editor[hidden] { display: none; }
.raw-entry { padding: 7px 9px; border-radius: 7px; background: var(--surface-muted); }
.raw-entry > div { display: flex; flex-wrap: wrap; gap: 5px 12px; font-size: 12px; }
.raw-entry p { margin: 5px 0 0; color: var(--ink-soft); font-size: 12px; }
.irregular-replacement {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 2px;
}
.irregular-replacement p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.irregular-replacement .button { min-height: 38px; padding: 7px 13px; }
.save-bar {
  position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: rgba(255, 255, 255, .96); box-shadow: 0 -4px 16px rgba(51, 47, 41, .07);
}
.save-bar p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.save-bar-copy { display: grid; gap: 4px; }
.save-message { font-weight: 700; }
.save-message-error { color: var(--red) !important; }
.save-message-success { color: var(--green) !important; }
.save-message-warning { color: var(--amber) !important; }
.save-bar-read-only { gap: 12px; }
.unsaved-dialog {
  width: min(460px, calc(100% - 32px)); padding: 24px;
  border: 1px solid var(--line); border-radius: 14px;
  color: var(--ink); background: var(--surface); box-shadow: var(--shadow);
}
.unsaved-dialog::backdrop { background: rgba(31, 28, 24, .42); }
.unsaved-dialog h2 { margin: 0; font-size: 22px; }
.unsaved-dialog p { margin: 10px 0 22px; color: var(--ink-soft); line-height: 1.5; }
.unsaved-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.is-scheduled .field-row > .work-fields,
.is-unset .field-row > .work-fields {
  /* Keep every day row the same height while hiding inapplicable controls. */
  display: contents !important;
  visibility: hidden;
  pointer-events: none;
}
.is-scheduled .reason-row.work-fields,
.is-unset .reason-row.work-fields {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 1100px) {
  .field-row { grid-template-columns: repeat(2, minmax(80px, 1fr)) 100px auto 100px 125px; }
  .field-kind { grid-column: 1 / 3; }
  .field-time-start { grid-column: 3; }
  .time-separator { grid-column: 4; }
  .field-time-end { grid-column: 5; }
  .field-break { grid-column: 6; }
  .field-project { grid-column: 1 / 4; grid-row: 2; }
  .field-activity { grid-column: 4 / 7; grid-row: 2; }
}

@media (max-width: 900px) {
  .app-header-inner {
    grid-template-columns: 1fr auto; min-height: 0; gap: 7px 12px; padding-block: 8px;
  }
  .wordmark { grid-column: 1; grid-row: 1; }
  .logout-form { grid-column: 2; grid-row: 1; }
  .app-header .week-navigation {
    grid-column: 1 / -1; grid-row: 2; display: grid;
    width: 100%; margin-top: 2px;
  }
}

@media (max-width: 720px) {
  .app-header-inner, .app-main { width: min(100% - 24px, 1500px); }
  .app-main { padding-block: 10px 34px; }
  .week-navigation {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .week-current { min-width: 0; padding-inline: 8px; }
  .week-nav-link { min-width: 0; padding-inline: 10px; }
  .week-table { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .day-row {
    grid-template-columns: 1fr; margin-bottom: 8px; border: 1px solid var(--line);
    border-radius: 10px; overflow: hidden; background: white;
    box-shadow: 0 2px 8px rgba(51, 47, 41, .04);
  }
  .day-heading {
    flex-direction: row; justify-content: flex-start; gap: 7px; padding: 8px 11px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .day-heading strong { font-size: 21px; }
  .day-heading > span, .state-badge { margin: 0; }
  .state-badge { margin-left: auto; }
  .day-content { padding: 9px; }
  .irregular-replacement { align-items: stretch; flex-direction: column; }
  .app-page input, .app-page select { min-height: 40px; }
  .app-page .button { min-height: 44px; }
  .field-row { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 7px; }
  .field-kind { grid-column: 1 / -1; }
  .field-time-start { grid-column: 1; grid-row: 2; }
  .time-separator { grid-column: 2; grid-row: 2; }
  .field-time-end { grid-column: 3; grid-row: 2; }
  .field-break { grid-column: 1 / -1; grid-row: 3; }
  .field-project { grid-column: 1; grid-row: 4; }
  .field-activity { grid-column: 3; grid-row: 4; }
  .field-inline { min-height: 40px; }
  .field-inline input { min-height: 38px; }
  .field-inline .inline-picker { min-height: 38px; }
  .reason-row { align-items: stretch; flex-direction: column; }
  .save-bar { padding: 7px 8px; }
}

@media (max-width: 500px) {
  .week-label-long { display: none; }
  .week-label-short { display: block; }
}

@media (max-width: 430px) {
  .login-shell { padding: 12px; }
  .login-card { padding: 28px 22px; border-radius: 20px; }
  .app-header-inner { width: calc(100% - 24px); }
  .app-header .button { padding-inline: 12px; }
  .field-row { gap: 7px; }
  .field-project { grid-column: 1 / -1; grid-row: 4; }
  .field-activity { grid-column: 1 / -1; grid-row: 5; }
  .week-current small { font-size: 11px; }
  .save-bar { align-items: stretch; flex-direction: column; }
  .save-bar .button { width: 100%; }
  .unsaved-dialog-actions { flex-direction: column; }
  .unsaved-dialog-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
  .button:hover { transform: none; }
}
