:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --ink: #24201b;
  --muted: #6e665d;
  --line: #d7dedc;
  --line-strong: #aebbb7;
  --accent: #1f6f5b;
  --accent-dark: #174d40;
  --blue: #276c9d;
  --amber: #b45f06;
  --red: #b42318;
  --green-soft: #dcefe8;
  --blue-soft: #dfeaf5;
  --amber-soft: #fff0d3;
  --red-soft: #fbe0dd;
  --shadow: 0 18px 45px rgba(39, 32, 24, 0.12);
  --slot-width: 72px;
  --row-height: 54px;
  --label-width: 164px;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.link-button {
  text-decoration: none;
}

.manual-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin-top: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
  width: 100%;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 111, 91, 0.1), transparent 38%),
    linear-gradient(315deg, rgba(180, 95, 6, 0.1), transparent 32%),
    var(--bg);
}

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

.login-panel h1,
.topbar h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.login-copy {
  color: var(--muted);
  margin: 10px 0 22px;
}

.pin-form {
  display: grid;
  gap: 10px;
}

.pin-form input,
.form-grid input,
.form-grid select,
.memo-label textarea,
.toolbar input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 11px 12px;
  min-height: 44px;
}

.pin-form button,
.primary-button {
  border: 1px solid var(--accent-dark);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  min-height: 44px;
  padding: 0 16px;
}

.ghost-button,
.icon-button,
.danger-button {
  border-radius: 6px;
  min-height: 40px;
  padding: 0 12px;
  font-weight: 700;
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--ink);
}

.danger-button {
  border: 1px solid #c73a30;
  background: var(--red-soft);
  color: var(--red);
}

.icon-button {
  width: 42px;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.form-error,
.conflict-warning {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.pin-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.pin-hint span,
.staff-pill,
.status-pill {
  border: 1px solid var(--line);
  background: #eef3f0;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-actions,
.toolbar,
.date-controls,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  padding: 16px;
}

.board-section,
.side-panel {
  min-width: 0;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.date-awareness {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.date-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border: 1px solid #b5cec6;
  border-radius: var(--radius);
  background: #eef7f3;
  padding: 11px 13px;
}

.date-alert.warning {
  border-color: #e0a64f;
  background: var(--amber-soft);
}

.date-alert.danger {
  border-color: #d1847d;
  background: var(--red-soft);
}

.date-alert strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
}

.date-alert span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.date-alert-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.date-alert-tags span {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  padding: 6px 9px;
  white-space: nowrap;
}

.date-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(84px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.date-chip {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px;
  display: grid;
  align-content: space-between;
  gap: 3px;
  text-align: left;
}

.date-chip.selected {
  border-color: var(--accent-dark);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.date-chip.attention {
  background: #fffaf0;
  border-color: #e0a64f;
}

.date-chip.holiday,
.date-chip.closed {
  background: #fff3f1;
  border-color: #d1847d;
}

.date-chip-weekday {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.date-chip strong {
  font-size: 18px;
  line-height: 1;
}

.date-chip-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 18px;
}

.date-badge {
  border-radius: 999px;
  background: #eef3f0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  padding: 4px 5px;
}

.date-badge.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.date-badge.danger {
  background: var(--red-soft);
  color: var(--red);
}

.phone-intake {
  background: var(--surface);
  border: 1px solid #b5cec6;
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(31, 111, 91, 0.09);
  margin-bottom: 12px;
  padding: 14px;
}

.phone-intake-header,
.intake-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.phone-intake-header {
  margin-bottom: 12px;
}

.phone-intake-header h2 {
  margin: 0;
  font-size: 20px;
}

.intake-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 0.8fr 1fr;
  gap: 10px;
}

.intake-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.intake-grid input,
.intake-grid select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 10px 12px;
  font-weight: 700;
}

.intake-result {
  align-items: stretch;
  margin-top: 12px;
}

.intake-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.intake-decision {
  flex: 1;
  border-radius: 6px;
  border: 1px solid #a8cfc3;
  background: #e6f3ee;
  padding: 12px;
}

.intake-decision.warning {
  border-color: #e0a64f;
  background: var(--amber-soft);
}

.intake-decision.danger {
  border-color: #d1847d;
  background: var(--red-soft);
}

.intake-decision strong {
  display: block;
  font-size: 21px;
  line-height: 1.25;
}

.intake-decision span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.intake-suggestions {
  width: min(340px, 42%);
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
}

.suggestion-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
}

.day-notice {
  display: flex;
  align-items: center;
  min-height: 36px;
  color: var(--muted);
  margin-bottom: 10px;
}

.day-notice strong {
  color: var(--ink);
}

.availability-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.availability-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-align: left;
}

.availability-card strong {
  display: block;
  font-size: 20px;
  margin-top: 4px;
}

.availability-card span {
  color: var(--muted);
  font-size: 13px;
}

.timeline-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 8px 20px rgba(39, 32, 24, 0.06);
  max-height: calc(100vh - 255px);
}

.timeline {
  position: relative;
  min-width: calc(var(--label-width) + var(--slot-width) * 14);
}

.time-header,
.table-row {
  display: grid;
  grid-template-columns: var(--label-width) repeat(14, var(--slot-width));
}

.time-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line-strong);
}

.corner-cell,
.time-cell,
.table-label,
.slot {
  min-height: var(--row-height);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.corner-cell,
.table-label {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--surface);
}

.corner-cell {
  z-index: 25;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-weight: 800;
}

.time-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.table-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 0 12px;
}

.table-label strong {
  font-size: 14px;
}

.table-label span {
  color: var(--muted);
  font-size: 12px;
}

.table-row {
  position: relative;
}

.table-row.area-start .table-label {
  border-top: 3px solid var(--accent);
}

.now-marker {
  position: absolute;
  top: 0;
  z-index: 24;
  width: 0;
  border-left: 3px solid var(--red);
  pointer-events: none;
}

.now-marker span {
  position: sticky;
  top: 8px;
  display: inline-block;
  transform: translateX(5px);
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 6px;
}

.slot {
  background:
    linear-gradient(90deg, rgba(221, 213, 202, 0.5) 1px, transparent 1px),
    var(--surface-strong);
}

.slot:hover {
  background: #eef7f3;
}

.reservation-block {
  position: absolute;
  top: 8px;
  height: calc(var(--row-height) - 16px);
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 5px 8px;
  overflow: hidden;
  display: grid;
  align-content: center;
  z-index: 12;
  text-align: left;
  color: #17211d;
  box-shadow: 0 6px 14px rgba(20, 20, 20, 0.14);
}

.reservation-block.confirmed {
  background: var(--green-soft);
  border-color: #8fc5b4;
}

.reservation-block.tentative {
  background: var(--amber-soft);
  border-color: #e0a64f;
  border-width: 2px;
  box-shadow: 0 0 0 2px rgba(180, 95, 6, 0.12), 0 6px 14px rgba(20, 20, 20, 0.14);
}

.reservation-block.cancelled {
  background: var(--red-soft);
  border-color: #e2a39d;
  text-decoration: line-through;
  opacity: 0.72;
}

.reservation-block.ended {
  opacity: 0.48;
}

.reservation-block .name {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.reservation-block .meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #4d4a45;
  font-size: 12px;
}

.side-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  height: calc(100vh - 105px);
  overflow: auto;
  position: sticky;
  top: 88px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.reservation-list {
  display: grid;
  gap: 10px;
}

.tentative-alert {
  margin-bottom: 10px;
}

.tentative-alert-card {
  width: 100%;
  border: 1px solid #e0a64f;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: var(--amber);
  padding: 10px 12px;
  font-weight: 800;
  text-align: left;
}

.tentative-alert-card span {
  display: block;
  color: #6e4a14;
  font-size: 13px;
  font-weight: 600;
  margin-top: 3px;
}

.reservation-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 12px;
}

.reservation-item.tentative {
  border-color: #e0a64f;
  background: #fff9eb;
}

.reservation-item:hover {
  border-color: var(--accent);
}

.reservation-item header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.reservation-item h3 {
  margin: 0;
  font-size: 16px;
}

.reservation-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill.confirmed {
  background: var(--green-soft);
  color: var(--accent-dark);
}

.status-pill.tentative {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.cancelled {
  background: var(--red-soft);
  color: var(--red);
}

.reservation-dialog {
  width: min(820px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

.reservation-dialog::backdrop {
  background: rgba(24, 20, 16, 0.45);
}

.reservation-dialog form {
  padding: 20px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.dialog-header h2,
.seat-picker h3 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label,
.memo-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.memo-label {
  margin: 12px 0;
}

.seat-picker {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #f5f8f7;
}

.seat-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.seat-picker-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.seat-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.seat-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 700;
}

.seat-option small {
  display: block;
  color: var(--muted);
  font-weight: 500;
}

.seat-option.unavailable {
  opacity: 0.5;
}

.audit-line {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.dialog-action-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

@media (max-width: 980px) {
  :root {
    --slot-width: 68px;
    --label-width: 146px;
  }

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

  .side-panel {
    position: static;
    height: auto;
  }

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

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

  .intake-result {
    flex-direction: column;
  }

  .intake-suggestions {
    width: 100%;
  }
}

@media (max-width: 640px) {
  :root {
    --slot-width: 62px;
    --row-height: 58px;
    --label-width: 132px;
  }

  .topbar,
  .toolbar,
  .date-alert,
  .dialog-actions,
  .seat-picker-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .date-controls,
  .toolbar-actions,
  .dialog-action-right {
    width: 100%;
  }

  .date-controls input,
  .toolbar-actions button,
  .intake-actions button,
  .dialog-action-right button,
  .danger-button {
    flex: 1;
  }

  .availability-grid,
  .form-grid,
  .seat-options,
  .intake-grid {
    grid-template-columns: 1fr;
  }

  .phone-intake-header {
    align-items: stretch;
    flex-direction: column;
  }

  .date-strip {
    grid-auto-columns: minmax(82px, 30vw);
  }

  .date-alert-tags {
    justify-content: flex-start;
  }

  .intake-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .layout {
    padding: 10px;
  }

  .reservation-dialog form {
    padding: 14px;
  }
}
