:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --ink: #2b2420;
  --muted: #7a6e66;
  --line: #eadfd4;
  --primary: #c8642d;
  --primary-ink: #ffffff;
  --accent: #3f7d6e;
  --warn: #b7791f;
  --danger: #b5432f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1916;
    --surface: #26221e;
    --ink: #f1e9e1;
    --muted: #a99c90;
    --line: #3a332d;
    --primary: #e08450;
    --primary-ink: #1c1916;
    --accent: #6fb3a2;
    --warn: #e0a84a;
    --danger: #e07a64;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
h3 { font-size: 1.05rem; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.2rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.4rem; }
#loginmenu { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: .9rem; }
.menubar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.baritem a, .baritemselected a { display: block; padding: 6px 12px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.baritem a:hover { background: var(--bg); text-decoration: none; }
.baritemselected a { background: var(--primary); color: var(--primary-ink); }
.baritemselected a:hover { text-decoration: none; }
#content { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; transition: opacity .18s; }
#content.spa-fading { opacity: .4; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 16px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { margin: 0; }
.card-body { padding: 18px; }
.card-body.no-pad { padding: 0; overflow-x: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; background: var(--bg); color: var(--ink); }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field.span-all { grid-column: 1 / -1; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit;
}
textarea { min-height: 76px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; font-weight: 500; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions a { margin-left: 12px; }
.row-actions a.danger, a.danger { color: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 28px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--bg); border: 1px solid var(--line); }
.pill-PENDING, .pill-DRAFT { color: var(--warn); border-color: var(--warn); }
.pill-APPROVED, .pill-SCHEDULED, .pill-SENT { color: var(--accent); border-color: var(--accent); }
.pill-COMPLETED, .pill-PAID { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.pill-DECLINED, .pill-CANCELLED, .pill-VOID { color: var(--danger); border-color: var(--danger); }

.alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 16px; }
.alert-error { background: rgba(181, 67, 47, .1); color: var(--danger); border: 1px solid rgba(181, 67, 47, .3); }
.alert-ok { background: rgba(63, 125, 110, .1); color: var(--accent); border: 1px solid rgba(63, 125, 110, .3); }

.dog-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.dog-card { overflow: hidden; margin: 0; }
.dog-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.dog-thumb { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; vertical-align: middle; background: var(--bg); }
.photo-preview { width: 160px; height: 160px; border-radius: var(--radius); object-fit: cover; background: var(--bg); border: 1px solid var(--line); }

.hero { text-align: center; padding: 48px 12px 24px; }
.hero h1 { font-size: 2.2rem; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 24px; font-size: 1.05rem; }
.auth-form { max-width: 400px; margin: 24px auto; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.day { background: var(--surface); min-height: 110px; padding: 6px; }
.day.today { background: rgba(200, 100, 45, .06); }
.day-num { font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.chip { display: block; font-size: .78rem; padding: 2px 6px; border-radius: 6px; margin-bottom: 3px; background: rgba(63, 125, 110, .14); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.svc-night { background: rgba(200, 100, 45, .16); }
.chip.svc-day { background: rgba(183, 121, 31, .16); }

.invoice-sheet { max-width: 760px; margin: 0 auto; }
.invoice-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.total-row td { font-weight: 700; font-size: 1.05rem; }

@media (max-width: 640px) {
  .topbar, .menubar { padding-left: 16px; padding-right: 16px; }
  #content { padding: 16px; }
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  th, td { padding: 8px 10px; }
}
@media print {
  .topbar, .menubar, .footer, .no-print { display: none !important; }
  body, .card { background: #fff; color: #000; box-shadow: none; border: none; }
}
