:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --card: rgba(255, 255, 255, .92);
  --text: #111b3d;
  --muted: #64708f;
  --line: #dce3f2;
  --primary: #111f80;
  --primary-2: #ef4b8d;
  --primary-soft: rgba(93, 116, 242, .12);
  --danger: #b91c1c;
  --success: #166534;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }

.page-bubbles { display: none; }
.page-bubbles__orb { position: absolute; width: 180px; height: 180px; border-radius: 999px; background: rgba(244,72,141,.18); filter: blur(1px); }
.page-bubbles__orb--1 { right: -52px; top: 60px; }
.page-bubbles__orb--2 { left: -80px; bottom: 15%; background: rgba(31,47,191,.10); }
.page-bubbles__ring { position: absolute; width: 240px; height: 240px; border: 34px solid rgba(95,116,242,.10); border-radius: 999px; right: 12%; bottom: -120px; }
.app-shell { position: relative; z-index: 1; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(210, 218, 236, .86);
}
.topbar__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; color: var(--primary); }
.brand-logo img { width: 78px; height: 34px; object-fit: contain; }
.nav { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.nav a {
  text-decoration: none;
  padding: 9px 13px;
  border-radius: 999px;
  color: #1c2a78;
  font-weight: 650;
}
.nav a.is-active { color: var(--primary); background: rgba(93, 116, 242, .12); }

.container { max-width: 1240px; margin: 0 auto; padding: 24px 18px 56px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(26px, 3vw, 36px); line-height: 1.05; margin-bottom: 8px; }
h2 { font-size: 20px; }
.muted { color: var(--muted); }
.stack, .settings-form { display: grid; gap: 14px; }

.card, .modal-card, .login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 45px rgba(21, 31, 80, .07);
  padding: 18px;
}
.login-panel { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.login-card { width: min(420px, 100%); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-weight: 650;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-ghost { background: transparent; }
.btn-small { min-height: 32px; padding: 0 12px; }
.actions-inline, .filters-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.service-form { display: grid; grid-template-columns: 170px minmax(240px, 1fr) 140px 120px 110px auto; gap: 10px; align-items: end; }
.table-input { min-height: 36px; border-radius: 12px; padding: 7px 10px; }
.checkbox-row { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; color: var(--text); }
.checkbox-row span { margin: 0; color: var(--text); font-size: 14px; font-weight: 650; }
.input, select, textarea {
  width: 100%;
  border: 1px solid rgba(95,116,242,.32);
  border-radius: 16px;
  min-height: 44px;
  padding: 10px 14px;
  background: rgba(255,255,255,.86);
  color: var(--text);
}
.input.is-required-alert {
  border-color: rgba(185,28,28,.72);
  background: rgba(254,242,242,.96);
  box-shadow: 0 0 0 3px rgba(185,28,28,.08);
}
label span { display: block; margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
label.is-required-alert span { color: var(--danger); }
.alert { margin-bottom: 14px; padding: 12px 16px; border-radius: 14px; background: var(--primary-soft); }
.alert-error { background: rgba(185,28,28,.12); color: var(--danger); }

.kanban { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { min-width: 240px; min-height: 520px; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 18px; padding: 12px; }
.kanban-column.is-drop-target { outline: 2px solid rgba(17,31,128,.24); outline-offset: 2px; background: rgba(255,255,255,.92); }
.kanban-column header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.kanban-column h2 { margin: 0; }
.kanban-list { display: grid; gap: 10px; align-content: start; min-height: 440px; }
.lead-card {
  width: 100%;
  display: grid;
  gap: 5px;
  text-align: left;
  border: 1px solid rgba(95,116,242,.20);
  border-radius: 14px;
  background: #fff;
  padding: 13px;
  color: var(--text);
  cursor: pointer;
}
.lead-card[draggable="true"] { cursor: grab; }
.lead-card.is-dragging { opacity: .45; }
.lead-card:hover { border-color: var(--primary); box-shadow: 0 12px 26px rgba(31,47,191,.10); }
.lead-card span, .lead-card small { color: var(--muted); }

.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; font-weight: 750; font-size: 13px; }
.badge-muted { background: rgba(95,116,242,.12); color: #26306f; }
.badge-primary { background: var(--primary); color: #fff; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(12,18,48,.38);
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal-backdrop[hidden] {
  display: none !important;
}
.modal-card { width: min(760px, 100%); max-height: 92vh; overflow: auto; background: #fff; border-radius: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.modal-close { border: 0; background: var(--primary-soft); border-radius: 50%; width: 36px; height: 36px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.wide { grid-column: 1 / -1; }

.month-tabs {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.month-tabs__list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: thin;
}
.month-tab,
.month-tabs__year {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: #1c2a78;
  text-decoration: none;
  font-weight: 650;
  white-space: nowrap;
}
.month-tab.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.month-tabs__year { color: var(--muted); }
.booking-calendar { display: grid; gap: 10px; }
.booking-calendar--month {
  grid-template-columns: 1fr;
  align-items: stretch;
}
.booking-day {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 36px;
  gap: 10px 14px;
  align-items: start;
  padding: 10px 12px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.82);
}
.booking-day.is-today { border-color: var(--primary-2); box-shadow: 0 10px 24px rgba(239,75,141,.10); }
.booking-day.is-closed {
  border-color: rgba(185,28,28,.28);
  background: rgba(254,242,242,.92);
}
.booking-day.is-drop-target { outline: 2px solid rgba(17,31,128,.28); outline-offset: 2px; }
.booking-day.is-drop-blocked { outline: 2px solid rgba(185,28,28,.42); outline-offset: 2px; }
.booking-day__header {
  display: contents;
  color: var(--muted);
}
.booking-day__header > div:first-child {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: grid;
  gap: 2px;
  align-content: start;
  padding-top: 3px;
}
.booking-day__header strong { color: var(--text); font-size: 18px; }
.booking-day__header small { color: var(--muted); }
.booking-day__closed {
  grid-column: 2;
  grid-row: 2;
  display: inline-flex;
  width: fit-content;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(185,28,28,.12);
  color: var(--danger);
  font-size: 13px;
  font-weight: 750;
}
.booking-day__list {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: grid;
  gap: 6px;
  align-content: start;
}
.booking-day__empty {
  min-height: 36px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}
.day-menu {
  grid-column: 3;
  grid-row: 1;
  position: relative;
  display: inline-flex;
  justify-self: end;
}
button.day-menu__trigger {
  appearance: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}
button.day-menu__trigger:hover,
button.day-menu__trigger:focus-visible {
  background: var(--primary-soft);
  color: var(--primary);
  outline: none;
}
.day-menu__content {
  position: absolute;
  right: 0;
  top: 38px;
  z-index: 12;
  width: 190px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(21, 31, 80, .16);
}
.day-menu__content[hidden] { display: none !important; }
.day-menu__content button {
  appearance: none;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.day-menu__content button:hover { background: var(--primary-soft); }
.day-menu__content button:disabled { opacity: .45; cursor: default; }
.day-menu__content form { margin: 0; }
.booking-row {
  min-height: 42px;
  width: 100%;
  border: 1px solid rgba(95,116,242,.20);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(120px, .8fr) minmax(180px, 1.4fr);
  gap: 10px;
  align-items: center;
  cursor: pointer;
}
.booking-row[draggable="true"] { cursor: grab; }
.booking-row.is-dragging { opacity: .45; }
.booking-row:hover { border-color: var(--primary); box-shadow: 0 10px 22px rgba(31,47,191,.10); }
.booking-row span, .booking-row small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.70);
  color: var(--muted);
}
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.detail-grid div { padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.detail-grid span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat-card { background: #26306f; color: #fff; border-radius: 18px; padding: 20px; }
.stat-card span { opacity: .8; }
.stat-card strong { display: block; font-size: 42px; margin-top: 8px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 40px; gap: 10px; align-items: center; margin: 12px 0; }
.bar-row b { display: block; max-width: 100%; height: 12px; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }

.chat-page { display: grid; gap: 14px; }
.chat-list { max-height: 58vh; overflow: auto; display: grid; gap: 10px; }
.chat-message { padding: 12px; border-radius: 16px; background: var(--primary-soft); }
.chat-message.is-external { background: rgba(244,72,141,.14); }
.chat-message small { color: var(--muted); }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.staff-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  min-width: 76px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: #26306f;
  color: #fff;
  box-shadow: 0 14px 36px rgba(17, 31, 128, .22);
  font-weight: 800;
  cursor: pointer;
}
.staff-chat-launcher__badge {
  margin-left: 6px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--primary-2);
  color: #fff;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.staff-chat {
  position: fixed;
  right: 24px;
  bottom: 80px;
  z-index: 79;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 22px 70px rgba(21, 31, 80, .18);
  overflow: hidden;
}
.staff-chat.is-collapsed { display: none; }
.staff-chat__header {
  min-height: 48px;
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.staff-chat__collapse {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--text);
  cursor: pointer;
}
.staff-chat__messages {
  padding: 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.staff-chat__message {
  align-self: flex-start;
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  background: #eef2ff;
}
.staff-chat__message--external {
  background: rgba(239, 75, 141, .13);
}
.staff-chat__message-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.staff-chat__message-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.staff-chat__composer {
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.staff-chat__input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 12px;
}
.staff-chat__send {
  min-width: 44px;
  width: 44px;
  padding: 0;
}
.staff-chat__empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 8px;
}

@media (max-width: 900px) {
  .topbar__inner, .page-head { flex-direction: column; align-items: stretch; }
  .kanban, .stats-grid, .two-col { grid-template-columns: 1fr; }
  .month-tabs { grid-template-columns: 1fr; }
  .month-tabs__year { display: none; }
  .booking-day { grid-template-columns: 72px minmax(0, 1fr) 36px; gap: 8px; }
  .booking-day__list { grid-column: 1 / -1; grid-row: 3; }
  .booking-day__closed { grid-column: 1 / -1; }
  .booking-row { grid-template-columns: 1fr; gap: 2px; min-height: 58px; }
  .service-form { grid-template-columns: 1fr; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
}
