:root {
  color-scheme: light;
  --ink: #182b2f;
  --muted: #637579;
  --line: #d8e2df;
  --brand: #0d675f;
  --brand-2: #10504c;
  --accent: #cc5c37;
  --bg: #f3f7f5;
  --panel: #ffffff;
  --soft: #edf5f2;
  --warn: #8b5a05;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; }
button, input, select, textarea { font: inherit; }
.topbar {
  min-height: 64px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2;
  backdrop-filter: blur(12px);
}
.topbar strong { font-size: 18px; color: var(--brand-2); }
.topbar nav { display: flex; gap: 16px; align-items: center; }
.topbar a { color: var(--brand); text-decoration: none; font-weight: 800; }
.layout { max-width: 1220px; margin: 0 auto; padding: 26px; }
.dashboard { display: grid; gap: 18px; }
.hero {
  min-height: 260px; display: flex; align-items: flex-end; padding: 34px; color: #fff;
  background: linear-gradient(130deg, rgba(17,97,90,.94), rgba(20,64,62,.78)), url('https://images.unsplash.com/photo-1584515933487-779824d29309?auto=format&fit=crop&w=1400&q=80') center/cover;
}
.hero span { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 800; }
.hero h1 { max-width: 720px; margin: 8px 0; font-size: clamp(32px, 5vw, 56px); line-height: 1; letter-spacing: 0; }
.hero p { max-width: 650px; margin: 0; font-size: 18px; color: rgba(255,255,255,.9); }
.filters { margin: 18px 0 0; display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; align-items: end; }
label { display: grid; gap: 6px; font-weight: 800; color: var(--ink); }
label, small { line-height: 1.35; }
select, input, textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--line); padding: 0 12px; background: #fff; color: var(--ink);
  border-radius: 8px; outline: none;
}
textarea { padding: 12px; resize: vertical; min-height: 118px; }
select:focus, input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13,103,95,.12); }
button {
  min-height: 44px; border: 0; border-radius: 8px; padding: 0 16px; background: var(--brand); color: #fff; font-weight: 900; cursor: pointer;
  box-shadow: 0 8px 18px rgba(13, 103, 95, .16);
}
button:hover, .button-link:hover { background: var(--brand-2); }
.tabs {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 6px; margin: 0;
  background: #eaf2ef; border: 1px solid var(--line); border-radius: 10px;
}
.tabs a {
  padding: 10px 13px; color: var(--muted); text-decoration: none; font-weight: 900; border-radius: 8px;
}
.tabs a.active { color: var(--brand-2); background: #fff; box-shadow: 0 2px 10px rgba(24,43,47,.08); }
.tabs a.attention-tab { color: #9b321d; background: #fff1eb; }
.compact { grid-template-columns: minmax(180px, 280px) auto; justify-content: start; }
.slots { display: grid; gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 0 0 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.bulk-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.slot {
  display: grid; grid-template-columns: minmax(96px, auto) minmax(0, 1fr) auto auto; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px;
  box-shadow: 0 1px 2px rgba(24,43,47,.04);
}
.slot strong { display: block; font-size: 17px; color: var(--ink); }
.slot span, .slot small, .slot-time em { display: block; color: var(--muted); font-style: normal; }
.slot-time { text-align: right; min-width: 160px; }
.slot-time b { display: block; color: var(--accent); }
.empty, .result {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; color: var(--muted);
  box-shadow: 0 1px 2px rgba(24,43,47,.04);
}
.empty h1, .empty h2, section h2 { margin: 0 0 8px; color: var(--ink); }
.result { border-color: #bfdfd5; background: #edf8f4; color: #14594d; font-weight: 800; }
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.setup-card {
  display: grid; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
  box-shadow: 0 1px 2px rgba(24,43,47,.04);
}
.setup-card small { color: var(--muted); }
.profile-form { display: grid; gap: 10px; }
.family-list { display: grid; gap: 6px; padding: 10px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; }
.check { display: flex; grid-template-columns: none; align-items: center; gap: 8px; color: var(--muted); }
.check input { min-height: auto; }
.slot-check { font-size: 13px; white-space: nowrap; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.support-form { display: grid; gap: 12px; max-width: 720px; }
.support-shell {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 70vh;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #f0f4f2;
  box-shadow: 0 14px 34px rgba(24,43,47,.08);
}
.support-shell.attention { border-color: #e18866; box-shadow: 0 0 0 3px rgba(204,92,55,.12), 0 14px 34px rgba(24,43,47,.08); }
.support-list { background: #fff; border-right: 1px solid var(--line); overflow: auto; max-height: 76vh; }
.support-list-head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center;
  padding: 14px; background: #fff; border-bottom: 1px solid var(--line);
}
.support-list-head strong { color: var(--ink); }
.support-list-head small, .empty-support { color: var(--muted); }
.support-list a {
  position: relative; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 13px 14px; color: var(--ink); text-decoration: none; border-bottom: 1px solid #eef3f1;
}
.support-list a.active { background: #e9f5f1; }
.support-list a.has-unread { background: #fff1eb; }
.support-list a.has-unread::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.support-list span, .support-list small, .support-list time { display: block; color: var(--muted); font-size: 12px; }
.support-list em {
  min-width: 22px; min-height: 22px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-style: normal; font-weight: 900;
}
.chat-avatar {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 999px;
  background: var(--brand); color: #fff; font-weight: 900;
}
.chat-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.chat-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.danger-button { background: #b53a24; box-shadow: 0 8px 18px rgba(181,58,36,.16); }
.danger-button:hover { background: #8f2e1d; }
.chat-head span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.chat-head strong { display: block; font-size: 18px; color: var(--ink); }
.chat-messages {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; overflow: auto;
  background: linear-gradient(180deg, #eef5f2, #f8fbfa);
}
.chat-message {
  max-width: min(620px, 86%); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; box-shadow: 0 1px 2px rgba(24,43,47,.04);
}
.chat-message.admin { align-self: flex-end; background: #dcf4ea; border-color: #c2e8d9; }
.chat-message.cliente { align-self: flex-start; }
.chat-message.unread-client-message { border-color: #e18866; box-shadow: 0 0 0 2px rgba(204,92,55,.12); }
.chat-message p { margin: 0; white-space: pre-wrap; }
.chat-message small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.chat-form {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; padding: 12px;
  background: #fff; border-top: 1px solid var(--line);
}
.chat-form textarea { min-height: 54px; }
.empty-support { padding: 14px; margin: 0; }
.button-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; border-radius: 8px;
  color: #fff; background: var(--brand); text-decoration: none; font-weight: 900;
}
.webhook-summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 0 0 12px; color: var(--muted);
}
.webhook-summary a { color: var(--brand); font-weight: 800; text-decoration: none; }
.webhook-logs { display: grid; gap: 12px; }
.webhook-log {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 10px;
}
.webhook-log-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.webhook-log strong, .webhook-log span { display: block; }
.webhook-log span, .webhook-log p { color: var(--muted); margin: 4px 0 0; }
.badge {
  min-width: 78px; text-align: center; padding: 5px 8px; font-style: normal; font-size: 12px; font-weight: 900;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #f8fbfa;
}
.badge.ok { color: #0c6d51; background: #eaf7f1; border-color: #c9eadc; }
.badge.warning { color: #8b5a05; background: #fff7df; border-color: #f4dda1; }
.badge.danger { color: #a33a24; background: #fff0ec; border-color: #f0c8bd; }
.webhook-log details { border-top: 1px solid var(--line); padding-top: 10px; }
.webhook-log summary { cursor: pointer; color: var(--brand); font-weight: 800; }
.webhook-log pre {
  max-height: 320px; overflow: auto; margin: 10px 0 0; padding: 12px;
  background: #0f2523; color: #edf7f4; font-size: 12px; line-height: 1.5;
}
dialog { border: 0; padding: 0; width: min(520px, calc(100vw - 28px)); }
dialog::backdrop { background: rgba(11, 32, 30, .55); }
dialog form { display: grid; gap: 14px; padding: 22px; background: #fff; }
dialog h2 { margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.actions button:first-child { background: #eef4f2; color: var(--ink); }
@media (max-width: 760px) {
  .layout { padding: 14px; }
  .topbar { padding: 12px 14px; align-items: flex-start; }
  .topbar, .topbar nav { display: grid; }
  .hero { min-height: 320px; padding: 22px; }
  .filters, .slot, .compact { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tabs a { white-space: nowrap; }
  .webhook-log-head { display: grid; }
  .slot-time { text-align: left; }
  .inline-form { display: grid; }
  .support-shell, .chat-form { grid-template-columns: 1fr; }
  .support-list { max-height: 300px; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-message { max-width: 94%; }
}
