/* A working tool: calm, dense, readable. Green means done, amber means attention. */
:root {
  --brand: #1d5a46; --on-brand: #fff;
  /* Surfaces and lines pick up a little of the brand colour, so each contractor's admin feels like their own. */
  --bg: color-mix(in srgb, var(--brand) 5%, #f4f4f1); --panel: #fff; --ink: #1b2420; --muted: #58625d;
  --line: color-mix(in srgb, var(--brand) 16%, #dcdcd8); --soft: color-mix(in srgb, var(--brand) 9%, #fff);
  --ok: #1d6b45; --warn: #9a5b00; --bad: #a3261e; --warn-bg: #fff1d6; --bad-bg: #fde5e2; --ok-bg: #dcf1e5;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.45 var(--a-body, "EB Garamond"), system-ui, sans-serif; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .stat strong { font-family: var(--a-head, inherit), system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.btn { padding: 10px 16px; background: var(--brand); color: var(--on-brand); border: 2px solid var(--brand); border-radius: var(--radius); font-weight: 700; cursor: pointer; }
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-alt { background: transparent; color: var(--brand); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-small { padding: 6px 10px; font-size: 0.875rem; }
.err { color: var(--bad); font-weight: 600; font-size: 0.9375rem; }
.muted { color: var(--muted); }

/* Login */
.login { display: grid; place-content: center; justify-items: center; gap: 16px; min-height: 100vh; padding: 20px; }
.login-card { width: min(400px, calc(100vw - 40px)); background: var(--panel); border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.login form { padding: 28px; display: grid; gap: 10px; }
.login h1 { font-size: 1.75rem; font-weight: 900; letter-spacing: -0.02em; line-height: 1.15; }
.login label { font-weight: 700; }
.login input { padding: 11px 12px; border: 2px solid #8b968f; border-radius: var(--radius); background: #fff; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 1.0625rem; }
.login-brand svg, .top h1 svg { width: 30px; height: 30px; flex: none; }
.demo { display: grid; gap: 10px; padding: 18px 28px 24px; background: var(--soft); border-top: 2px solid var(--line); }
.demo .btn { width: 100%; }
.login-back a { color: var(--muted); font-weight: 600; }
.top h1 { display: flex; align-items: center; gap: 10px; }
a.btn { display: inline-block; text-decoration: none; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 2px solid var(--line); }
.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; width: min(1320px, 100% - 32px); margin: 0 auto; padding: 12px 0; }
.top h1 { font-size: 1.375rem; font-weight: 900; letter-spacing: -0.02em; }
.biz { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.biz span { color: var(--muted); font-weight: 500; }
.biz select { padding: 8px 10px; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); font-weight: 700; }
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--soft); border-radius: var(--radius); }
.tabs button { padding: 7px 14px; background: none; border: 0; border-radius: 6px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.15); }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

#main { width: min(1320px, 100% - 32px); margin: 0 auto; padding: 20px 0 60px; }

/* Week header */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.bar h2 { font-size: 1.5rem; font-weight: 900; letter-spacing: -0.02em; margin-right: auto; }
.nav { display: flex; gap: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.stat { padding: 10px 16px; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); }
.stat strong { display: block; font-size: 1.625rem; font-weight: 900; line-height: 1.1; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 0.875rem; }

/* Week grid */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.day { background: var(--panel); border: 2px solid var(--line); border-radius: 10px; overflow: hidden; }
.day.is-today { border-color: var(--brand); }
.day.is-past { opacity: 0.7; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 10px 12px; background: var(--soft); }
.day.is-today .day-head { background: var(--brand); color: var(--on-brand); }
.day-head strong { font-size: 1rem; }
.day-head button { padding: 0; background: none; border: 0; color: inherit; font-size: 0.8125rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; opacity: 0.85; }
.day-note { padding: 10px 12px; color: var(--muted); font-size: 0.9375rem; }
.day-closed { margin: 8px; padding: 8px 10px; background: var(--warn-bg); color: var(--warn); border-radius: 6px; font-size: 0.875rem; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.slot { padding: 10px 10px 8px; border-top: 1px solid var(--line); }
.slot-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 6px; }
.slot-head strong { font-size: 0.9375rem; }
.meter { display: inline-flex; gap: 3px; }
.meter i { width: 9px; height: 9px; border: 2px solid var(--brand); border-radius: 50%; }
.meter i.on { background: var(--brand); }
.slot.is-blocked { background: repeating-linear-gradient(-45deg, #f3f3f0 0 8px, #e9ebe6 8px 16px); }
.chip { display: block; width: 100%; margin-bottom: 5px; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--brand); border-radius: 6px; text-align: left; cursor: pointer; line-height: 1.3; }
.chip:hover { background: var(--soft); }
.chip strong { display: block; font-size: 0.9375rem; overflow-wrap: anywhere; }
.chip span { display: block; color: var(--muted); font-size: 0.8125rem; }
.chip.st-completed { border-left-color: var(--ok); }
.chip.st-no-show { border-left-color: var(--warn); }
.chip.st-cancelled { border-left-color: #a8b0aa; }
.chip.st-cancelled strong { text-decoration: line-through; color: var(--muted); }
.slot-add { padding: 0; background: none; border: 0; color: var(--brand); font-size: 0.8125rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.slot-block { color: var(--muted); font-size: 0.8125rem; display: flex; justify-content: space-between; gap: 6px; }
.slot-block button { padding: 0; background: none; border: 0; color: var(--brand); font-weight: 700; text-decoration: underline; cursor: pointer; font-size: inherit; }

/* List */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filters input, .filters select { padding: 9px 11px; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); }
.filters input { flex: 1 1 220px; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 2px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--soft); font-size: 0.875rem; color: var(--muted); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f9f6; }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8125rem; font-weight: 700; background: var(--soft); }
.badge.st-confirmed { background: #e2ecf7; color: #1f4f86; }
.badge.st-completed { background: var(--ok-bg); color: var(--ok); }
.badge.st-no-show { background: var(--warn-bg); color: var(--warn); }
.badge.st-cancelled { background: var(--bad-bg); color: var(--bad); }

/* Dialog */
dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100vh - 24px); padding: 0; background: var(--panel); color: var(--ink); border: 0; border-radius: 12px; box-shadow: 0 20px 60px rgb(0 0 0 / 0.35); overflow: auto; }
dialog::backdrop { background: rgb(20 30 25 / 0.55); }
.dlg { padding: 22px; display: grid; gap: 14px; }
.dlg-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.dlg h2 { font-size: 1.375rem; font-weight: 900; letter-spacing: -0.02em; line-height: 1.2; }
.x { padding: 4px 10px; background: none; border: 0; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; padding: 12px 14px; background: var(--soft); border-radius: var(--radius); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts a { color: var(--brand); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.field { display: grid; gap: 4px; }
.field label, .grid2 label { font-weight: 700; }
.field input, .field select, .field textarea, .grid2 input, .grid2 select { width: 100%; padding: 10px 11px; background: #fff; border: 2px solid #8b968f; border-radius: var(--radius); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 > div { display: grid; gap: 4px; }
.check { display: flex; gap: 10px; align-items: start; }
.check input { flex: none; width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); }
.check.is-off { color: var(--muted); }
.note { color: var(--muted); font-size: 0.9375rem; }

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 50; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; background: var(--ink); color: #fff; border-radius: var(--radius); font-weight: 600; box-shadow: 0 6px 24px rgb(0 0 0 / 0.3); }

@media (max-width: 1100px) {
  .week { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}
@media (max-width: 640px) {
  .week { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .top-actions { margin-left: 0; width: 100%; }
  .top-actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
