:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --panel: #ffffff;
  --panel-soft: #edf4e7;
  --ink: #1d271c;
  --muted: #667064;
  --line: #d8e0d2;
  --green: #4f8f2f;
  --green-dark: #356f22;
  --amber: #c27b19;
  --red: #b44b39;
  --blue: #356a86;
  --shadow: 0 18px 45px rgba(36, 52, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px 1fr;
}

.sidebar {
  background: #20351d;
  color: #f5faef;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar.signed-out .nav-list,
.sidebar.signed-out .store-filter,
.sidebar.signed-out #logoutButton {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #78ad38;
  display: grid;
  place-items: center;
  color: #12210f;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #c8d9bd;
  font-size: 0.85rem;
  margin-top: 2px;
}

.nav-list,
.store-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: inherit;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
}

.nav-item span {
  width: 32px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.nav-item.active,
.store-main.active {
  background: rgba(120, 173, 56, 0.18);
  border-color: rgba(154, 213, 91, 0.6);
}

.account-panel {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 18px;
  display: grid;
  gap: 7px;
}

.account-panel strong,
.account-panel span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-panel span {
  color: #c8d9bd;
  font-size: 0.82rem;
  font-weight: 700;
}

.sidebar-button {
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #f5faef;
}

.section-title {
  color: #c8d9bd;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.section-title-spaced {
  margin-top: 2px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  margin-bottom: 8px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.rule-type-control {
  grid-template-columns: repeat(2, 1fr);
}

.rule-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-bubble {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  color: #f5faef;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: none;
  cursor: help;
}

.info-popover {
  position: absolute;
  z-index: 10;
  left: 22px;
  top: -8px;
  width: 244px;
  padding: 10px;
  border-radius: 8px;
  background: #f8fbf4;
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.info-bubble:hover .info-popover,
.info-bubble:focus .info-popover {
  opacity: 1;
  transform: translateY(0);
}

.segmented-control button {
  min-height: 27px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c8d9bd;
  font-size: 0.7rem;
  font-weight: 800;
}

.segmented-control button.active {
  background: #78ad38;
  color: #12210f;
}

.sidebar-switch {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #f5faef;
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 12px;
}

.sidebar-switch input,
.booked-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #78ad38;
}

.store-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 6px;
}

.store-row:has(.store-rule-button) {
  grid-template-columns: 1fr 38px 38px;
}

.store-main,
.booked-toggle,
.store-rule-button {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: inherit;
  border-radius: 8px;
}

.store-main {
  justify-content: space-between;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 12px;
  text-align: left;
  font-size: 0.92rem;
}

.store-main small {
  color: #c8d9bd;
}

.store-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.store-name,
.store-info {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-name {
  color: #f5faef;
}

.store-info {
  color: #c8d9bd;
  font-size: 0.68rem;
  font-weight: 650;
}

.booked-toggle {
  display: grid;
  place-items: center;
  cursor: pointer;
}

.store-rule-button {
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 900;
}

.store-rule-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.booked-toggle.off {
  opacity: 0.45;
}

.calendar-source-main {
  border-left: 4px solid var(--calendar-color, #7c5cbb);
}

.calendar-source-main .store-info {
  color: #d7cfee;
}

.calendar-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--calendar-color, #7c5cbb);
  flex: 0 0 auto;
}

.main {
  position: relative;
  padding: 28px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--green-dark);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3vw, 3rem);
}

h2 {
  font-size: 1.15rem;
}

.actions,
.settings-actions,
.agenda-header,
.calendar-header,
.legend {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
}

.primary-button {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 700;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 1.3rem;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.app-content[hidden] {
  display: none;
}

.auth-view[hidden] {
  display: none !important;
}

.auth-view {
  display: none;
  min-height: calc(100vh - 56px);
  place-items: center;
}

.auth-view.active-view {
  display: grid;
}

.auth-panel {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.auth-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 18px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f4;
}

.auth-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tabs button.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(36, 52, 31, 0.08);
}

.auth-form label {
  margin: 0;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.auth-inline-message {
  display: none;
  border: 1px solid rgba(180, 75, 57, 0.28);
  border-radius: 8px;
  background: #fff5f2;
  color: var(--red);
  padding: 10px 12px;
  font-weight: 750;
  line-height: 1.35;
}

.auth-inline-message.show {
  display: block;
}

.auth-form .primary-button,
.auth-form .ghost-button {
  width: 100%;
}

.auth-form .primary-button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.auth-proof-list {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  list-style: none;
}

.auth-proof-list li {
  position: relative;
  padding-left: 22px;
}

.auth-proof-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
}

.calendar-panel,
.agenda-panel,
.settings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.calendar-panel {
  padding: 18px;
}

.calendar-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.legend {
  color: var(--muted);
  font-size: 0.88rem;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 5px;
}

.legend-dot.available {
  background: var(--green);
}

.legend-dot.booked {
  background: var(--blue);
}

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

.weekday-row {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0 2px 8px;
}

.calendar-grid {
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.day-cell {
  min-height: 132px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px;
  background: #fff;
}

.day-cell.outside {
  background: #f4f5f2;
  color: #9ba297;
}

.day-number {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  margin-bottom: 8px;
}

.today-ring {
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
}

.slot-pill {
  position: relative;
  display: block;
  width: 100%;
  border: 0;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: var(--panel-soft);
  margin: 6px 0 0;
  padding: 7px 28px 7px 7px;
  text-align: left;
  color: var(--ink);
}

.slot-pill.booked {
  border-color: var(--blue);
  background: #e8f3f7;
  padding-right: 7px;
}

.slot-pill.calendar-event {
  border-color: var(--calendar-color, #7c5cbb);
  background: var(--calendar-bg, #f0ebfa);
  padding-right: 7px;
}

.slot-pill.short-notice {
  border-color: var(--amber);
  background: #fff4df;
}

.slot-pill strong {
  display: block;
  font-size: 0.84rem;
  line-height: 1.2;
}

.slot-time {
  font-weight: 800;
}

.slot-count {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(79, 143, 47, 0.14);
  color: var(--green-dark);
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 1;
}

.short-notice-badge {
  display: inline-block;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(194, 123, 25, 0.16);
  color: #7a4a08;
  padding: 2px 6px;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 900;
  line-height: 1.1;
}

.slot-pill span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-pill span {
  color: var(--muted);
  font-size: 0.78rem;
}

.slot-pill.limited-dim {
  opacity: 0.42;
}

.more-slots {
  border: 0;
  background: transparent;
  color: var(--green-dark);
  cursor: pointer;
  font-size: 0.8rem;
  margin-top: 6px;
  padding: 0;
  text-align: left;
}

.more-slots:hover {
  text-decoration: underline;
}

.agenda-panel {
  margin-top: 16px;
  padding: 18px;
}

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

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

.agenda-item {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.agenda-time {
  color: var(--green-dark);
  font-weight: 800;
}

.agenda-item strong,
.agenda-item span {
  display: block;
}

.agenda-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.free-count {
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--green-dark);
  padding: 6px 10px;
  font-weight: 800;
  white-space: nowrap;
}

.free-count.booked {
  background: #e8f3f7;
  color: var(--blue);
}

.free-count.short-notice-count {
  background: #fff4df;
  color: #7a4a08;
}

.settings-panel {
  max-width: 780px;
  padding: 22px;
}

.settings-view .settings-panel + .settings-panel,
.settings-panel-spaced {
  margin-top: 16px;
}

.settings-panel p {
  color: var(--muted);
  line-height: 1.5;
}

label {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.status-banner {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(460px, calc(100vw - 48px));
  border-radius: 8px;
  background: #20351d;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.status-banner.show {
  opacity: 1;
  transform: translateY(0);
}

.slot-dialog {
  width: min(520px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
  color: var(--ink);
}

.store-rule-dialog {
  width: min(760px, calc(100vw - 36px));
}

.slot-dialog::backdrop {
  background: rgba(18, 33, 15, 0.35);
}

.slot-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.slot-dialog-header h2 {
  margin-bottom: 0;
}

.slot-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 18px;
}

.slot-detail-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.slot-detail-grid dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.slot-detail-grid dd {
  margin: 0;
  line-height: 1.4;
}

.day-dialog-list {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.day-dialog-list .slot-pill {
  margin: 0;
}

.store-rule-body {
  padding: 18px;
}

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

.rule-source {
  display: inline-block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.checkbox-label {
  align-content: end;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  min-height: 69px;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fbfcfa;
}

.admin-summary-grid {
  margin-bottom: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.75fr);
  gap: 16px;
}

.admin-table-panel,
.admin-events-panel {
  max-width: none;
}

.admin-user-list,
.admin-event-list {
  display: grid;
  gap: 10px;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 150px;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.admin-user-row strong,
.admin-user-row span,
.admin-user-row small {
  display: block;
}

.admin-user-row span,
.admin-user-row small,
.admin-event span {
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-user-row label {
  margin: 0;
}

.admin-event {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.admin-event strong,
.admin-event span {
  display: block;
}

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

  .sidebar {
    min-height: auto;
  }

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

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

  .actions .primary-button {
    grid-column: 1 / -1;
  }

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

  .weekday-row,
  .calendar-grid {
    min-width: 760px;
  }

  .calendar-panel {
    overflow-x: auto;
  }

  .agenda-item {
    grid-template-columns: 1fr;
  }

  .slot-detail-grid {
    grid-template-columns: 1fr;
  }

  .store-rule-grid {
    grid-template-columns: 1fr;
  }

  .admin-grid,
  .admin-user-row {
    grid-template-columns: 1fr;
  }
}
