:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-soft: #eef6f5;
    --text: #172026;
    --muted: #64717b;
    --line: #d7dee5;
    --brand: #087f8c;
    --brand-strong: #05636d;
    --accent: #f2c94c;
    --good: #18794e;
    --bad: #b42318;
    --warn: #9a6700;
    --radius: 8px;
    --shadow: 0 10px 26px rgba(21, 35, 45, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
}

a {
    color: var(--brand);
    font-weight: 700;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 20px;
    justify-content: space-between;
    padding: 14px 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    align-items: center;
    color: var(--text);
    display: flex;
    gap: 10px;
    font-size: 18px;
    font-weight: 800;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: var(--brand);
    border-radius: var(--radius);
    color: #fff;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.topnav,
.toolbar,
.section-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topnav a {
    border-radius: var(--radius);
    color: var(--muted);
    padding: 8px 10px;
}

.topnav a:hover,
.topnav a.active {
    background: var(--surface-soft);
    color: var(--brand-strong);
    text-decoration: none;
}

.user-chip {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    display: flex;
    gap: 8px;
    padding: 8px 10px;
}

.page {
    margin: 0 auto;
    max-width: 1180px;
    padding: 28px 24px 48px;
}

.page.narrow {
    max-width: 460px;
}

.page-header,
.section-heading {
    align-items: flex-start;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.page-title,
.section-heading h2,
.section-heading h3 {
    margin: 0;
}

h1 {
    font-size: 32px;
    line-height: 1.15;
}

h2 {
    font-size: 22px;
}

h3 {
    font-size: 17px;
}

.subtle,
.muted,
.empty {
    color: var(--muted);
}

.empty {
    font-style: italic;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.five {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.panel,
.company,
.box,
.login-panel,
.console-section,
.sidebar-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.panel + .panel,
.company + .company {
    margin-top: 16px;
}

.workflow-steps {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
}

.workflow-step {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    gap: 12px;
    padding: 14px;
}

.workflow-step strong,
.ivr-digit {
    align-items: center;
    background: var(--brand);
    border-radius: var(--radius);
    color: #fff;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 18px;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.workflow-step span {
    font-weight: 800;
}

.ivr-builder-layout {
    align-items: start;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.25fr);
    margin-bottom: 18px;
}

.softphone-workspace {
    align-items: start;
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(0, 1fr) 330px;
}

.softphone-console {
    display: grid;
    gap: 16px;
}

.call-stage {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    border-top: 4px solid var(--brand);
    box-shadow: var(--shadow);
    padding: 22px;
}

.call-stage-top {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: space-between;
}

.call-stage h2 {
    color: var(--text);
    font-size: 42px;
    line-height: 1.1;
    margin: 6px 0;
    text-transform: capitalize;
}

.eyebrow {
    color: var(--brand-strong);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0;
    text-transform: uppercase;
}

.phone-primary {
    font-size: 16px;
    min-height: 52px;
    min-width: 150px;
}

.agent-state-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 18px;
}

.agent-state,
.wrapup-meta > div {
    background: #f8fafb;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
}

.agent-state strong,
.wrapup-meta strong {
    color: var(--muted);
    display: block;
    font-size: 12px;
    text-transform: uppercase;
}

.agent-state span,
.wrapup-meta span {
    display: block;
    font-weight: 800;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.call-action-bar {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    display: flex;
    gap: 10px;
    padding: 14px;
}

.call-action-bar button {
    flex: 1;
}

.incoming-popup {
    align-items: center;
    background: rgba(23, 32, 38, 0.58);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: fixed;
    z-index: 50;
}

.incoming-popup-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 24px 70px rgba(16, 24, 32, 0.24);
    max-width: 460px;
    padding: 28px;
    text-align: center;
    width: 100%;
}

.incoming-popup-panel h2 {
    font-size: 30px;
    margin: 8px 0;
}

.incoming-caller {
    color: var(--muted);
    font-size: 18px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.incoming-popup-actions {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 18px;
}

.incoming-popup-actions button {
    min-height: 54px;
}

.is-hidden {
    display: none !important;
}

.availability-toggle {
    display: flex;
    gap: 8px;
}

.availability-toggle button {
    flex: 1;
}

.dialer-panel {
    display: grid;
    gap: 12px;
}

.dialer-entry {
    align-items: stretch;
    display: grid;
    gap: 10px;
    grid-template-columns: auto minmax(0, 1fr) auto;
}

.dialer-prefix {
    align-items: center;
    background: #eef6f5;
    border: 1px solid #cfe2e0;
    border-radius: var(--radius);
    color: var(--brand-strong);
    display: inline-flex;
    font-size: 20px;
    font-weight: 900;
    justify-content: center;
    min-height: 48px;
    padding: 0 14px;
}

.dialer-entry input {
    font-size: 22px;
    font-weight: 800;
    min-height: 48px;
}

.dialpad {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dial-key {
    background: #f8fafb;
    border-color: var(--line);
    color: var(--text);
    flex-direction: column;
    font-size: 26px;
    min-height: 64px;
}

.dial-key:hover {
    background: #eef6f5;
    color: var(--brand-strong);
}

.dial-key span {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0;
    margin-top: 2px;
}

.dialer-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.wrapup-meta {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 12px;
}

.wrapup-required {
    border-left: 4px solid var(--accent) !important;
}

.wrapup-section {
    border-color: #d4ad1f;
    border-top: 4px solid var(--accent);
}

.wrapup-section .section-heading h3 {
    font-size: 24px;
}

.wrapup-section .wrapup-required {
    background: #fff6dd;
}

.wrapup-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
}

.wrapup-grid textarea {
    min-height: 96px;
}

.wrapup-grid + button {
    margin-top: 12px;
}

.agent-sidebar {
    display: grid;
    gap: 14px;
}

.skill-group {
    border-top: 1px solid var(--line);
    margin-top: 14px;
    padding-top: 14px;
}

.skill-group h3 {
    margin: 0 0 10px;
}

.skill-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.skill-pill {
    background: #eef6f5;
    border: 1px solid #cfe2e0;
    border-radius: var(--radius);
    color: var(--text);
    display: inline-flex;
    flex-direction: column;
    font-weight: 800;
    gap: 4px;
    padding: 8px 10px;
}

.skill-pill code {
    align-self: flex-start;
    font-size: 12px;
}

.ivr-card-list,
.ivr-option-list {
    display: grid;
    gap: 10px;
}

.ivr-card,
.ivr-option-card {
    align-items: center;
    background: #f8fafb;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 12px;
}

.ivr-card:hover,
.ivr-card.active {
    background: #eef6f5;
    border-color: #b8d8d4;
    text-decoration: none;
}

.ivr-card span,
.ivr-option-card span {
    display: grid;
    gap: 2px;
}

.ivr-card small,
.ivr-option-card small {
    color: var(--muted);
    font-weight: 600;
}

.ivr-card em,
.ivr-option-card em {
    color: var(--muted);
    font-style: normal;
    font-weight: 800;
}

.ivr-option-card {
    justify-content: flex-start;
}

.ivr-option-card span {
    flex: 1;
}

.timeline-list {
    display: grid;
    gap: 10px;
}

.timeline-event {
    background: #f8fafb;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0;
}

.timeline-event summary {
    align-items: center;
    cursor: pointer;
    display: grid;
    gap: 10px;
    grid-template-columns: 190px minmax(150px, 1fr) minmax(90px, auto) 70px;
    padding: 12px;
}

.timeline-event[open] summary {
    border-bottom: 1px solid var(--line);
}

.timeline-event em,
.timeline-event small {
    color: var(--muted);
    font-style: normal;
    font-weight: 800;
}

.timeline-event > .grid {
    padding: 12px;
}

.timeline-time {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

button,
.button {
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font-weight: 800;
    justify-content: center;
    min-height: 38px;
    padding: 9px 13px;
}

button:hover,
.button:hover {
    background: var(--brand-strong);
    text-decoration: none;
}

button.secondary,
.button.secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
}

button.danger,
.button.danger {
    background: var(--bad);
    border-color: var(--bad);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.compact-button {
    min-height: 34px;
    padding: 7px 10px;
}

label {
    color: var(--text);
    display: block;
    font-weight: 800;
    margin: 12px 0 6px;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    max-width: 100%;
    padding: 10px 11px;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(8, 127, 140, 0.18);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
}

table {
    background: var(--surface);
    border: 1px solid var(--line);
    border-collapse: separate;
    border-radius: var(--radius);
    border-spacing: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #edf3f4;
    color: #33434c;
    font-size: 13px;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.error,
.notice {
    border-radius: var(--radius);
    padding: 12px 14px;
}

.error {
    background: #fff0ed;
    border: 1px solid #f3c2bb;
    color: var(--bad);
}

.notice {
    background: #e9f7ef;
    border: 1px solid #b7e2c7;
    color: var(--good);
}

.status-badge {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    padding: 5px 8px;
    text-transform: uppercase;
}

.status-ready {
    background: #e9f7ef;
    border-color: #b7e2c7;
    color: var(--good);
}

.status-on_call {
    background: #e8f4ff;
    border-color: #b6d7f2;
    color: #155e8a;
}

.status-wrap_up {
    background: #fff6dd;
    border-color: #f1d891;
    color: var(--warn);
}

.status-not_ready,
.status-offline {
    background: #f4f6f8;
    color: var(--muted);
}

.live-pill {
    align-items: center;
    background: #f4f6f8;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    min-height: 34px;
    padding: 7px 10px;
    text-transform: uppercase;
}

.live-ok {
    background: #e9f7ef;
    border-color: #b7e2c7;
    color: var(--good);
}

.live-warn {
    background: #fff6dd;
    border-color: #f1d891;
    color: var(--warn);
}

.live-error {
    background: #fff0ed;
    border-color: #f3c2bb;
    color: var(--bad);
}

.supervisor-stats {
    margin-bottom: 16px;
}

.supervisor-stat {
    display: grid;
    gap: 10px;
}

.supervisor-stat strong {
    font-size: 34px;
    line-height: 1;
}

code,
.sid {
    background: #edf3f4;
    border-radius: 6px;
    color: #163840;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 2px 5px;
}

pre,
.log {
    background: #101820;
    border: 1px solid #26323a;
    border-radius: var(--radius);
    color: #d6f3ef;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow: auto;
}

.softphone-drawer {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-top: 14px;
    padding: 0;
}

.softphone-drawer summary {
    cursor: pointer;
    font-weight: 800;
    list-style-position: inside;
    padding: 12px;
}

.softphone-drawer[open] {
    padding: 0 12px 12px;
}

.softphone-drawer[open] summary {
    border-bottom: 1px solid var(--line);
    margin: 0 -12px 12px;
}

@media (max-width: 840px) {
    .topbar,
    .page-header,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .grid.two,
    .grid.three,
    .grid.five,
    .workflow-steps,
    .ivr-builder-layout,
    .softphone-workspace,
    .agent-state-grid,
    .wrapup-meta,
    .wrapup-grid,
    .timeline-event summary {
        grid-template-columns: 1fr;
    }

    .call-stage-top,
    .call-action-bar,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .dialer-entry,
    .dialer-actions {
        grid-template-columns: 1fr;
    }

    .page {
        padding: 20px 14px 36px;
    }
}
