:root {
  --ink: #1f2937;
  --anthracite: #111827;
  --anthracite-soft: #1f2937;
  --muted: #6b7280;
  --gray: #9ca3af;
  --line: #e5e7eb;
  --surface: #ffffff;
  --background: #f3f4f6;
  --red: #dc2626;
  --red-dark: #b91c1c;
  --red-soft: #fef2f2;
  --blue: #00759e;
  --blue-dark: #075b7a;
  --blue-soft: #eff8ff;
  --green: #067647;
  --green-soft: #ecfdf3;
  --green-line: #58b985;
  --danger: #b42318;
  --warning: #92400e;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--background); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--background); font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.brand-header { position: relative; z-index: 40; background: white; box-shadow: 0 3px 14px rgba(17, 24, 39, .09); }
.brand-header-inner { width: min(1240px, calc(100% - 40px)); min-height: 104px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 12px 0; }
.brand-lockup img { display: block; width: min(390px, 52vw); height: 76px; object-fit: contain; object-position: left center; }
.brand-product { color: var(--anthracite); font-size: clamp(1rem, 2vw, 1.42rem); font-weight: 800; letter-spacing: .02em; text-align: right; }

.topbar { position: sticky; top: 0; z-index: 30; color: white; background: var(--anthracite); border-bottom: 1px solid #374151; box-shadow: 0 6px 16px rgba(17, 24, 39, .15); }
.topbar-inner { width: min(1240px, calc(100% - 40px)); min-height: 58px; margin: 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 24px; }
.nav-links { display: flex; gap: 22px; align-items: center; }
.nav-links > a, .link-button { color: #d1d5db; text-decoration: none; background: none; border: 0; padding: 0; font-weight: 700; transition: color .15s ease; }
.nav-links form { margin: 0; }
.nav-links > a:hover, .link-button:hover { color: #f87171; }

.page { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 72px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; color: var(--anthracite); font-size: clamp(1.85rem, 3vw, 2.7rem); line-height: 1.08; letter-spacing: -.035em; }
h2 { color: var(--anthracite); font-size: 1.14rem; }
.eyebrow { color: var(--red); font-weight: 850; font-size: .76rem; letter-spacing: .13em; text-transform: uppercase; margin-bottom: 8px; }
.card, .table-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 8px; font-weight: 800; text-decoration: none; transition: .15s ease; }
.button.primary { color: white; background: var(--red); }
.button.primary:hover { background: var(--red-dark); transform: translateY(-1px); }
.button.secondary { color: var(--anthracite); background: white; border-color: #d1d5db; }
.button.secondary:hover { color: var(--blue-dark); border-color: var(--blue); }
.button.full { width: 100%; }

label, .label-title { display: block; color: #374151; font-size: .88rem; font-weight: 750; }
input, select, textarea { width: 100%; margin-top: 7px; padding: 11px 12px; color: var(--ink); background: white; border: 1px solid #cbd1da; border-radius: 8px; outline: none; }
input[readonly] { color: var(--muted); background: #f9fafb; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 117, 158, .14); }
.help { margin: 6px 0 0; color: var(--muted); font-size: .84rem; }
.stack-form, .form-section, .invitation-form { display: grid; gap: 18px; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 4px; }
.field-row, .filters { display: flex; gap: 16px; align-items: flex-end; }
.grow { flex: 1; }
.small-field { width: 125px; }
.contact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.contact-help { margin-top: -10px; padding-left: 12px; border-left: 3px solid var(--blue); }

.flash-stack { display: grid; gap: 8px; margin-bottom: 22px; }
.flash { padding: 12px 15px; border-radius: 8px; border: 1px solid; }
.flash.success { color: var(--green); background: var(--green-soft); border-color: #abefc6; }
.flash.error { color: #912018; background: var(--red-soft); border-color: #fecaca; }
.notice { padding: 11px 13px; border-radius: 8px; font-size: .9rem; }
.notice.warning { color: var(--warning); background: #fff7ed; border: 1px solid #fed7aa; }

.login-page { min-height: calc(100vh - 104px); display: grid; place-items: center; padding: 30px 24px; }
.login-card { width: min(430px, 100%); padding: 34px; border-top: 4px solid var(--red); }
.login-intro { margin-bottom: 24px; color: var(--muted); }
.filters { padding: 18px; margin-bottom: 20px; }
.filters label:not(.grow) { width: 220px; }
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1040px; }
th, td { padding: 15px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid #e9edf3; }
th { color: var(--muted); font-size: .75rem; letter-spacing: .07em; text-transform: uppercase; background: #f9fafb; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: .76rem; font-weight: 850; white-space: nowrap; }
.badge.active { color: var(--blue-dark); background: var(--blue-soft); }
.badge.booked { color: var(--green); background: var(--green-soft); }
.badge.expired { color: #4b5563; background: #f3f4f6; }
.badge.deleted { color: #991b1b; background: #fee2e2; }
.inline-error { width: max-content; margin-top: 5px; color: var(--danger); font-size: .75rem; font-weight: 850; }
.actions { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.actions form { margin: 0; }
.text-action { padding: 0; color: var(--blue-dark); background: none; border: 0; font-size: .84rem; text-decoration: none; white-space: nowrap; }
.text-action:hover { color: var(--red); }
.text-action.danger { color: var(--danger); }
.contact-cell { display: grid; gap: 3px; }
.empty-state { padding: 28px; text-align: center; color: var(--muted); }
.cell-meta { margin-top: 4px; color: var(--muted); font-size: .78rem; }
.cell-detail { max-width: 310px; margin-top: 4px; color: #4b5563; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-section { padding: 24px; align-content: start; border-top: 3px solid var(--anthracite); }
.form-section.wide, .settings-grid > .wide { grid-column: 1 / -1; }
.form-section h2 { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.device-list { display: grid; gap: 10px; }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #f9fafb; }
.device-row strong, .device-row span { display: block; }
.device-row span { margin-top: 3px; color: var(--muted); font-size: .82rem; }
.compact-form { width: min(620px, 100%); }
.enrollment-card { width: min(820px, 100%); padding: 28px; }
.setup-steps { display: grid; gap: 9px; padding-left: 22px; }
.secret-code { display: inline-block; max-width: 100%; padding: 5px 7px; overflow-wrap: anywhere; color: var(--anthracite); background: #f3f4f6; border-radius: 5px; }
.invitation-form { padding: 28px; border-top: 4px solid var(--red); }
.calendar-list { display: grid; gap: 8px; margin-top: 12px; }
.calendar-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: #f9fafb; }
.calendar-option label { display: flex; align-items: center; gap: 10px; flex: 1; }
.calendar-option input { width: auto; margin: 0; accent-color: var(--red); }
.priority-buttons { display: flex; gap: 5px; }
.icon-button { width: 34px; height: 32px; color: var(--anthracite); border: 1px solid var(--line); border-radius: 6px; background: white; }
.icon-button:hover { color: var(--red); border-color: var(--red); }

.public-page { width: 100%; min-height: calc(100vh - 104px); margin: 0; padding: 0; background: radial-gradient(circle at top right, rgba(0, 117, 158, .10), transparent 34%), linear-gradient(180deg, #f9fafb, #f3f4f6); }
.public-shell { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 58px 0 80px; }
.public-shell.narrow { width: min(650px, calc(100% - 32px)); }
.public-heading { margin-bottom: 28px; }
.public-heading p { color: var(--muted); font-size: 1.02rem; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; color: var(--muted); font-size: .86rem; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-dot { width: 10px; height: 10px; border: 2px solid; border-radius: 999px; }
.legend-dot.green { background: var(--green-soft); border-color: var(--green-line); }
.legend-dot.standard { background: white; border-color: #9ca3af; }
.slot-days { display: grid; gap: 30px; }
.day-section h2 { margin-bottom: 12px; }
.slot-grid { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; transition: padding .18s ease; }
.slot-grid.has-visible-tip { padding-top: 142px; }
.slot-card { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 16px; min-width: 0; padding: 17px; background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 7px 22px rgba(17, 24, 39, .06); }
.slot-card.green { background: var(--green-soft); border-color: var(--green-line); border-left: 5px solid var(--green); }
.slot-card strong, .slot-card span { display: block; }
.slot-card span { margin-top: 3px; color: var(--muted); font-size: .8rem; }
.green-recommendation { position: absolute; left: 0; bottom: calc(100% + 16px); z-index: 5; width: min(440px, calc(200% + 12px)); padding: 17px 42px 17px 18px; color: white; background: var(--anthracite); border-left: 5px solid var(--green-line); border-radius: 10px; box-shadow: 0 14px 32px rgba(17, 24, 39, .2); }
.green-recommendation::after { content: ""; position: absolute; left: 34px; bottom: -10px; width: 18px; height: 18px; background: var(--anthracite); transform: rotate(45deg); }
.green-recommendation strong { color: white; font-size: .96rem; }
.green-recommendation span { margin-top: 4px; color: #d1d5db; font-size: .82rem; line-height: 1.45; }
.tip-close { position: absolute; top: 9px; right: 10px; width: 28px; height: 28px; padding: 0; color: #d1d5db; background: transparent; border: 0; font-size: 1.3rem; line-height: 1; }
.tip-close:hover { color: white; }
.empty-public, .confirm-card, .result-card { padding: 30px; }
.confirm-card { display: grid; gap: 22px; border-top: 4px solid var(--red); }
.summary-list { margin: 0; display: grid; gap: 12px; }
.summary-list div { display: grid; grid-template-columns: 90px 1fr; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; font-weight: 780; }
.binding-notice { padding: 15px; color: #374151; background: #f9fafb; border: 1px solid #d1d5db; border-left: 4px solid var(--blue); border-radius: 8px; font-size: .9rem; }
.result-card { text-align: center; margin-top: 28px; border-top: 4px solid var(--red); }
.result-card p { color: var(--muted); }
.result-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 18px; color: white; background: var(--red); border-radius: 50%; font-size: 1.8rem; font-weight: 900; }
.large-text { color: var(--ink) !important; font-size: 1.28rem; font-weight: 850; }
.confirmation-results { display: grid; gap: 8px; margin-top: 18px; }
.confirmation-result { margin: 0; padding: 10px 12px; border-radius: 8px; }
.confirmation-result.sent { color: var(--green); background: var(--green-soft); }
.confirmation-result.failed { color: var(--danger); background: var(--red-soft); }

@media (max-width: 760px) {
  .brand-header-inner { width: min(100% - 28px, 1240px); min-height: 86px; gap: 14px; }
  .brand-lockup img { width: min(260px, 58vw); height: 62px; }
  .brand-product { max-width: 130px; font-size: .86rem; }
  .topbar-inner { width: min(100% - 28px, 1240px); align-items: flex-start; flex-direction: column; gap: 10px; padding: 13px 0; }
  .nav-links { width: 100%; gap: 11px 15px; flex-wrap: wrap; font-size: .84rem; }
  .page { width: min(100% - 24px, 1240px); padding-top: 26px; }
  .page-heading, .field-row, .filters { align-items: stretch; flex-direction: column; }
  .filters label:not(.grow), .small-field { width: 100%; }
  .settings-grid, .slot-grid, .contact-grid { grid-template-columns: 1fr; }
  .slot-grid.has-visible-tip { padding-top: 185px; }
  .slot-card { align-items: stretch; flex-direction: column; }
  .slot-card .button { width: 100%; }
  .green-recommendation { width: 100%; bottom: calc(100% + 15px); }
  .public-shell { padding-top: 38px; }
}
