* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  font-family: "Segoe UI", sans-serif;
  color: #23272a;
  background: #f4f5f4;
  font-synthesis: none;
}

body {
  min-width: 360px;
  min-height: 100vh;
  margin: 0;
  background: #f4f5f4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f4f5f4, #e8eeeb);
}

.login-panel {
  width: min(100%, 410px);
  padding: 32px;
  border: 1px solid #dce1de;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(24, 35, 31, 0.09);
}

.back-link {
  color: #59645f;
  font-size: 14px;
  text-decoration: none;
}

.eyebrow {
  margin: 28px 0 8px;
  color: #a16c25;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.login-panel h1,
.dialog-header h2 {
  margin: 0;
  font-size: 25px;
  font-weight: 650;
}

.login-copy {
  margin: 10px 0 24px;
  color: #66716c;
  font-size: 14px;
}

.login-panel label,
.event-form > label,
.event-form .form-row label {
  display: grid;
  gap: 7px;
  margin: 14px 0 7px;
  color: #454e49;
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #cfd6d2;
  border-radius: 5px;
  background: #fff;
  color: #23272a;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #94b5a3;
  outline-offset: 1px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
}

.primary-button {
  background: #17231f;
  color: #fff;
}

.primary-button:hover {
  background: #2b3b34;
}

.secondary-button,
.text-button,
.icon-button {
  border-color: #d3dad6;
  background: #fff;
  color: #35413b;
}

.secondary-button:hover,
.text-button:hover,
.icon-button:hover {
  background: #f0f4f1;
}

.danger-button {
  border-color: #ecc3bd;
  background: #fff6f4;
  color: #9b352a;
}

.login-panel .primary-button {
  width: 100%;
  margin-top: 20px;
}

.form-message,
.calendar-message {
  min-height: 18px;
  margin: 10px 0 0;
  color: #963d32;
  font-size: 13px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 70px;
  padding: 12px 22px;
  border-bottom: 1px solid #d9dfdb;
  background: #fff;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #202723;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.admin-brand span {
  color: #7b8580;
  font-size: 13px;
  font-weight: 500;
}

.calendar-toolbar,
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 38px;
  padding: 4px;
  font-size: 20px;
  line-height: 1;
}

.week-picker {
  width: 150px;
}

.week-label {
  min-width: 98px;
  color: #66716c;
  font-size: 12px;
  text-align: center;
}

.logout-button {
  margin-left: 4px;
}

.calendar-panel {
  display: grid;
  grid-template-columns: 62px minmax(900px, 1fr);
  margin: 18px 18px 0;
  overflow: auto;
  border: 1px solid #d9dfdb;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(25, 33, 29, 0.04);
}

.time-column {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #fff;
  border-right: 1px solid #dfe4e1;
}

.all-day-label,
.day-header {
  height: 66px;
  display: flex;
  align-items: end;
  justify-content: center;
  padding: 0 4px 10px;
  border-bottom: 1px solid #dfe4e1;
  color: #67716c;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.time-labels {
  display: grid;
  grid-template-rows: repeat(10, 64px);
}

.time-label {
  position: relative;
  top: -7px;
  padding-right: 8px;
  color: #78817c;
  font-size: 10px;
  text-align: right;
}

.calendar-content {
  min-width: 900px;
}

.day-headers,
.all-day-lane,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
}

.day-header {
  align-items: end;
  gap: 5px;
  border-right: 1px solid #e2e6e3;
}

.day-header strong {
  color: #303a35;
}

.day-header.today {
  background: #f0f5f1;
}

.all-day-lane {
  min-height: 34px;
  border-bottom: 1px solid #dfe4e1;
}

.all-day-cell {
  padding: 2px;
  border-right: 1px solid #e2e6e3;
}

.calendar-grid {
  min-height: 640px;
  grid-template-rows: 640px;
  background: repeating-linear-gradient(to bottom, transparent 0 15px, #e8ece9 15px 16px);
}

.day-track {
  position: relative;
  border-right: 1px solid #e2e6e3;
  background: repeating-linear-gradient(to bottom, transparent 0 63px, #dce2de 63px 64px);
}

.day-track.closed {
  background-color: #f3f4f3;
  background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(119, 130, 123, 0.055) 6px 8px), repeating-linear-gradient(to bottom, transparent 0 63px, #dce2de 63px 64px);
}

.calendar-event {
  position: absolute;
  z-index: 2;
  left: 3px;
  width: calc(100% - 6px);
  min-height: 18px;
  overflow: hidden;
  border: 0;
  border-left: 3px solid #bd741f;
  border-radius: 3px;
  padding: 4px 5px;
  background: #f5d7b6;
  color: #382d21;
  text-align: left;
  cursor: pointer;
}

.calendar-event:hover {
  z-index: 3;
  filter: brightness(0.97);
  box-shadow: 0 2px 8px rgba(37, 40, 37, 0.15);
}

.event-time,
.event-title,
.event-detail {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-time {
  margin-bottom: 2px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.event-title {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.event-detail {
  margin-top: 2px;
  font-size: 10px;
  line-height: 1.25;
}

.calendar-event.absence {
  border-left-color: #a9493d;
  background: #f5dfdc;
  color: #56302c;
}

.calendar-event.pause {
  border-left-color: #78847d;
  background: #e5e9e6;
  color: #404a44;
}

.calendar-event.task {
  border-left-color: #358070;
  background: #d9eee8;
  color: #254b43;
}

.calendar-event.note {
  border-left-color: #687c9e;
  background: #e4eaf4;
  color: #34425a;
}

.admin-app > .calendar-message {
  margin: 8px 22px;
  color: #66716c;
}

.event-dialog {
  width: min(600px, calc(100% - 24px));
  max-height: min(90vh, 900px);
  overflow: auto;
  border: 1px solid #d6ddd8;
  border-radius: 8px;
  padding: 0;
  background: #fff;
  color: #23272a;
  box-shadow: 0 24px 80px rgba(20, 28, 23, 0.25);
}

.event-dialog::backdrop {
  background: rgba(20, 27, 23, 0.44);
}

.event-form {
  padding: 24px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.dialog-header .eyebrow {
  margin: 0 0 5px;
}

.dialog-header h2 {
  font-size: 21px;
}

.dialog-section {
  display: grid;
  gap: 4px;
  margin: 10px 0;
}

.dialog-section[hidden],
.block-time-fields[hidden] {
  display: none;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.block-time-fields {
  grid-template-columns: 1.2fr 1fr 1fr;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #454e49;
  font-size: 13px;
}

.checkbox-label input {
  width: 17px;
  min-height: 17px;
  margin: 0;
}

.optional {
  color: #7a847e;
  font-weight: 400;
}

.admin-service-list {
  display: grid;
  gap: 6px;
  margin: 6px 0;
}

.admin-service-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  align-items: center;
  gap: 10px;
  color: #414b45;
  font-size: 13px;
}

.admin-service-row input {
  min-height: 34px;
  padding: 5px 8px;
}

.payment-section {
  margin-top: 20px;
  border-top: 1px solid #e0e5e2;
  padding-top: 14px;
}

.payment-section h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.payment-summary {
  margin: 0 0 10px;
  color: #45514b;
  font-size: 13px;
  font-weight: 600;
}

.payment-list {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.payment-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #58635d;
  font-size: 12px;
}

.payment-entry-row {
  grid-template-columns: 0.8fr 0.8fr 1.4fr;
  gap: 8px;
}

.ledger-dialog {
  width: min(1120px, calc(100% - 24px));
}

.ledger-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 16px;
}

.ledger-toolbar label {
  display: grid;
  gap: 5px;
  color: #59645f;
  font-size: 12px;
  font-weight: 600;
}

.ledger-toolbar input {
  width: 150px;
}

.ledger-totals {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.ledger-totals > div {
  display: grid;
  gap: 6px;
  min-height: 70px;
  align-content: center;
  border: 1px solid #dfe5e1;
  border-radius: 5px;
  padding: 9px 11px;
  background: #f9faf9;
}

.ledger-totals span {
  color: #717b75;
  font-size: 11px;
}

.ledger-totals strong {
  color: #28352e;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.ledger-table-wrap {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid #dfe5e1;
  border-radius: 5px;
}

.ledger-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #fff;
}

.ledger-table th,
.ledger-table td {
  padding: 9px 11px;
  border-bottom: 1px solid #e7ebe8;
  font-size: 12px;
  text-align: left;
}

.ledger-table th {
  position: sticky;
  top: 0;
  background: #f3f6f4;
  color: #58635d;
  font-weight: 650;
}

.table-subtext {
  display: block;
  margin-top: 3px;
  color: #76817b;
  font-size: 11px;
}

.amount-cell {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.refund-amount {
  color: #a44337;
}

.empty-ledger {
  padding: 14px;
  color: #7a847e;
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.dialog-spacer {
  flex: 1;
}

@media (max-width: 900px) {
  .admin-header {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .calendar-toolbar {
    order: 3;
    width: 100%;
  }

  .header-actions {
    margin-left: auto;
  }

  .week-label {
    display: none;
  }
}

@media (max-width: 560px) {
  .admin-header {
    gap: 10px;
    padding: 10px;
  }

  .header-actions {
    gap: 5px;
    flex-wrap: wrap;
    width: 100%;
  }

  .header-actions .secondary-button,
  .header-actions .primary-button {
    padding: 7px 9px;
    font-size: 12px;
  }

  .calendar-toolbar {
    gap: 5px;
  }

  .week-picker {
    width: 130px;
  }

  .calendar-panel {
    margin: 10px 8px 0;
  }

  .event-form {
    padding: 18px;
  }

  .block-time-fields {
    grid-template-columns: 1fr 1fr;
  }

  .ledger-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .payment-entry-row {
    grid-template-columns: 1fr;
  }

  .ledger-toolbar input {
    width: 130px;
  }
}

.review-list { display: grid; gap: 10px; margin: 12px 0 18px; max-height: 45vh; overflow: auto; }
.review-item { border: 1px solid #dfe2df; border-radius: 10px; padding: 12px 14px; background: #fff; }
.review-item p { margin: 6px 0 10px; line-height: 1.5; }
.review-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.review-stars { color: #c89d42; letter-spacing: 1px; }
.review-meta { color: #6b7280; font-size: 0.85rem; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.review-badge { font-size: 0.8rem; padding: 3px 10px; border-radius: 999px; background: #eceeec; color: #4b5563; }
.review-badge.on { background: #e5f4e8; color: #1f7a35; }
.review-add { border-top: 1px solid #dfe2df; padding-top: 14px; display: grid; gap: 8px; }
.review-add h3 { margin: 0; font-size: 1rem; }
.review-add textarea { width: 100%; padding: 10px; border: 1px solid #cfd3cf; border-radius: 8px; }
.inline-check { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; }

.customer-toolbar { display: flex; gap: 10px; margin: 8px 0; }
.customer-toolbar input { flex: 1; padding: 10px; border: 1px solid #cfd3cf; border-radius: 8px; }
.customer-row { text-align: left; border: 1px solid #dfe2df; border-radius: 10px; padding: 10px 14px; background: #fff; cursor: pointer; display: grid; gap: 2px; font: inherit; }
.customer-row:hover { border-color: #c89d42; }
.duplicate-group { display: grid; gap: 6px; padding: 8px; border: 2px solid #c89d42; border-radius: 12px; margin-bottom: 10px; }
.customer-toolbar { flex-wrap: wrap; }
.review-add[hidden], #customerHistory[hidden] { display: none; }
.review-add input:not([type=checkbox]) { width: 100%; padding: 10px; border: 1px solid #cfd3cf; border-radius: 8px; }
