:root {
  color-scheme: light;
  --paper: #f7f3eb;
  --surface: #fffaf2;
  --ink: #172323;
  --muted: #667271;
  --line: #ded7ca;
  --brand: #166066;
  --coral: #df5f50;
  --gold: #d9a441;
  --green: #4f8060;
  --shadow: 0 18px 45px rgba(20, 36, 34, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
}

button:hover,
.day:hover {
  filter: brightness(0.97);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 28px;
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h1 {
  font-size: clamp(28px, 4vw, 42px);
}

.stack {
  display: grid;
  gap: 16px;
}

.eyebrow {
  color: var(--coral);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.error {
  color: #b42318;
  min-height: 20px;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.top-actions {
  grid-column: 2;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.month-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-actions input {
  width: 152px;
}

.worker-picker {
  width: 180px;
  font-weight: 800;
  text-align: center;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.ghost-button {
  background: white;
  color: var(--brand);
  border: 1px solid var(--line);
}

.toolbar {
  display: block;
  margin-bottom: 18px;
}

.payroll-grid {
  display: grid;
  gap: 12px;
}

.payroll-grid {
  grid-template-columns: repeat(2, minmax(210px, 1fr));
}

.payroll-card {
  display: grid;
  gap: 10px;
  min-height: 126px;
  padding: 16px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 6px solid var(--brand);
  border-radius: 8px;
  text-align: left;
}

.payroll-card h3 {
  font-size: 28px;
}

.payroll-card small {
  color: var(--muted);
  line-height: 1.55;
}

.calendar-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.weekday-row,
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  background: #e8dfd0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.weekday-row span {
  padding: 10px 0;
}

.day {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 136px;
  padding: 10px;
  border-radius: 0;
  border-right: 1px solid var(--line);
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.day:nth-child(7n) {
  border-right: 0;
}

.day.muted {
  background: #f0eadf;
  color: #97a09f;
}

.day.today .day-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
}

.day-number-row {
  display: flex;
}

.day-number {
  font-weight: 800;
}

.day-total {
  min-height: 18px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.shift-list {
  display: grid;
  gap: 6px;
}

.shift-pill {
  display: block;
  width: 100%;
  border-left: 4px solid var(--shift-color, var(--green));
  border-radius: 6px;
  background: color-mix(in srgb, var(--shift-color, var(--green)) 14%, white);
  color: var(--ink);
  padding: 6px 7px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.shift-pill b {
  display: block;
}

dialog {
  width: min(640px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 35, 35, 0.38);
}

.dialog-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.dialog-card header,
.dialog-actions,
.two-col,
.section-head,
.segments-list,
.quick-list,
.template-form {
  display: grid;
  gap: 12px;
}

.dialog-card header {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

.dialog-actions {
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
}

.section-head {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.section-head h3,
.template-editor summary {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.quick-panel,
.segments-panel,
.template-editor {
  display: grid;
  gap: 12px;
}

.quick-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-chip {
  display: grid;
  grid-template-columns: 1fr 34px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--shift-color, var(--brand));
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.quick-chip button {
  min-height: 42px;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.quick-chip button:last-child {
  padding: 0;
  text-align: center;
  color: #b42318;
}

.quick-chip small {
  display: block;
  color: var(--muted);
}

.template-form {
  grid-template-columns: 1fr;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.segment-row {
  display: grid;
  grid-template-columns: 1fr 1fr 82px 42px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.segment-row input[type="color"],
.template-form input[type="color"] {
  padding: 4px;
}

.empty-note {
  color: var(--muted);
  font-weight: 700;
}

.danger {
  background: #b42318;
}

.dialog-note {
  color: var(--muted);
  font-weight: 700;
}

.dialog-actions.simple {
  grid-template-columns: 1fr auto;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    grid-column: auto;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .month-actions input {
    width: 100%;
  }

  .payroll-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day {
    min-height: 112px;
    padding: 8px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .login-panel {
    padding: 22px;
  }

  .calendar-wrap {
    overflow: hidden;
  }

  .weekday-row,
  .calendar {
    min-width: 0;
  }

  .top-actions {
    gap: 10px;
  }

  .worker-picker {
    width: 100%;
  }

  .month-actions {
    display: grid;
    grid-template-columns: 42px 1fr 42px;
  }

  .payroll-grid {
    grid-template-columns: 1fr;
  }

  .weekday-row {
    font-size: 12px;
  }

  .weekday-row span {
    padding: 8px 0;
  }

  .day {
    min-height: 82px;
    gap: 4px;
    padding: 5px;
  }

  .day-number {
    font-size: 13px;
  }

  .day.today .day-number {
    width: 23px;
    height: 23px;
  }

  .day-total {
    min-height: 14px;
    font-size: 10px;
  }

  .shift-list {
    gap: 4px;
  }

  .shift-pill {
    border-left-width: 3px;
    padding: 4px;
    font-size: 10px;
  }

  .quick-list,
  .segment-row {
    grid-template-columns: 1fr;
  }

  .segment-row .icon-button {
    width: 100%;
  }

  .dialog-actions {
    grid-template-columns: 1fr 1fr;
  }

  .dialog-actions span {
    display: none;
  }
}
