:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #20231f;
  --muted: #657065;
  --line: #dfe4dc;
  --panel: #ffffff;
  --accent: #21705d;
  --accent-strong: #155745;
  --warn: #a15f00;
  --danger: #a63b3b;
  --soft: #edf4ef;
  --paid: #e4f4eb;
  --unpaid: #fff0df;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #17251f;
  color: #fff;
  padding: 28px 20px;
}

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

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: #f7c873;
  color: #17251f;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.brand p,
.eyebrow {
  margin: 4px 0 0;
  color: #aebdb4;
  font-size: 13px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab-button {
  min-height: 42px;
  border-radius: 8px;
  background: transparent;
  color: #d7e4dc;
  text-align: left;
  padding: 0 14px;
}

.tab-button.active,
.tab-button:hover {
  background: #294238;
  color: #fff;
}

.content {
  padding: 28px;
  min-width: 0;
}

.toolbar,
.section-header,
.calendar-header,
.filter-row,
.ledger-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toolbar {
  margin-bottom: 24px;
}

.toolbar h2,
.section-header h3,
.calendar-header h3 {
  margin: 0;
}

.toolbar h2 {
  font-size: 30px;
}

.toolbar-actions,
.row-actions,
.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.filter-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.filter-button {
  background: var(--soft);
  color: var(--accent-strong);
}

.filter-button.active {
  background: var(--accent);
  color: #fff;
}

.danger-button {
  background: #f7e6e6;
  color: var(--danger);
}

.icon-button {
  width: 42px;
  padding: 0;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 28px;
}

.small-button {
  min-height: 34px;
  margin-top: 8px;
}

.panel {
  display: none;
}

.panel.active {
  display: grid;
  gap: 18px;
}

.surface,
.metric,
.client-card,
.booking-row,
.reminder-item,
.day-dog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.surface {
  padding: 18px;
}

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

.booking-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric {
  padding: 18px;
}

.metric-link {
  cursor: pointer;
}

.metric-link:hover {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.split-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.side-panel {
  position: sticky;
  top: 20px;
}

.stack-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.compact-header {
  margin-bottom: 10px;
}

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

.form-grid.single {
  grid-template-columns: 1fr;
}

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

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

textarea {
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.quick-new-client {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.quick-new-client strong {
  color: var(--ink);
}

.checkbox-group {
  display: grid;
  gap: 8px;
}

.checkbox-card {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
}

.checkbox-card input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
}

.checkbox-text {
  display: grid;
  gap: 2px;
}

.checkbox-text strong {
  color: var(--ink);
  font-size: 14px;
}

.checkbox-text small {
  color: var(--muted);
}

.checkbox-empty,
.price-preview {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--muted);
  padding: 10px 12px;
}

.search-input {
  max-width: 320px;
}

.wide-input {
  min-width: min(320px, 100%);
}

.client-workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.client-list {
  display: grid;
  gap: 12px;
  color: var(--muted);
}

.compact-list {
  align-content: start;
}

.client-list-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.client-list-item span,
.client-list-item small {
  color: var(--muted);
}

.client-list-item.active,
.client-list-item:hover {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.client-detail {
  min-width: 0;
}

.client-card {
  padding: 14px;
}

.client-card.wide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.client-main {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 14px;
}

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

.dog-avatar {
  width: 82px;
  height: 82px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--soft);
  color: var(--accent-strong);
}

.dog-avatar.placeholder {
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 800;
}

.history-box {
  border-left: 1px solid var(--line);
  padding-left: 16px;
}

.client-order-form {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.dog-editor-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 14px;
}

.dog-editor {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.compact-history {
  border-left: 0;
  border-top: 1px solid var(--line);
  padding: 12px 0 0;
  margin-top: 12px;
}

.mini-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.client-card h4,
.booking-row h4,
.reminder-item h4 {
  margin: 0 0 8px;
}

.client-card p,
.booking-row p,
.reminder-item p,
.history-box p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.45;
}

.booking-row,
.reminder-item,
.day-dog {
  padding: 14px;
}

.day-dog {
  display: grid;
  gap: 4px;
  color: var(--ink);
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-strong);
  padding: 0 10px;
  font-size: 13px;
}

.pill.warn {
  background: var(--unpaid);
  color: var(--warn);
}

.pill.paid {
  background: var(--paid);
  color: var(--accent-strong);
}

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

.calendar-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.weekday-row {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.calendar-grid {
  gap: 8px;
  margin-top: 8px;
}

.day-cell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  text-align: left;
  color: var(--ink);
}

.day-cell:hover,
.day-cell.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.day-cell.outside {
  opacity: 0.42;
}

.day-number {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

.dog-chip-wrap {
  display: grid;
  gap: 5px;
  margin-top: 6px;
  pointer-events: none;
}

.dog-chip {
  display: block;
  min-width: 0;
  border-radius: 6px;
  background: #eaf3f1;
  color: #155745;
  padding: 5px 7px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 16px;
}

.booking-filter-row {
  align-items: stretch;
}

.booking-filter-row input,
.booking-filter-row select {
  max-width: 220px;
}

.ledger-summary {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

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

th {
  color: var(--muted);
  font-weight: 600;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.detail-row td {
  background: #fbfcfa;
}

.booking-detail-block,
.payment-detail-block {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.booking-detail-block strong,
.payment-detail-block strong {
  color: var(--ink);
}

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

.payment-detail-block > div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

@media (max-width: 1100px) {
  .calendar-layout,
  .client-card.wide,
  .client-workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .history-box {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
  }

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 16px;
  }

  .brand {
    margin-bottom: 14px;
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(96px, 1fr));
    overflow-x: auto;
  }

  .tab-button {
    text-align: center;
  }

  .content {
    padding: 18px max(18px, env(safe-area-inset-right)) 18px max(18px, env(safe-area-inset-left));
  }

  .metric-grid,
  .split-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions > button {
    flex: 1 1 120px;
  }
}

@media (max-width: 640px) {
  .toolbar,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar h2 {
    font-size: 24px;
  }

  .search-input {
    max-width: none;
  }

  .calendar-grid {
    gap: 4px;
    min-width: 680px;
  }

  .weekday-row {
    min-width: 680px;
  }

  .day-cell {
    min-height: 104px;
    padding: 6px;
  }

  .dog-chip {
    font-size: 11px;
    padding: 4px 5px;
  }

  .client-main {
    grid-template-columns: 1fr;
  }

  .inline-edit {
    grid-template-columns: 1fr;
  }

  .mini-form {
    grid-template-columns: 1fr;
  }

  .booking-filter-row input,
  .booking-filter-row select {
    max-width: none;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  table {
    min-width: 0;
  }

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

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px 12px;
  }

  td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 0;
    padding: 6px 0;
    align-items: center;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
  }

  .detail-row td {
    display: block;
    padding: 8px 0 0;
  }

  .detail-row td::before {
    display: none;
  }

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