:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657083;
  --line: #d7e0ea;
  --primary: #12355b;
  --primary-2: #1e5b93;
  --primary-soft: #e8f1fb;
  --danger: #b42318;
  --success: #067647;
  --warning: #a15c07;
  --shadow: 0 16px 40px rgba(15, 35, 62, .08);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--primary-2); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 34px; letter-spacing: 0; }
h2 { margin-bottom: 6px; font-size: 20px; letter-spacing: 0; }
h3 { font-size: 16px; letter-spacing: 0; }
p { color: var(--muted); line-height: 1.5; }

button, .button, .link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
button:hover, .button:hover, .link-button:hover { background: #0b2747; }
button:disabled { opacity: .45; cursor: not-allowed; }
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  background: white;
  color: var(--primary);
  border: 1px solid var(--line);
  font-weight: 700;
}
.ghost:hover { background: var(--primary-soft); }
.danger { background: var(--danger); }
.full { width: 100%; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 264px;
  background: #102a46;
  color: white;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
}
.brand-mark {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
}
.sidebar nav { display: grid; gap: 6px; }
.sidebar a {
  color: #eef6ff;
  padding: 11px 12px;
  border-radius: 6px;
  font-weight: 700;
}
.sidebar a:hover { background: rgba(255,255,255,.10); }
.sidebar-user {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
}
.sidebar-user span { color: #c4d5e8; font-size: 13px; }

.content { margin-left: 264px; padding: 30px; }
.public-content { padding: 32px; max-width: 1120px; margin: 0 auto; }
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.card, .panel, .login-card, .result-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.card { padding: 18px; }
.panel, .login-card, .result-box { padding: 20px; }
.card span { color: var(--muted); display: block; font-weight: 700; }
.card strong { font-size: 34px; display: block; margin-top: 8px; }
.section-title {
  display: grid;
  gap: 2px;
  margin-bottom: 16px;
}
.section-title.inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.section-title p { margin-bottom: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; background: white; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-size: 13px; background: #f7f9fc; }
tbody tr:hover { background: #fbfdff; }
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: 12px;
}
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  color: var(--muted);
}
.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.status-dot.active, .status-dot.available, .status-dot.finished { color: var(--success); }
.status-dot.inactive, .status-dot.canceled { color: var(--danger); }
.status-dot.scheduled, .status-dot.reserved, .status-dot.in_progress { color: var(--warning); }

.form, .grid-form, .search-form { display: grid; gap: 14px; }
.grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  background: white;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(30, 91, 147, .15);
  border-color: var(--primary-2);
}
textarea { min-height: 96px; resize: vertical; }
.wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row-actions form { margin: 0; }
.row-actions .button,
.row-actions .ghost,
.row-actions button {
  min-height: 36px;
  padding: 0 12px;
}
.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 300px;
}
.inline-form button { min-height: 42px; }
.call-cell {
  display: grid;
  gap: 8px;
  min-width: 220px;
}
.call-timer {
  display: inline-flex;
  width: fit-content;
  border-radius: 6px;
  padding: 5px 9px;
  background: #fff4cc;
  color: var(--warning);
}
.call-timer.expired {
  background: #fee4e2;
  color: var(--danger);
}
.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.filter { max-width: 360px; }
.history-filter {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 260px;
}
.field-hint {
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.field-hint[data-state="success"] { color: var(--success); }
.field-hint[data-state="error"] { color: var(--danger); }
.field-hint[data-state="loading"] { color: var(--primary-2); }
.muted { color: var(--muted); }
.contract-selector {
  max-width: 640px;
  margin-bottom: 16px;
}
.contract-box {
  display: grid;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.contract-box h3 {
  margin: 14px 0 0;
  color: var(--primary);
}
.contract-text {
  margin-bottom: 0;
  color: var(--text);
  white-space: pre-line;
}
.contract-notice,
.contract-consent {
  color: var(--text);
  font-weight: 700;
}
.checkbox-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--text);
}
.checkbox-row input {
  width: 18px;
  min-height: 18px;
  padding: 0;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
}
.detail-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.detail-grid dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.detail-grid dd {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(18,53,91,.92), rgba(30,91,147,.78)),
    #102a46;
}
.login-card { width: min(440px, 100%); padding: 28px; }
.login-icon {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
}
.login-title {
  display: grid;
  gap: 4px;
  margin-bottom: 18px;
  text-align: center;
  font-size: 28px;
}
.login-title span:last-child {
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
}
.setup-callout {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.setup-callout p { margin-bottom: 0; }
.alert {
  padding: 12px 14px;
  border-radius: 6px;
  background: #fff4cc;
  color: #6f4600;
  margin-bottom: 16px;
  font-weight: 700;
}
.error { background: #fee4e2; color: var(--danger); }
.alert.success { background: #dcfae6; color: var(--success); }

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.stack { display: grid; gap: 10px; align-content: start; }
.selection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.check-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfdff;
}
.check-list label {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--text);
  font-weight: 600;
}
.qr { width: 220px; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.public-hero { padding: 48px 0 28px; max-width: 760px; }
.public-hero h1 { font-size: clamp(32px, 5vw, 56px); margin: 12px 0; }
.public-hero.compact h1 { font-size: clamp(28px, 4vw, 42px); }
.public-panel { margin-top: 16px; }
.search-form {
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
  align-items: end;
  margin-top: 20px;
}
.result-box { max-width: 720px; }
.result-box.success { border-color: #abefc6; }
.result-box.warning { border-color: #fedf89; }
.position { font-size: 24px; color: var(--success); font-weight: 800; }
.call-popup[hidden] { display: none; }
.call-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 26, 43, .72);
}
.call-popup-card {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 8px;
  border: 1px solid #abefc6;
  background: white;
  box-shadow: 0 24px 80px rgba(5, 16, 30, .32);
  text-align: center;
}
.call-popup-card h2 {
  margin: 14px 0 8px;
  font-size: 30px;
  color: var(--primary);
}
.call-popup-card p {
  margin-bottom: 18px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}
.call-popup-timer {
  display: inline-flex;
  justify-content: center;
  min-width: 96px;
  margin-bottom: 18px;
  border-radius: 6px;
  padding: 8px 14px;
  background: #fff4cc;
  color: var(--warning);
  font-size: 22px;
}
.call-popup-timer.expired {
  background: #fee4e2;
  color: var(--danger);
}
.has-call-popup { overflow: hidden; }

@media (max-width: 900px) {
  .sidebar { position: static; width: auto; }
  .content { margin-left: 0; padding: 20px; }
  .grid-form, .admin-grid, .selection-grid, .search-form, .history-filter { grid-template-columns: 1fr; }
  .page-header, .section-title.inline { align-items: flex-start; flex-direction: column; }
  .filter { max-width: 100%; }
}
@media print {
  .sidebar, .content > :not(.admin-grid) { display: none; }
  .content { margin: 0; }
}
