/* Boutique Residence admin - Hebrew RTL, light and dark */
:root {
  --bg: #f6f2ec; --panel: #ffffff; --panel-2: #fbf9f6; --ink: #1f1c19; --ink-2: #4b4640; --muted: #857d74;
  --line: #e7e0d6; --line-2: #d9d0c4; --accent: #8a6a43; --accent-2: #a7835a; --accent-soft: #f1e8dc; --on-accent: #fff;
  --ok: #2f7d4f; --ok-soft: #e3f2e8; --warn: #9a6400; --warn-soft: #fbf0d9; --bad: #b3322c; --bad-soft: #fbe5e3;
  --info: #2d5f9a; --info-soft: #e4edf8; --idle: #6d6760; --idle-soft: #efebe6;
  --wa-in: #ffffff; --wa-out: #e7f5dd; --wa-bg: #efe9e1;
  --radius: 14px; --radius-sm: 9px; --shadow: 0 1px 2px rgba(31, 28, 25, .05), 0 6px 20px rgba(31, 28, 25, .06);
  --font: "Heebo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151311; --panel: #1e1b18; --panel-2: #23201c; --ink: #f3eee8; --ink-2: #d4ccc2; --muted: #9c948a;
    --line: #34302b; --line-2: #443e37; --accent: #c9a571; --accent-2: #d8b88a; --accent-soft: #2e271e; --on-accent: #1d1a16;
    --ok: #74c493; --ok-soft: #1c2e22; --warn: #e3b25a; --warn-soft: #33291a; --bad: #f08a83; --bad-soft: #3a201e;
    --info: #8db7ea; --info-soft: #1c2736; --idle: #a8a097; --idle-soft: #2a2622;
    --wa-in: #26221e; --wa-out: #24331f; --wa-bg: #1a1714;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: plaintext; text-align: left; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--panel); border-inline-start: 0; border-inline-end: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font: 600 15px Georgia, serif; letter-spacing: .02em; }
.brand-name { font-weight: 600; line-height: 1.15; }
.brand-name small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--ink); }
.nav .ico { width: 20px; text-align: center; opacity: .85; }
.nav .count { margin-inline-start: auto; background: var(--accent); color: var(--on-accent); border-radius: 999px; font-size: 12px; padding: 0 7px; min-width: 20px; text-align: center; }
.side-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.main { padding: 22px 28px 90px; min-width: 0; }
.topbar { display: none; }
.tabbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 14px 14px 96px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 30; }
  .tabbar a { display: grid; justify-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; position: relative; }
  .tabbar a.on { color: var(--accent); }
  .tabbar .ico { font-size: 18px; line-height: 1; }
  .tabbar .dot { position: absolute; top: 2px; inset-inline-end: 22%; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; line-height: 1.2; margin: 0; font-weight: 600; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 14px; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }

/* ---------- surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.flat { box-shadow: none; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .v { font-size: 26px; font-weight: 600; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.kpi.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.banner { border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; border: 1px solid; font-size: 14px; }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--ink); }
.banner.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.banner.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.banner.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

/* ---------- lists */
.list { display: grid; }
.item { display: flex; gap: 12px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--line); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item.click { cursor: pointer; border-radius: 10px; padding-inline: 8px; }
.item.click:hover { background: var(--panel-2); }
.item .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel-2); }
.tbl-wrap { overflow-x: auto; }
@media (max-width: 860px) {
  .tbl.cards thead { display: none; }
  .tbl.cards tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
  .tbl.cards td { border: 0; padding: 0; }
  .tbl.cards td[data-hide-sm] { display: none; }
}

/* ---------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 9px; font-size: 12.5px; font-weight: 500; white-space: nowrap; background: var(--idle-soft); color: var(--idle); border: 1px solid transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.outline { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.dot-ok::before, .dot-bad::before, .dot-warn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-ok::before { background: var(--ok); } .dot-bad::before { background: var(--bad); } .dot-warn::before { background: var(--warn); }

/* ---------- forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 30px; padding: 3px 10px; font-size: 13px; border-radius: 8px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); outline: none; }
textarea.input { min-height: 90px; resize: vertical; line-height: 1.55; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.bad { border-color: var(--bad); }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.errors { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.errors li { color: var(--bad); font-size: 13.5px; }
.errors li.w { color: var(--warn); }

/* ---------- chat */
.chat { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); height: calc(100vh - 140px); min-height: 480px; }
.chat-list { border-inline-end: 1px solid var(--line); overflow-y: auto; }
.chat-list .item { padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.chat-list .item.on { background: var(--accent-soft); }
.chat-pane { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-body { overflow-y: auto; padding: 18px 16px; background: var(--wa-bg); display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: min(78%, 560px); padding: 8px 12px 6px; border-radius: 12px; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); white-space: pre-wrap; word-break: break-word; }
.bubble.in { background: var(--wa-in); align-self: flex-start; border-start-start-radius: 4px; }
.bubble.out { background: var(--wa-out); align-self: flex-end; border-start-end-radius: 4px; }
.bubble.tpl { background: var(--panel-2); border: 1px dashed var(--line-2); align-self: flex-end; color: var(--ink-2); font-size: 14px; }
.bubble .meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; justify-content: flex-end; }
.chat-foot { border-top: 1px solid var(--line); padding: 10px; display: grid; gap: 8px; background: var(--panel); }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); border-radius: 999px; padding: 2px 10px; }
@media (max-width: 860px) {
  .chat { grid-template-columns: 1fr; height: auto; min-height: 0; border: 0; background: transparent; }
  .chat.has-open .chat-list { display: none; }
  .chat:not(.has-open) .chat-pane { display: none; }
  .chat-pane { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: calc(100vh - 190px); background: var(--panel); }
  .chat-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
}

/* ---------- timeline */
.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl:last-child { border-bottom: 0; }
.tl .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; background: var(--idle-soft); color: var(--idle); }
.tl.sent .n { background: var(--ok-soft); color: var(--ok); }
.tl.due .n, .tl.scheduled .n { background: var(--info-soft); color: var(--info); }
.tl.blocked .n, .tl.failed .n { background: var(--bad-soft); color: var(--bad); }
.tl.waiting .n { background: var(--warn-soft); color: var(--warn); }

/* ---------- messages editor */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip code { font-family: var(--mono); color: var(--accent); margin-inline-end: 4px; }
.lang-chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; background: var(--panel-2); cursor: pointer; font-size: 13.5px; }
.lang-chip:hover { border-color: var(--accent); text-decoration: none; }
.wa-preview { background: var(--wa-bg); border-radius: var(--radius); padding: 16px; }
.wa-preview .bubble { max-width: 100%; }
.wa-btn { display: block; text-align: center; color: var(--info); border-top: 1px solid var(--line); padding: 7px 0 2px; font-weight: 500; font-size: 14px; }
textarea.input.editor-text { font-family: var(--font); font-size: 15px; min-height: 240px; }

/* ---------- modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(20, 17, 14, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: var(--radius); width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal h2 { margin-bottom: 12px; }
.toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; display: grid; gap: 8px; z-index: 60; }
@media (max-width: 860px) { .toasts { bottom: 84px; inset-inline: 12px; } }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 420px; font-size: 14px; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(420px, 100%); padding: 26px; }
.auth h1 { font-size: 22px; margin: 6px 0 4px; }

.secret { display: flex; gap: 8px; align-items: center; }
.secret code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-family: var(--mono); font-size: 13px; direction: ltr; overflow-x: auto; white-space: nowrap; flex: 1; min-width: 0; }
.photo { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); display: block; }
.step-edit { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 700px) { .step-edit { grid-template-columns: 1fr; } }
