:root {
  color-scheme: light;
  --bg: #f7faf6;
  --surface: #ffffff;
  --surface-soft: #edf5ee;
  --ink: #173328;
  --muted: #627269;
  --line: #d8e3da;
  --green: #287a4d;
  --green-dark: #195b3a;
  --berry: #7f3978;
  --tomato: #c44b39;
  --sky: #dcecf5;
  --tan: #efe3ca;
  --shadow: 0 18px 55px rgba(36, 64, 48, 0.12);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(40, 122, 77, 0.18);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 72px;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand,
.ghost-link,
.utility-link,
.staff-link {
  color: inherit;
  text-decoration: none;
}

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

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand small,
.section-toolbar p,
.utility-link small,
.empty-state span {
  color: var(--muted);
  font-size: 13px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--green-dark);
}

.brand-mark svg {
  width: 31px;
  height: 31px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.button-icon,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.top-actions,
.date-controls,
.form-actions,
.row-actions,
.type-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost-link,
.primary-button,
.secondary-button,
.text-button,
.icon-button,
.filter-chip,
.row-actions button {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.secondary-button {
  background: var(--surface-soft);
}

.staff-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.secondary-button.compact {
  min-height: 34px;
  padding: 0 10px;
}

.text-button {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--green-dark);
  padding: 4px 0;
}

.icon-button {
  width: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
}

button:hover,
.ghost-link:hover,
.utility-link:hover {
  border-color: #acc5b1;
  transform: translateY(-1px);
}

button:focus-visible,
a:focus-visible,
input:focus,
select:focus,
textarea:focus {
  outline: 0;
  box-shadow: var(--focus);
  border-color: var(--green);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(285px, 330px) minmax(420px, 1fr) minmax(400px, 520px);
  gap: 18px;
  padding: 18px;
  align-items: start;
}

.booking-view {
  width: min(900px, calc(100% - 32px));
  margin: 28px auto;
}

.booking-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.booking-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.booking-intro p {
  margin: 6px 0 0;
  color: var(--muted);
}

.booking-farm {
  margin: 0 0 8px !important;
  color: var(--green-dark) !important;
  font-size: 14px;
  font-weight: 900;
}

.self-booking-form {
  gap: 16px;
}

.slot-label {
  display: block;
  margin-bottom: 8px;
  color: #41564b;
  font-size: 13px;
  font-weight: 900;
}

.booking-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
}

.booking-slot {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.booking-slot[data-selected="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.no-slots {
  margin: 0;
  border: 1px dashed #bdd0c1;
  border-radius: var(--radius);
  background: #fbfdfb;
  color: var(--muted);
  padding: 18px;
  text-align: center;
  font-weight: 800;
}

.entry-panel,
.calendar-panel,
.summary-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.entry-panel,
.calendar-panel {
  padding: 18px;
}

.summary-panel {
  padding: 16px;
}

.panel-heading,
.section-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.section-toolbar p {
  margin: 4px 0 0;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #41564b;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 41px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  font-size: 15px;
}

textarea {
  resize: vertical;
  min-height: 76px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 0.78fr;
  gap: 10px;
}

.form-message {
  min-height: 18px;
  margin: 0;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

.sync-panel,
.auth-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
  padding: 10px;
  margin-bottom: 12px;
}

.sync-panel strong,
.sync-panel span {
  display: block;
}

.sync-panel strong {
  font-size: 13px;
  color: var(--green-dark);
}

.sync-panel span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.auth-panel {
  gap: 10px;
}

.auth-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.staff-locked .workspace {
  grid-template-columns: minmax(300px, 420px);
  justify-content: center;
}

.staff-locked #appointmentForm,
.staff-locked .calendar-panel,
.staff-locked .summary-panel,
.staff-locked .utility-links,
.staff-locked #resetData {
  display: none !important;
}

.staff-locked .entry-panel {
  width: min(420px, 100%);
}

.utility-links {
  margin-top: 18px;
  display: grid;
  gap: 9px;
}

.utility-link {
  min-height: 48px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
  padding: 8px 10px;
  text-align: left;
  font-size: 14px;
  font-weight: 800;
}

.utility-link.muted {
  color: #506158;
  background: #f5f1e7;
}

.type-filter {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-chip {
  min-height: 32px;
  font-size: 13px;
}

.filter-chip.active {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: #fff;
}

.timeline {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.time-slot {
  display: grid;
  grid-template-columns: 82px 1fr;
  min-height: 58px;
  background: #fff;
}

.time-slot + .time-slot {
  border-top: 1px solid var(--line);
}

.slot-time {
  padding: 12px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  background: #f7faf6;
  border-right: 1px solid var(--line);
}

.slot-body {
  padding: 8px;
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
}

.open-slot {
  border: 1px dashed #c4d5c8;
  background: #fbfdfb;
  color: #7a8b81;
  min-height: 38px;
  flex: 1;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.appointment-card {
  min-width: 198px;
  max-width: 260px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: var(--radius);
  border: 1px solid #eebeb6;
  border-left: 5px solid var(--tomato);
  background: #fff0eb;
  padding: 8px 10px;
}

.appointment-card.berries {
  border-color: #dfbfdd;
  border-left-color: var(--berry);
  background: #f6eef6;
}

.appointment-card.vegetables {
  border-color: #bdd9c5;
  border-left-color: var(--green);
  background: #eef7f0;
}

.appointment-card strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.appointment-card span {
  display: block;
  color: #51635a;
  font-size: 12px;
  margin-top: 2px;
}

.card-edit {
  min-height: 30px;
  border: 1px solid rgba(23, 51, 40, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  color: var(--green-dark);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
  flex: 0 0 auto;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f3f8f4;
  color: #41564b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  position: sticky;
  top: 0;
}

th button,
th span {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  min-height: auto;
  font: inherit;
  text-transform: inherit;
}

td {
  font-size: 14px;
}

.type-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: #ffe3da;
  color: #9f392b;
}

.type-pill.berries {
  background: #f4e4f1;
  color: var(--berry);
}

.type-pill.vegetables {
  background: #e4f2e8;
  color: var(--green-dark);
}

.status-pill {
  margin-top: 5px;
  color: #506158;
  background: #edf0ec;
}

.row-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.row-actions button[data-action="delete"] {
  color: #a43a2c;
}

.empty-state {
  margin-top: 14px;
  min-height: 110px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed #bdd0c1;
  border-radius: var(--radius);
  background: #fbfdfb;
  padding: 18px;
}

.empty-state strong,
.empty-state span {
  display: block;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(285px, 340px) 1fr;
  }

  .summary-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .topbar,
  .workspace {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .panel-heading,
  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .date-controls {
    flex-wrap: wrap;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .booking-view {
    width: calc(100% - 20px);
    margin-top: 16px;
  }

  .booking-card {
    padding: 18px 14px;
  }

  .booking-intro {
    flex-direction: column;
  }

  .time-slot {
    grid-template-columns: 70px 1fr;
  }
}

@media print {
  .topbar,
  .entry-panel,
  .calendar-panel,
  .section-toolbar button,
  .row-actions {
    display: none !important;
  }

  .workspace {
    display: block;
    padding: 0;
  }

  .summary-panel,
  .table-wrap {
    box-shadow: none;
    border: 0;
  }
}
