/* Atex Desk — Apple-style front end.
   Light scheme only. White / #F5F5F7 backgrounds, #1D1D1F text,
   blue #0071E3 calls to action, system font stack. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f5f5f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --green: #047857;
  --green-bg: #e7f5ee;
  --green-border: #bfe6d2;
  --border: #d2d2d7;
  --danger: #d70015;
  --danger-bg: #fdf0f0;
  --danger-border: #f5c2c0;
  --warn-bg: #fff8e6;
  --warn-border: #e6c200;
  --amber-bg: #fef3c7;
  --amber-text: #92400e;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
  overflow-x: clip;
}

a { color: var(--blue); }

img, video { max-width: 100%; height: auto; }

:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
}

.container.narrow { max-width: 560px; }

.muted { color: var(--muted); }
.center-text { text-align: center; }
.center-vert { padding: 80px 20px; text-align: center; }
.center-row { justify-content: center; }
.loading-text { color: var(--muted); }
.error-text { color: var(--danger); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  background: none;
  color: var(--text);
  white-space: nowrap;
}

.btn-primary { background: var(--blue); color: #ffffff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary { border-color: var(--border); background: #ffffff; }
.btn-secondary:hover { background: var(--bg-soft); }
.btn-ghost { color: var(--blue); padding: 10px 12px; }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-compact { padding: 8px 16px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- forms ---------- */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.field textarea { min-height: 88px; resize: vertical; }

.field-error {
  color: var(--danger);
  font-size: 14px;
  margin: 4px 0 0;
}

.hint { font-size: 14px; color: var(--muted); margin: 6px 0 0; }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav { display: flex; gap: 2px; margin-left: 8px; }

.nav-link {
  background: none;
  border: none;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 8px;
}

.nav-link:hover { background: var(--bg-soft); }

.auth-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-title { font-weight: 600; font-size: 16px; }
.signed-in-as { font-size: 14px; white-space: nowrap; }

/* ---------- hero + live chat ---------- */

.hero { padding: 56px 0 24px; text-align: center; }

.hero h1 {
  font-size: clamp(36px, 6vw, 60px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}

.hero-sub {
  font-size: 20px;
  color: var(--muted);
  max-width: 640px;
  margin: 0 auto 28px;
}

.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.chat-panel {
  max-width: 680px;
  margin: 36px auto 0;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: hidden;
  scroll-margin-top: 72px;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  flex-wrap: wrap;
}

.chat-messages {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  min-height: 180px;
  overflow-y: auto;
}

.bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.bubble-assistant {
  background: var(--bg-soft);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.bubble-user {
  background: var(--blue);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.bubble-user a { color: #ffffff; }

.citations { margin-top: 8px; font-size: 14px; }
.citations a { display: inline-block; margin-right: 10px; }
.typing { color: var(--muted); }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
}

/* ---------- pills + badges ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text);
  white-space: nowrap;
}

.pill-kb,
.pill-active { background: var(--green-bg); color: var(--green); }
.pill-paused { background: var(--amber-bg); color: var(--amber-text); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
}

.badge-unread { background: var(--danger); }
.badge-new { background: var(--blue); }

/* ---------- sections ---------- */

.section { padding: 56px 0; scroll-margin-top: 56px; }
.section-alt { background: var(--bg-soft); }

.section h2 {
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  text-align: center;
}

.section-sub {
  text-align: center;
  color: var(--muted);
  max-width: 640px;
  margin: 0 auto 32px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card h3 { margin: 0 0 8px; font-size: 19px; }
.card p { margin: 0; color: var(--muted); }

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
}

table.data {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

table.data th,
table.data td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.data th { background: var(--bg-soft); font-size: 15px; }
table.data tr:last-child td,
table.data tr:last-child th { border-bottom: none; }

.footnote { font-size: 14px; color: var(--muted); margin-top: 12px; }

/* ---------- pricing / faq / enquiry ---------- */

.pricing-card {
  max-width: 520px;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow);
}

.price-big { font-size: 36px; font-weight: 700; margin: 8px 0; }
.price-note { font-size: 17px; font-weight: 400; }

.faq-list { max-width: 720px; margin: 0 auto; }

.faq-list details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  margin-bottom: 12px;
  padding: 0 20px;
}

.faq-list summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 14px 0;
  list-style: none;
}

.faq-list summary::-webkit-details-marker { display: none; }
.faq-list details p { margin: 0 0 16px; color: var(--muted); }

.copy-box {
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.copy-box p { flex: 1; margin: 0; min-width: 220px; overflow-wrap: anywhere; }
.mono-link { font-size: 14px; }

/* ---------- footer + mobile bar ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 48px;
  margin-top: 24px;
}

.footer-inner {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.footer-inner nav {
  margin-left: auto;
  display: flex;
  gap: 20px;
}

.footer-inner nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.mobile-bar { display: none; }

/* ---------- auth ---------- */

.auth-card {
  max-width: 440px;
  margin: 48px auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-card h1 { margin-top: 0; font-size: 28px; }
.auth-links { margin-top: 20px; font-size: 15px; color: var(--muted); }

/* ---------- banners ---------- */

.banner {
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.banner-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #7a0c0c;
}

.banner-success {
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  color: #065f46;
}

.banner-warning {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: #6b4e00;
}

/* ---------- admin ---------- */

.admin-main { padding-top: 24px; padding-bottom: 64px; }
.admin-head { margin-bottom: 8px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tabs a {
  padding: 10px 16px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs a.active { color: var(--text); border-bottom-color: var(--blue); }

.client-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-wrap: anywhere;
}

.client-card-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.client-card h3 { margin: 0 0 8px; font-size: 19px; }
.client-card h3 a { color: var(--text); text-decoration: none; }
.client-card h3 a:hover { text-decoration: underline; }
.client-card p { margin: 6px 0; }
.client-meta { font-size: 15px; color: var(--muted); }

.detail-head {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.detail-head h2 { margin: 0 0 4px; }
.detail-head p { margin: 4px 0; }

.detail-section {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.detail-section h3 { margin-top: 0; }
.detail-section h4 { margin-bottom: 8px; }

.section-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.section-head h3 { margin: 0; }

.settings-section {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.settings-section h3 { margin-top: 0; }

.kb-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  background: #ffffff;
  overflow-wrap: anywhere;
}

.kb-entry h4 { margin: 0 0 4px; }
.kb-url { font-size: 14px; margin: 0 0 8px; }
.kb-excerpt { color: var(--muted); font-size: 15px; margin: 0; }

.entry-actions,
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.list-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #ffffff;
  overflow-wrap: anywhere;
}

.list-row p { margin: 6px 0; }

.thread-panel {
  border: 2px solid var(--blue);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
  background: #ffffff;
}

.thread-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.thread-head h4 { margin: 0; }

.msg { margin-bottom: 14px; overflow-wrap: anywhere; }
.msg-role { font-weight: 600; font-size: 14px; }
.msg-time { color: var(--muted); font-size: 13px; font-weight: 400; }
.msg-text { margin-top: 2px; }

.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.snippet-box {
  width: 100%;
  min-height: 76px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  resize: vertical;
  margin-bottom: 12px;
}

.billing-message { margin: 14px 0 0; font-size: 15px; min-height: 0; }
.billing-message:empty { margin: 0; }
.billing-success { color: var(--green); }
.billing-error { color: var(--danger); }

.payments-list { margin: 8px 0 0; padding-left: 20px; }
.payments-list li { margin-bottom: 6px; overflow-wrap: anywhere; }

/* ---------- sample clinic page ---------- */

.sample-banner {
  background: var(--green-bg);
  color: #065f46;
  border-bottom: 1px solid var(--green-border);
  padding: 12px 0;
  font-weight: 600;
  text-align: center;
  font-size: 15px;
}

/* ---------- responsive ---------- */

@media (max-width: 767px) {
  .site-nav { display: none; }
  .signed-in-as { display: none; }
  .admin-title { display: none; }
  .section { padding: 40px 0; }
  .hero { padding: 40px 0 16px; }
  .hero-sub { font-size: 18px; }
  .auth-card { margin: 24px auto; padding: 24px; }
  .mobile-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .mobile-bar .btn { flex: 1; padding: 10px 8px; font-size: 15px; }
  .has-mobile-bar { padding-bottom: 84px; }
  body.hide-mobile-bar .mobile-bar { display: none; }
  .chat-messages { max-height: 360px; }
}

@media (max-width: 420px) {
  .container { padding: 0 16px; }
  .auth-actions .btn-compact { padding: 8px 10px; font-size: 15px; }
  .pricing-card { padding: 24px 16px; }
  .price-big { font-size: 30px; }
  .detail-section,
  .settings-section { padding: 16px; }
}
