:root {
    --lf-accent: #2456d6;
    --lf-accent-soft: #e8eefc;
    --lf-ink: #1c2230;
    --lf-muted: #697386;
    --lf-line: #e3e7ee;
    --lf-bg: #f5f7fa;
    --lf-card: #ffffff;
    --lf-ok: #1f8a4c;
    --lf-warn: #b7791f;
    --lf-bad: #c53030;
    --lf-merge-bg: #fff4d6;
    --lf-merge-missing: #fde2e2;
    --bs-primary: var(--lf-accent);
    --bs-link-color: var(--lf-accent);
    --bs-link-color-rgb: 36, 86, 214;
}

html, body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--lf-bg);
    color: var(--lf-ink);
}

h1:focus { outline: none; }

.btn-primary { --bs-btn-bg: var(--lf-accent); --bs-btn-border-color: var(--lf-accent); --bs-btn-hover-bg: #1c46b3; --bs-btn-hover-border-color: #1c46b3; --bs-btn-active-bg: #173b96; }
.btn-outline-primary { --bs-btn-color: var(--lf-accent); --bs-btn-border-color: var(--lf-accent); --bs-btn-hover-bg: var(--lf-accent); --bs-btn-hover-border-color: var(--lf-accent); }
.text-muted, .form-text { color: var(--lf-muted) !important; }

/* ---------- Top nav ---------- */
.app-nav { background: #111827; padding: .35rem 0; }
.app-nav .navbar-brand { color: #fff; font-weight: 700; letter-spacing: .01em; }
.app-nav .navbar-brand i { color: #7aa2ff; }
.app-nav .nav-link { color: #c7cfdd; padding: .45rem .7rem; border-radius: .4rem; }
.app-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.app-nav .nav-link.active { color: #fff; background: rgba(122,162,255,.18); }
.app-nav .navbar-toggler { color: #fff; cursor: pointer; }
.app-nav form { margin: 0; }
@media (max-width: 767.98px) {
    .app-nav-collapse { display: none; width: 100%; padding: .5rem 0; }
    #nav-toggle:checked ~ .app-nav-collapse { display: block; }
}

.app-main { padding: 1.25rem 1.5rem 3rem; max-width: 1400px; margin: 0 auto; }
.app-main.full { max-width: none; padding: 0; }
@media (max-width: 575.98px) { .app-main { padding: 1rem .75rem 2rem; } }

/* ---------- Page chrome ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.card { border: 1px solid var(--lf-line); border-radius: .75rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); background: var(--lf-card); }
.card-header { background: transparent; border-bottom: 1px solid var(--lf-line); font-weight: 600; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--lf-muted); font-weight: 600; border-bottom-width: 1px; }
.table-hover tbody tr:hover { --bs-table-hover-bg: #f7f9fc; }

.stat { padding: 1rem 1.1rem; }
.stat .label { font-size: .8rem; color: var(--lf-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .85rem; color: var(--lf-muted); }

.progress-thin { height: .45rem; border-radius: 1rem; background: #edf0f5; }
.badge-soft { background: var(--lf-accent-soft); color: var(--lf-accent); font-weight: 600; }
.status-pill { display: inline-block; padding: .15rem .55rem; border-radius: 1rem; font-size: .75rem; font-weight: 600; background: #eef1f5; color: #475467; }
.status-pill.ok { background: #e3f5ea; color: var(--lf-ok); }
.status-pill.warn { background: #fdf3e1; color: var(--lf-warn); }
.status-pill.bad { background: #fde8e8; color: var(--lf-bad); }
.status-pill.info { background: var(--lf-accent-soft); color: var(--lf-accent); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--lf-muted); }
.empty i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .6; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.code-block { background: #0f172a; color: #e2e8f0; border-radius: .5rem; padding: .85rem 1rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; white-space: pre; overflow-x: auto; }

/* ---------- Script rendering ---------- */
.script-view { font-size: 1.08rem; line-height: 1.7; white-space: pre-line; overflow-wrap: anywhere; }
.script-view .merge { background: var(--lf-merge-bg); border-radius: .25rem; padding: 0 .2rem; font-weight: 600; }
.script-view .merge.missing { background: var(--lf-merge-missing); color: var(--lf-bad); }
.script-question { display: block; white-space: normal; margin: .35rem 0 .6rem; padding: .6rem .8rem; background: #f7f9fc; border: 1px solid var(--lf-line); border-left: 3px solid var(--lf-accent); border-radius: .5rem; font-size: .98rem; line-height: 1.4; }
.script-question.missing-required { border-left-color: var(--lf-bad); }
.script-question .q-label { font-size: .8rem; font-weight: 600; color: var(--lf-muted); margin-bottom: .35rem; }
.script-question .q-label .req { color: var(--lf-bad); }
.script-question .choice-group { display: flex; flex-wrap: wrap; gap: .4rem; }
.script-question .choice { position: relative; }
.script-question .choice input { position: absolute; opacity: 0; pointer-events: none; }
.script-question .choice span { display: inline-block; padding: .35rem .8rem; border: 1px solid #cfd6e2; border-radius: 2rem; background: #fff; cursor: pointer; user-select: none; transition: all .1s; }
.script-question .choice span:hover { border-color: var(--lf-accent); }
.script-question .choice input:checked + span { background: var(--lf-accent); border-color: var(--lf-accent); color: #fff; }
.script-question .choice input:focus-visible + span { outline: 2px solid var(--lf-accent); outline-offset: 2px; }
.script-question .form-control, .script-question .form-select { max-width: 32rem; }

/* ---------- Script editor ---------- */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 991.98px) { .editor-grid { grid-template-columns: 1fr; } }
.script-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; line-height: 1.55; min-height: 460px; resize: vertical; tab-size: 2; }
.diag { font-size: .85rem; padding: .35rem .6rem; border-radius: .35rem; margin-bottom: .25rem; }
.diag.error { background: #fde8e8; color: #9b2c2c; }
.diag.warning { background: #fdf3e1; color: #8a5a12; }
.cheat .btn { font-size: .78rem; }

/* ---------- Caller workspace ---------- */
.workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
@media (max-width: 1199.98px) { .workspace { grid-template-columns: 240px minmax(0, 1fr); } .workspace .lead-panel { grid-column: 1 / -1; } }
@media (max-width: 767.98px) { .workspace { grid-template-columns: 1fr; } .workspace .queue-panel { order: 3; } }
.queue-panel .list-group-item { cursor: pointer; border-left: 0; border-right: 0; padding: .55rem .8rem; }
.queue-panel .list-group-item.active { background: var(--lf-accent-soft); color: var(--lf-ink); border-color: var(--lf-line); }
.queue-panel .list-group-item .qname { font-weight: 600; }
.queue-panel .list-group-item .qsub { font-size: .8rem; color: var(--lf-muted); }
.queue-section { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--lf-muted); padding: .6rem .8rem .3rem; }
.sticky-col { position: sticky; top: 1rem; }
.lead-fields dt { font-size: .75rem; color: var(--lf-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin-top: .45rem; }
.lead-fields dd { margin-bottom: 0; overflow-wrap: anywhere; }
.call-bar { position: sticky; bottom: 0; z-index: 5; background: #fff; border-top: 1px solid var(--lf-line); box-shadow: 0 -4px 12px rgba(16,24,40,.06); padding: .75rem 1rem; border-radius: 0 0 .75rem .75rem; }
.dispo-grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.dispo-grid .btn { font-size: .85rem; }
.dispo-grid .btn kbd { font-size: .65rem; padding: .05rem .3rem; margin-left: .3rem; background: rgba(0,0,0,.12); color: inherit; }
.dial-btn { font-size: 1.05rem; font-weight: 600; }
.phone-big { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.call-status { font-size: .85rem; }
.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.toast-host { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080; display: flex; flex-direction: column; gap: .5rem; }
.lf-toast { background: #111827; color: #fff; padding: .75rem 1rem; border-radius: .6rem; box-shadow: 0 8px 24px rgba(0,0,0,.2); min-width: 260px; }

/* ---------- Template bits ---------- */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; border-radius: .5rem; }
.blazor-error-boundary::after { content: "An error has occurred." }

.darker-border-checkbox.form-check-input { border-color: #929292; }
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder { color: var(--bs-secondary-color); text-align: end; }
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder { text-align: start; }
