:root {
  --primary: #1C3988;
  --primary-light: #488BFD;
  --background: #F1F6FC;
  --success: #67C27C;

  --surface: #ffffff;
  --border: #dde6f5;
  --border-strong: #c6d6ef;
  --text: #16233d;
  --text-muted: #64748b;
  --danger: #c2413c;
  --warning: #b7791f;

  --radius: 6px;
  --space: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 12px; }

:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }

/* Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-nav a i { font-size: 17px; width: 18px; flex-shrink: 0; text-align: center; color: var(--text-muted); }
.sidebar-nav a:hover { background: var(--background); text-decoration: none; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-nav a.active i { color: #fff; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 13px; }
.sidebar-foot strong { display: flex; align-items: center; gap: 6px; }
.sidebar-foot .muted { color: var(--text-muted); display: block; word-break: break-all; }

.main { flex: 1; min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.content { padding: 28px; max-width: 1180px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 4px; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 9px 12px; color: var(--text-muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }

/* Forms */
label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=time], input[type=date], input[type=color], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-light); outline: none; box-shadow: 0 0 0 3px rgba(72,139,253,0.15); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; margin: 0; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #162f70; text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--background); color: var(--primary); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e6c3c1; }
.btn-danger:hover { background: #fdf3f2; color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Status */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; border: 1px solid;
}
.badge-confirmed { color: #1f6b39; background: #eaf7ee; border-color: #c6e7d1; }
.badge-cancelled { color: var(--danger); background: #fdf1f0; border-color: #eecac8; }
.badge-rescheduled { color: var(--warning); background: #fdf6e7; border-color: #f0e0bb; }
.badge-completed { color: var(--primary); background: #eaf1ff; border-color: #cadcfb; }
.badge-no_show { color: var(--text-muted); background: #f1f4f9; border-color: var(--border); }

.notice, .error-box {
  padding: 11px 14px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; border: 1px solid;
}
.notice { background: #eaf7ee; border-color: #c6e7d1; color: #1f6b39; }
.error-box { background: #fdf1f0; border-color: #eecac8; color: var(--danger); }

.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty h3 { color: var(--text); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.host-identity { display: flex; align-items: center; gap: 12px; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); }
.host-identity-top { margin-top: 0; padding-top: 0; padding-bottom: 18px; border-top: 0; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.host-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.host-avatar-fallback { display: flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; font-weight: 700; font-size: 16px; }
.stack > * + * { margin-top: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Auth + public pages */
.centered {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 32px 16px; background: var(--background);
}
.panel {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 30px;
}
.panel-wide { max-width: 900px; }
.panel h1 { margin-bottom: 4px; }
.panel .sub { color: var(--text-muted); margin-bottom: 22px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.provider-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px; margin-bottom: 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: #fff; color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer;
}
.provider-btn:hover { background: var(--background); text-decoration: none; color: var(--text); }

.auth-footer {
  padding: 20px 16px; text-align: center; background: var(--background);
  border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted);
}
.auth-footer-links { margin-bottom: 6px; }
.auth-footer-links a { color: var(--text-muted); margin: 0 10px; }
.auth-footer-links a:hover { color: var(--text); }
.auth-footer-brand a { color: var(--primary); font-weight: 600; }

/* Booking page */
.booking-shell {
  max-width: 940px; margin: 32px auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.booking-grid { display: grid; grid-template-columns: 300px 1fr 220px; min-height: 520px; }
.booking-aside { padding: 26px; border-right: 1px solid var(--border); }
.booking-aside .logo { max-height: 40px; margin-bottom: 16px; }
.booking-aside .host { color: var(--text-muted); font-weight: 600; }
.booking-aside h1 { font-size: 20px; margin: 4px 0 12px; }
.booking-meta { list-style: none; padding: 0; margin: 18px 0 0; color: var(--text-muted); font-size: 14px; }
.booking-meta li { margin-bottom: 8px; }
.booking-cal { padding: 26px; border-right: 1px solid var(--border); min-width: 0; }
.booking-slots { padding: 26px 20px; overflow-y: auto; max-height: 560px; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-muted); text-transform: uppercase; padding-bottom: 6px; }
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); border: 1px solid transparent;
  background: none; font-family: inherit; font-size: 14px; color: var(--text-muted); cursor: default;
}
.cal-day.open { background: #eaf1ff; color: var(--primary); font-weight: 600; cursor: pointer; }
.cal-day.open:hover { background: #d8e6ff; }
.cal-day.selected { background: var(--primary); color: #fff; }
.cal-day.empty { visibility: hidden; }

.slot {
  display: block; width: 100%; padding: 10px; margin-bottom: 8px;
  border: 1px solid var(--primary-light); border-radius: var(--radius);
  background: #fff; color: var(--primary); font-weight: 600; font-size: 14px;
  font-family: inherit; cursor: pointer; text-align: center;
}
.slot:hover { background: #eaf1ff; }
.slot.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.confirm-mark {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--success); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 14px;
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 0 0 16px 20px; border-left: 2px solid var(--border); position: relative; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--primary-light);
}
.timeline .time { color: var(--text-muted); font-size: 12px; }

.chart { width: 100%; height: 300px; }

@media (max-width: 900px) {
  .booking-grid { grid-template-columns: 1fr; }
  .booking-aside, .booking-cal { border-right: 0; border-bottom: 1px solid var(--border); }
  .booking-slots { max-height: none; }
}

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar-nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px; }
  .sidebar-nav a { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .content, .topbar { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
