/* natiq dashboard styles — calm and RTL-first: only logical properties (inline/block), light and
   dark themes via prefers-color-scheme, layouts that work down to 360 px. Loaded under
   CSP style-src 'self', so every style lives here (no inline styles anywhere). */

:root {
  color-scheme: light dark;
  --font: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f0f3f6;
  --surface-sunken: #e9edf1;
  --border: #d9dfe6;
  --border-strong: #b8c1cc;
  --text: #1b2330;
  --text-muted: #556171;
  --accent: #0d6b66;
  --accent-hover: #0a5753;
  --accent-soft: #e0f0ee;
  --accent-text: #0b5c58;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-hover: #912018;
  --danger-soft: #fdeceb;
  --on-danger: #ffffff;
  --warning: #8a5300;
  --warning-soft: #fff2d9;
  --success: #17703a;
  --success-soft: #e3f3e8;
  --info: #1b5aa6;
  --info-soft: #e6effa;
  --focus-ring: #2563eb;
  --bubble-customer: #dcefea;
  --bubble-agent: #ffffff;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
  --shadow-md: 0 8px 24px rgb(15 23 42 / 14%);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1318;
    --surface: #151b22;
    --surface-muted: #1a222b;
    --surface-sunken: #10161c;
    --border: #2a3440;
    --border-strong: #3c4856;
    --text: #e4e9ee;
    --text-muted: #9ba7b4;
    --accent: #3fb5ad;
    --accent-hover: #5cc6bf;
    --accent-soft: #10302e;
    --accent-text: #72d1c9;
    --on-accent: #04201e;
    --danger: #f28b82;
    --danger-hover: #f6a39c;
    --danger-soft: #3a1714;
    --on-danger: #2a0c0a;
    --warning: #f0b955;
    --warning-soft: #33260c;
    --success: #74d193;
    --success-soft: #11291a;
    --info: #86b6f2;
    --info-soft: #132439;
    --focus-ring: #7aa7ff;
    --bubble-customer: #143a35;
    --bubble-agent: #1a222b;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-md: 0 8px 28px rgb(0 0 0 / 55%);
  }
}

/* ───────────── base ───────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-block-size: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.5rem;
  line-height: 1.35;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1.1rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0 0 0.6rem;
}

p:last-child {
  margin-block-end: 0;
}

a {
  color: var(--accent-text);
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

img {
  max-inline-size: 100%;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

[tabindex="-1"]:focus {
  outline: none;
}

.muted {
  color: var(--text-muted);
}

.nowrap {
  white-space: nowrap;
}

.sr-only {
  position: absolute !important;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  inset-block-start: -100px;
  z-index: 200;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  inset-block-start: 12px;
}

.noscript {
  max-inline-size: 640px;
  margin: 48px auto;
  padding: 16px;
  text-align: center;
}

/* ───────────── top bar ───────────── */

.topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  background: var(--surface);
  border-block-end: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  max-inline-size: 1200px;
  margin-inline: auto;
  padding: 10px 16px;
}

.brand,
.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  inline-size: 30px;
  block-size: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.tenant {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-inline-size: 0;
}

.tenant-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-name {
  max-inline-size: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.875rem;
}

@media (max-width: 720px) {
  .topbar-inner {
    gap: 8px 12px;
  }

  .tenant {
    order: 10;
    flex-basis: 100%;
  }

  .account-name {
    display: none;
  }

  .account {
    margin-inline-start: auto;
  }

  /* five sections do not fit beside the brand: the nav gets its own row and scrolls sideways */
  .nav {
    order: 5;
    flex-basis: 100%;
    min-inline-size: 0;
    overflow-x: auto;
  }

  .nav-link {
    padding: 6px 10px;
    white-space: nowrap;
  }
}

/* ───────────── page layout ───────────── */

.main {
  max-inline-size: 1200px;
  margin-inline: auto;
  padding: 20px 16px 56px;
}

.main:focus {
  outline: none;
}

.page-head {
  margin-block-end: 16px;
}

.page-title {
  margin: 0;
}

.page-intro {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.page-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-block: 48px;
  text-align: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card + .card {
  margin-block-start: 16px;
}

.stack > .card + .card {
  margin-block-start: 0;
}

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

.card-title {
  margin-block-end: 4px;
}

.card-intro {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-block-end: 16px;
}

@media (max-width: 480px) {
  .main {
    padding-block-start: 14px;
  }

  .card {
    padding: 14px;
  }
}

/* ───────────── buttons ───────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-block-size: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn[aria-busy="true"] {
  cursor: progress;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--accent-text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn-danger {
  background: var(--danger);
  color: var(--on-danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-sm {
  min-block-size: 32px;
  padding: 4px 12px;
  font-size: 0.85rem;
}

.btn-icon {
  inline-size: 32px;
  padding: 0;
  font-size: 1.1rem;
}

.btn-block {
  inline-size: 100%;
}

/* ───────────── forms ───────────── */

input:not([type="checkbox"], [type="radio"], [type="file"]),
select,
textarea {
  inline-size: 100%;
  min-block-size: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea {
  min-block-size: 72px;
  resize: vertical;
  line-height: 1.6;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 0;
  border-color: var(--focus-ring);
}

input:disabled,
select:disabled,
textarea:disabled,
input:read-only:not([type="checkbox"], [type="radio"], [type="file"]) {
  background: var(--surface-muted);
  color: var(--text-muted);
}

input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
  inline-size: 18px;
  block-size: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

input[type="file"] {
  max-inline-size: 100%;
  font: inherit;
}

[aria-invalid="true"] {
  border-color: var(--danger) !important;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-inline-size: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-check {
  justify-content: flex-end;
  padding-block-end: 8px;
}

.field-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.field-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

.counter {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.counter.is-over {
  color: var(--danger);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.form-note {
  margin: 0;
  font-size: 0.85rem;
}

.form-errors {
  padding: 10px 14px;
  border-inline-start: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--text);
  font-size: 0.9rem;
}

.form-errors ul {
  margin: 0;
  padding-inline-start: 20px;
}

/* ───────────── badges, pills, notices ───────────── */

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-neutral,
.pill-neutral {
  border-color: var(--border);
}

.badge-success,
.pill-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning,
.pill-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger,
.pill-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-info,
.pill-info {
  background: var(--info-soft);
  color: var(--info);
}

.pill {
  font-size: 0.82rem;
  padding: 3px 12px;
}

.notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-inline-start-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

.notice-info {
  border-color: var(--info);
  background: var(--info-soft);
}

.notice-warning {
  border-color: var(--warning);
  background: var(--warning-soft);
}

.notice-danger {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.notice-title {
  font-weight: 600;
}

/* ───────────── states, spinner, toasts ───────────── */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 16px;
  color: var(--text-muted);
  text-align: center;
}

.state-empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.state-error .state-title {
  color: var(--danger);
  font-weight: 600;
}

.spinner {
  inline-size: 24px;
  block-size: 24px;
  border: 3px solid var(--border);
  border-block-start-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* top of the screen: at the bottom they would cover the playground composer */
.toasts {
  position: fixed;
  inset-block-start: 12px;
  inset-inline: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  inline-size: 100%;
  max-inline-size: 520px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}

.toast-success {
  background: var(--success);
  color: var(--surface);
}

.toast-error {
  background: var(--danger);
  color: var(--on-danger);
}

.toast-text {
  flex: 1 1 auto;
  margin: 0;
}

.toast-close {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0.85;
}

/* ───────────── dialog ───────────── */

.dialog {
  inline-size: min(560px, calc(100vw - 32px));
  max-block-size: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
}

.dialog-wide {
  inline-size: min(760px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgb(8 12 16 / 55%);
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.dialog-title {
  margin: 0;
  font-size: 1.1rem;
}

.dialog-message {
  margin: 0;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.image-preview {
  max-block-size: 140px;
  inline-size: auto;
  margin-block-start: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: contain;
  background: var(--surface-muted);
}

/* ───────────── login ───────────── */

.login {
  display: grid;
  place-items: center;
  min-block-size: calc(100vh - 120px);
}

.login-card {
  inline-size: min(420px, 100%);
  padding: 28px 24px;
}

.login-brand {
  margin-block-end: 18px;
}

.login-title {
  margin-block-end: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-block-start: 20px;
}

/* ───────────── settings tabs ───────────── */

.tabs {
  display: flex;
  gap: 2px;
  margin-block-end: 20px;
  border-block-end: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 0;
  border-block-end: 3px solid transparent;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  border-block-end-color: var(--accent);
  color: var(--accent-text);
}

.tab:focus-visible {
  outline-offset: -3px;
}

.tab-panel:focus-visible {
  outline-offset: 4px;
}

.tab-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-block-end: 16px;
}

.tab-intro p {
  flex: 1 1 320px;
  margin: 0;
}

/* ───────────── business hours ───────────── */

.hours {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day {
  display: grid;
  grid-template-columns: 96px 90px minmax(0, 1fr);
  align-items: start;
  gap: 8px 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.day.has-error {
  border-color: var(--danger);
}

.day-name {
  padding-block-start: 6px;
  font-weight: 600;
}

.day-toggle {
  padding-block-start: 6px;
}

.day-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-inline-size: 0;
}

.day-closed {
  margin: 0;
  padding-block-start: 6px;
}

.ranges {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.range input[type="time"] {
  inline-size: 130px;
}

.range-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.range-note {
  color: var(--info);
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .day {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .day-body {
    grid-column: 1 / -1;
  }

  .range input[type="time"] {
    inline-size: 112px;
  }
}

/* ───────────── catalog ───────────── */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-block-end: 12px;
}

.toolbar .search {
  flex: 1 1 240px;
}

.toolbar select,
.toolbar .date-input {
  inline-size: auto;
  flex: 0 0 auto;
}

.page-appointments .toolbar {
  justify-content: space-between;
}

.page-appointments .toolbar-actions {
  align-items: center;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-count {
  margin-block-end: 8px;
  font-size: 0.85rem;
}

.import-panel {
  margin-block-end: 16px;
}

.import-result {
  margin-block: 12px;
}

.import-result:empty {
  display: none;
}

.import-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.import-preview {
  max-block-size: 320px;
  overflow: auto;
  margin-block-start: 12px;
}

.error-list {
  max-block-size: 260px;
  margin: 8px 0 0;
  padding-inline-start: 22px;
  overflow: auto;
}

.item-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-inline-size: 0;
}

.item-text {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
}

.item-name {
  font-weight: 600;
}

.item-desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.thumb {
  flex: 0 0 auto;
  inline-size: 40px;
  block-size: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-muted);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.switch {
  cursor: pointer;
}

/* ───────────── tables ───────────── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 10px 12px;
  border-block-end: 1px solid var(--border);
  text-align: start;
  vertical-align: middle;
}

.table thead th {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-block-end: 0;
}

.table tbody tr:hover {
  background: var(--surface-muted);
}

.table tfoot th,
.table tfoot td {
  border-block-start: 2px solid var(--border-strong);
  border-block-end: 0;
  background: var(--surface-muted);
  font-weight: 700;
}

.table .num {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table tr.is-muted .item-name,
.table tr.is-muted td {
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .table-stack thead {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .table-stack,
  .table-stack tbody,
  .table-stack tr,
  .table-stack td {
    display: block;
    inline-size: 100%;
  }

  .table-stack tr {
    padding-block: 8px;
    border-block-end: 1px solid var(--border);
  }

  .table-stack tbody tr:last-child {
    border-block-end: 0;
  }

  .table-stack td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 14px;
    border: 0;
  }

  .table-stack td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
  }

  .table-stack .item-cell {
    justify-content: flex-end;
    text-align: end;
  }
}

/* ───────────── FAQs & policies ───────────── */

.entries {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry,
.entry-add > .entry-form {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.entry-add > .entry-form {
  margin-block-end: 16px;
  border-color: var(--accent);
}

.entry-title {
  margin-block-end: 6px;
}

.entry-body {
  margin: 0;
  white-space: pre-wrap;
}

.entry-actions {
  display: flex;
  gap: 6px;
  margin-block-start: 10px;
}

.entry-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entry-form-title {
  margin: 0;
}

/* ───────────── tone & mode ───────────── */

.options {
  display: grid;
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

.options legend {
  margin-block-end: 8px;
  padding: 0;
}

.option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 2px 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option:has(input:disabled) {
  cursor: default;
}

.option input {
  grid-row: span 2;
  margin-block-start: 3px;
}

.option-title {
  font-weight: 600;
}

.option-desc {
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* ───────────── usage ───────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 12px;
  margin-block-end: 16px;
}

.stat {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-wide {
  grid-column: span 2;
}

@media (max-width: 480px) {
  .stat-wide {
    grid-column: auto;
  }
}

.stat-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.stat-value {
  margin: 2px 0;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-of {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.stat-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.meter {
  display: block;
  inline-size: 100%;
  block-size: 8px;
  margin-block: 8px 4px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-sunken);
  accent-color: var(--accent);
  overflow: hidden;
  appearance: none;
}

.meter::-webkit-progress-bar {
  background: var(--surface-sunken);
  border-radius: 999px;
}

.meter::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

.meter::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.meter.is-high::-webkit-progress-value {
  background: var(--danger);
}

.meter.is-high::-moz-progress-bar {
  background: var(--danger);
}

.usage-table code {
  font-size: 0.8rem;
}

/* ───────────── playground ───────────── */

.pg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  margin-block-end: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.pg-status,
.pg-controls,
.pg-new {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.pg-controls {
  gap: 10px 20px;
}

.chat {
  display: flex;
  flex-direction: column;
  block-size: min(68vh, 720px);
  min-block-size: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  overflow: hidden;
}

.chat-log {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-log:focus-visible {
  outline-offset: -3px;
}

.chat-empty {
  margin: auto;
  max-inline-size: 460px;
  color: var(--text);
  text-align: center;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-inline-size: min(88%, 680px);
}

.msg-customer {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-agent,
.msg-human {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  max-inline-size: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bubble-agent);
  box-shadow: var(--shadow-sm);
}

.msg-customer .bubble {
  border-color: transparent;
  border-end-end-radius: 4px;
  background: var(--bubble-customer);
}

.msg-agent .bubble,
.msg-human .bubble {
  border-end-start-radius: 4px;
}

.msg-human .bubble {
  border-color: var(--info);
}

.msg.is-draft .bubble {
  border-style: dashed;
  border-color: var(--warning);
}

.msg.is-rejected .bubble {
  opacity: 0.6;
}

.msg-customer[data-state="failed"] .bubble {
  outline: 2px solid var(--danger);
}

.bubble-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-block-end: 6px;
}

.msg-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.msg-who {
  font-weight: 600;
}

.msg-status:empty {
  display: none;
}

.msg-system {
  align-self: center;
  max-inline-size: min(92%, 640px);
  padding: 5px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

.msg-system-info {
  border-color: var(--info);
  color: var(--info);
}

.msg-system-warning {
  border-color: var(--warning);
  color: var(--warning);
}

.msg-system-success {
  border-color: var(--success);
  color: var(--success);
}

.draft-actions {
  margin-block-start: 10px;
  padding-block-start: 10px;
  border-block-start: 1px solid var(--border);
}

.draft-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.draft-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-details {
  inline-size: 100%;
  font-size: 0.84rem;
}

.msg-details summary {
  inline-size: fit-content;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}

.details-body {
  margin-block-start: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr));
  gap: 6px;
  margin: 0 0 10px;
}

.details-grid > div {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.details-grid dt {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.details-grid dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.details-subtitle {
  margin-block: 10px 6px;
  font-weight: 600;
}

.warning-list {
  margin: 0 0 8px;
  padding-inline-start: 20px;
}

.tool-calls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tool-call {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tool-call.is-error {
  border-color: var(--danger);
}

.tool-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tool-name {
  font-weight: 700;
}

.tool-label {
  margin: 8px 0 2px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.code {
  max-block-size: 260px;
  margin: 0;
  padding: 8px 10px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots span {
  inline-size: 6px;
  block-size: 6px;
  border-radius: 50%;
  background: currentcolor;
  animation: blink 1.2s infinite ease-in-out both;
}

.dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }

  40% {
    opacity: 1;
  }
}

.group-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 6px 16px;
  border-block-start: 1px solid var(--border);
  background: var(--warning-soft);
  font-size: 0.85rem;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px;
  border-block-start: 1px solid var(--border);
  background: var(--surface);
}

.composer-input {
  flex: 1 1 auto;
  min-block-size: 44px;
  max-block-size: 160px;
  resize: none;
  field-sizing: content;
}

.composer-hint {
  margin: 0;
  padding: 0 12px 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.pg-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 20px;
  margin-block-start: 10px;
  font-size: 0.86rem;
}

.pg-footer p {
  margin: 0;
}

.budget {
  color: var(--text-muted);
}

.budget.is-danger {
  color: var(--danger);
  font-weight: 600;
}

@media (max-width: 480px) {
  .chat {
    block-size: 70vh;
    min-block-size: 360px;
  }

  .msg {
    max-inline-size: 94%;
  }

  .chat-log {
    padding: 12px;
  }
}

/* ───────────── inbox ───────────── */

.inbox {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.inbox-list-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-inline-size: 0;
}

.inbox-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.segment {
  min-block-size: 30px;
  padding: 3px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.segment:hover {
  color: var(--text);
}

.segment[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
}

.inbox-summary {
  margin: 0;
  font-size: 0.82rem;
}

.inbox-list {
  max-block-size: min(74vh, 800px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.inbox-list .state-empty {
  border: 0;
}

.conv-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.conv-list li + li {
  border-block-start: 1px solid var(--border);
}

.conv-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-inline-start: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
}

.conv-item:hover {
  background: var(--surface-muted);
}

.conv-item[aria-current="page"] {
  border-inline-start-color: var(--accent);
  background: var(--accent-soft);
}

.conv-item:focus-visible {
  outline-offset: -3px;
}

.conv-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-inline-size: 0;
}

.conv-name {
  min-inline-size: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-time {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.conv-item-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.conv-channel {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.conv-preview {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.inbox-detail {
  min-inline-size: 0;
}

.conv {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conv-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.conv-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  order: 1;
  min-inline-size: 0;
}

.conv-title {
  margin: 0;
  font-size: 1.1rem;
}

.conv-sub {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  order: 2;
}

.conv-reason {
  flex-basis: 100%;
  order: 3;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.back-link {
  display: none;
  flex-basis: 100%;
  font-size: 0.85rem;
  font-weight: 600;
}

.conv-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  align-items: start;
  gap: 12px;
}

.conv-chat {
  block-size: min(70vh, 760px);
}

.customer-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 0.88rem;
}

.card-subtitle {
  margin: 14px 0 4px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.card-text {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.facts {
  display: grid;
  gap: 4px;
  margin: 0;
}

.fact {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.fact dt {
  color: var(--text-muted);
}

.fact dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: end;
  overflow-wrap: anywhere;
}

.msg-author {
  font-weight: 600;
}

@media (max-width: 1100px) {
  .conv-body {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* narrow screens: the list and the open conversation take turns */
@media (max-width: 860px) {
  .inbox {
    grid-template-columns: minmax(0, 1fr);
  }

  .inbox.has-selection .inbox-list-pane,
  .inbox:not(.has-selection) .inbox-detail {
    display: none;
  }

  .inbox-list {
    max-block-size: none;
  }

  .back-link {
    display: inline-block;
  }
}

/* ───────────── appointments ───────────── */

.period-label {
  margin: 0;
}

.date-input {
  min-block-size: 32px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.sched-body {
  margin-block-start: 12px;
}

.sched-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  align-items: start;
}

.sched-week {
  display: grid;
  gap: 12px;
}

.sched-col,
.sched-day {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.sched-day.is-today {
  border-color: var(--accent);
}

.sched-col-title {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  font-size: 0.95rem;
}

.sched-empty {
  margin: 0;
  font-size: 0.85rem;
}

.bk {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--success);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.bk-pending {
  border-inline-start-color: var(--warning);
}

.bk-cancelled,
.bk-done,
.bk-no_show {
  border-inline-start-color: var(--border-strong);
  opacity: 0.8;
}

.bk.is-highlighted {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.bk-top {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.bk-time {
  font-weight: 700;
}

.bk-service,
.bk-customer,
.bk-meta,
.bk-notes {
  margin: 0;
  overflow-wrap: anywhere;
}

.bk-meta {
  font-size: 0.8rem;
}

.bk-notes {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  font-size: 0.85rem;
}

.bk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ───────────── orders ───────────── */

.segmented-wrap {
  margin-block: 8px 12px;
}

.split {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(0, 3fr);
  gap: 16px;
  align-items: start;
}

.order-items-list,
.closures,
.mini-list,
.bell-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.order-items-list {
  display: grid;
  gap: 6px;
}

.order-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.order-row:hover,
.order-row.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.order-number,
.order-total {
  font-weight: 700;
}

.order-who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-time {
  grid-column: 1 / -1;
  font-size: 0.8rem;
}

.order-card .row-actions {
  margin-block-start: 12px;
}

@media (max-width: 860px) {
  .split {
    grid-template-columns: 1fr;
  }
}

/* ───────────── booking setup ───────────── */

.closures {
  display: grid;
  gap: 6px;
}

.closure {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.closure .btn {
  margin-inline-start: auto;
}

.checks {
  max-block-size: 220px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ───────────── customer card: bookings and orders ───────────── */

.mini-list {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
}

/* ───────────── bell ───────────── */

.bell-wrap {
  position: relative;
}

.bell {
  position: relative;
}

.bell-count {
  min-inline-size: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: var(--on-danger);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.bell-panel {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 30;
  inline-size: min(360px, 92vw);
  max-block-size: 70vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.bell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-block-end: 1px solid var(--border);
}

.bell-item {
  display: grid;
  gap: 2px;
  inline-size: 100%;
  padding: 8px 12px;
  border: 0;
  border-block-end: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.bell-item:hover {
  background: var(--surface-muted);
}

.bell-item.is-unread {
  background: var(--accent-soft);
}

.bell-type {
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
}

.bell-title {
  font-weight: 600;
}

.bell-body,
.bell-time {
  font-size: 0.8rem;
}

.bell-empty {
  padding: 12px;
}

/* ───────────── motion ───────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
