/* Mesbah Voice Lab — dashboard design system. Neutral surfaces, one teal accent, quiet status colours. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e3e8ee;
  --border-strong: #cfd7e0;
  --text: #17212b;
  --text-2: #3d4a57;
  --muted: #6b7785;
  --primary: #0d7c86;
  --primary-hover: #0a6971;
  --primary-soft: #e3f3f4;
  --primary-ring: rgba(13, 124, 134, .25);
  --success: #15803d;
  --success-soft: #e5f5ea;
  --warning: #b45309;
  --warning-soft: #fdf1e1;
  --danger: #c2283a;
  --danger-soft: #fbe9eb;
  --info: #2f5fd0;
  --info-soft: #e8eefb;
  --neutral-soft: #eef1f4;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans Arabic", "Segoe UI Arabic", sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--text); font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh;
  /* the sidebar column keeps its white background and divider for the full page height */
  background: linear-gradient(90deg, var(--surface) 239px, var(--border) 239px, var(--border) 240px, var(--bg) 240px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 8px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.brand b { display: block; font-size: 14.5px; }
.brand small { color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 520; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; color: var(--muted); }
.sidebar-foot .mini-budget { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 28px 14px; flex-wrap: wrap; }
.page-header .subtitle { color: var(--muted); margin-top: 4px; }
.page-body { padding: 0 28px 32px; display: flex; flex-direction: column; gap: 16px; }
.breadcrumb { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { display: none; }
  .page-header, .page-body { padding-left: 16px; padding-right: 16px; }
}

/* ---------- grids ---------- */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
@media (max-width: 1100px) { .grid-main, .grid-2 { grid-template-columns: 1fr; } }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 0; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.card-title { display: flex; align-items: center; gap: 8px; }
.card-title .icon { color: var(--primary); }
.card.accent { border-color: #b9e1e4; background: linear-gradient(180deg, #fbfefe, #fff); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 560; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #a51f30; }
.btn.danger-outline { color: var(--danger); border-color: #efc2c8; }
.btn.danger-outline:hover:not(:disabled) { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--neutral-soft); }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn .icon { width: 17px; height: 17px; }

/* ---------- forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 560; color: var(--text-2); font-size: 13.5px; }
label.field .help { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=number], input[type=date], input:not([type]), select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px; min-height: 38px; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 450; color: var(--text-2); }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); }
.segmented { display: inline-flex; background: var(--neutral-soft); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 6px; font: inherit; font-weight: 560; color: var(--text-2); cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { border: 1.5px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; background: var(--surface); }
.choice:hover { border-color: var(--border-strong); }
.choice.on { border-color: var(--primary); background: var(--primary-soft); }
.choice b { display: block; }
.choice small { color: var(--muted); }
.choice .icon { margin-top: 2px; color: var(--primary); }
@media (max-width: 640px) { .choice-cards { grid-template-columns: 1fr; } }

/* ---------- chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--neutral-soft); color: var(--text-2); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.green { background: var(--success-soft); color: var(--success); }
.chip.amber { background: var(--warning-soft); color: var(--warning); }
.chip.red { background: var(--danger-soft); color: var(--danger); }
.chip.blue { background: var(--info-soft); color: var(--info); }
.chip.teal { background: var(--primary-soft); color: var(--primary); }
.chip.pulse .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- banners ---------- */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.banner .icon { width: 20px; height: 20px; }
.banner.info { background: var(--info-soft); border-color: #cfdbf6; color: #1f3f8f; }
.banner.warn { background: var(--warning-soft); border-color: #f2d4ad; color: #7c3d06; }
.banner.ok { background: var(--success-soft); border-color: #bfe3cb; color: #14532d; }
.banner.danger { background: var(--danger-soft); border-color: #f1c4ca; color: #8a1a29; }
.banner .text { flex: 1; }
.banner .text b { display: block; }

/* ---------- control bar ---------- */
.control-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.session-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.meta .icon { width: 15px; height: 15px; }

/* ---------- composer ---------- */
.composer textarea { font-size: 16px; min-height: 64px; }
.composer .row.top { gap: 10px; }
.samples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.samples .label { color: var(--muted); font-size: 12.5px; margin-right: 2px; }
.sample { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.sample:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.kbd-hint { color: var(--muted); font-size: 12px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 16px; }
.tabs button { border: 0; background: none; padding: 12px 10px 10px; font: inherit; font-weight: 560; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { background: var(--neutral-soft); color: var(--text-2); border-radius: 999px; font-size: 11.5px; padding: 0 7px; }

/* ---------- conversation ---------- */
.feed { display: flex; flex-direction: column; gap: 12px; max-height: 640px; overflow: auto; padding-right: 2px; }
.waiting { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.waiting .title { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.turn { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.turn-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.bubble { max-width: 92%; padding: 9px 12px; border-radius: 12px; line-height: 1.55; unicode-bidi: plaintext; }
.bubble.viewer { background: var(--neutral-soft); align-self: flex-start; border-top-left-radius: 4px; }
.bubble.viewer .who { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.bubble.ai { background: var(--primary-soft); align-self: flex-end; border-top-right-radius: 4px; color: #0b4a50; }
.bubble.ai .who { font-size: 12px; font-weight: 600; color: var(--primary); margin-bottom: 2px; display: flex; gap: 6px; align-items: center; }
.bubble.ai .speech { font-size: 15.5px; }
.bubble.note { background: var(--warning-soft); color: #7c3d06; align-self: stretch; max-width: 100%; font-size: 13.5px; }
.bubble.muted-note { background: var(--surface-2); color: var(--muted); align-self: stretch; max-width: 100%; font-size: 13px; border: 1px dashed var(--border); }
.turn-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .icon { width: 28px; height: 28px; color: #9aa6b2; }

/* ---------- now playing ---------- */
.now { display: flex; align-items: center; gap: 14px; }
.eq { display: flex; gap: 3px; align-items: flex-end; height: 26px; width: 30px; }
.eq span { width: 5px; background: var(--primary); border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.eq span:nth-child(2) { animation-delay: .15s; } .eq span:nth-child(3) { animation-delay: .3s; } .eq span:nth-child(4) { animation-delay: .45s; }
.eq.idle span { animation: none; height: 4px !important; background: var(--border-strong); }
@keyframes eq { 0%, 100% { height: 5px; } 50% { height: 24px; } }
.progress { height: 6px; background: var(--neutral-soft); border-radius: 999px; overflow: hidden; }
.progress > div { width: 0; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.progress.amber > div { background: var(--warning); }
.progress.red > div { background: var(--danger); }

/* ---------- status list ---------- */
.status-line { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #b8c2cc; flex: none; }
.status-dot.green { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.status-dot.amber { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-soft); }
.status-dot.red { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; color: var(--text); overflow-wrap: anywhere; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.checklist li { display: flex; gap: 8px; align-items: flex-start; }
.checklist .icon { width: 16px; height: 16px; margin-top: 2px; }
.checklist .ok { color: var(--success); } .checklist .bad { color: var(--danger); } .checklist .na { color: var(--muted); }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.tile .label { color: var(--muted); font-size: 12px; font-weight: 560; }
.tile .value { font-size: 20px; font-weight: 680; margin-top: 2px; }
.tile .sub { color: var(--muted); font-size: 12px; }
@media (max-width: 800px) { .tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
table.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tr:last-child td { border-bottom: 0; }
table.table tr.clickable { cursor: pointer; }
table.table tr.clickable:hover td { background: var(--surface-2); }
.rtl { unicode-bidi: plaintext; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- helper cards ---------- */
.helper { border: 1px solid #f2d4ad; background: var(--warning-soft); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.helper .q { color: #7c3d06; font-weight: 560; }

/* ---------- toasts & modal ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: 380px; }
.toast { background: #1d2733; color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; animation: slidein .18s ease-out; }
.toast.error { background: #7f1d2a; }
.toast.ok { background: #14532d; }
.toast .icon { margin-top: 1px; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 32, .38); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(460px, 100%); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal p { color: var(--text-2); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

details.more { border-top: 1px solid var(--border); padding-top: 10px; }
details.more summary { cursor: pointer; color: var(--text-2); font-weight: 560; list-style: none; display: flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { margin-bottom: 10px; }
.steps { margin: 0; padding-left: 18px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.code { font-family: var(--mono); font-size: 12.5px; background: var(--neutral-soft); border-radius: 6px; padding: 2px 6px; }
.log { font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; }
.log .item { display: flex; gap: 8px; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.hidden { display: none !important; }
.modal.wide { width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.issues { display: flex; flex-direction: column; gap: 6px; }
.issue { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.issue.blocker { color: var(--danger); }
.issue.warning { color: var(--warning); }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--neutral-soft); }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumbs figure { margin: 0; display: flex; flex-direction: column; gap: 4px; align-items: center; font-size: 12px; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.repeat-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 8px; align-items: start; }
.tab-panel[hidden] { display: none; }
.preview-box { background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; white-space: pre-wrap; }
.filter-bar input, .filter-bar select { width: auto; min-width: 200px; }
.filter-bar input { min-width: 280px; }
.control-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
