:root {
    color-scheme: dark;
    --bg: #0d111b;
    --panel: #151b2c;
    --panel-strong: #1c2438;
    --line: #27324a;
    --line-soft: #324161;
    --text: #eef2ff;
    --muted: #9eaacc;
    --green: #28b36a;
    --yellow: #d3a739;
    --red: #df5a68;
    --blue: #4d7cff;
    --blue-strong: #3766eb;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.26);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(77, 124, 255, 0.18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(40, 179, 106, 0.12), transparent 28%),
        var(--bg);
    color: var(--text);
    font-family: Inter, Arial, sans-serif;
}

body {
    min-height: 100vh;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.shell {
    display: grid;
    grid-template-columns: 360px 1fr;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(7, 10, 17, 0.72);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 2px 2px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--blue), #6f5ef8);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(59, 96, 236, 0.28);
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
}

.brand-subtitle,
.subtitle {
    color: var(--muted);
    font-size: 13px;
}

.content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.topbar h1 {
    margin: 0 0 8px;
    font-size: 30px;
    line-height: 1.05;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chip,
.status-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--line-soft);
    background: rgba(255, 255, 255, 0.03);
    font-size: 13px;
    font-weight: 600;
    color: #d5deff;
}

[data-state="ready"] {
    border-color: rgba(40, 179, 106, 0.4);
    background: rgba(40, 179, 106, 0.12);
    color: #b4f5ce;
}

[data-state="busy"] {
    border-color: rgba(211, 167, 57, 0.42);
    background: rgba(211, 167, 57, 0.14);
    color: #f8df9d;
}

[data-state="error"] {
    border-color: rgba(223, 90, 104, 0.4);
    background: rgba(223, 90, 104, 0.12);
    color: #ffc0c6;
}

[data-state="idle"] {
    color: #d5deff;
}

.panel,
.dialer-card,
.control-card {
    background: linear-gradient(180deg, rgba(28, 36, 56, 0.9), rgba(18, 24, 39, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 18px;
}

.panel-compact {
    padding: 18px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-head h2 {
    margin: 0;
    font-size: 16px;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.status-card {
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-label,
.quick-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
}

.quick-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
    padding: 14px 0 0;
}

.quick-meta strong {
    display: block;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.quick-actions,
.mini-actions,
.dial-actions,
.in-call-actions,
.modal-actions {
    display: flex;
    gap: 10px;
}

.quick-actions {
    margin-top: 16px;
}

.mini-actions {
    margin-top: 14px;
}

.field-list {
    display: grid;
    gap: 12px;
}

.field {
    display: grid;
    gap: 7px;
}

.field span {
    color: var(--muted);
    font-size: 12px;
}

.field input,
.field select,
.dial-display input {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: rgba(7, 11, 20, 0.82);
    color: var(--text);
    outline: none;
}

.field input:focus,
.field select:focus,
.dial-display input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(77, 124, 255, 0.14);
}

.toggle-row {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d6dcf1;
    font-size: 14px;
}

.toggle input {
    width: 18px;
    height: 18px;
}

.primary-button,
.secondary-button,
.ghost-button,
.call-button,
.hangup-button {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-button,
.call-button {
    background: linear-gradient(135deg, var(--blue), var(--blue-strong));
    color: #fff;
    font-weight: 600;
}

.secondary-button {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.07);
}

.ghost-button {
    background: transparent;
    color: #c7d4ff;
    border-color: rgba(255, 255, 255, 0.09);
}

.hangup-button {
    background: linear-gradient(135deg, #bd4053, #df5a68);
    color: #fff;
    font-weight: 600;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.call-button:hover,
.hangup-button:hover {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 420px);
    gap: 20px;
    min-height: 0;
}

.workspace-main {
    display: grid;
    gap: 20px;
}

.workspace-side {
    display: grid;
    gap: 20px;
}

.dialer-card,
.control-card {
    padding: 20px;
}

.dial-display {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.dial-display label {
    color: var(--muted);
    font-size: 13px;
}

.dial-display input {
    min-height: 58px;
    font-size: 28px;
    letter-spacing: 0;
}

.dial-actions {
    margin-bottom: 18px;
}

.dial-actions > button,
.modal-actions > button,
.quick-actions > button,
.mini-actions > button,
.in-call-actions > button {
    flex: 1;
}

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

.keypad button {
    min-height: 82px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.04);
    color: #f4f7ff;
    font-size: 28px;
    font-weight: 600;
    display: grid;
    place-items: center;
    gap: 3px;
}

.keypad button span {
    font-size: 11px;
    color: var(--muted);
}

.active-call-box {
    min-height: 120px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 16px;
}

.call-line {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.call-subline {
    color: var(--muted);
    font-size: 14px;
}

.live-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 0 0 rgba(40, 179, 106, 0);
}

.live-dot[data-active="true"] {
    background: var(--green);
    box-shadow: 0 0 0 8px rgba(40, 179, 106, 0.14);
}

.history-list,
.log-list {
    display: grid;
    gap: 10px;
    max-height: 340px;
    overflow: auto;
    padding-right: 2px;
}

.history-item,
.log-item {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 14px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.history-number {
    font-weight: 600;
}

.history-time,
.log-time {
    color: var(--muted);
    font-size: 12px;
}

.history-use {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    background: rgba(77, 124, 255, 0.14);
    border: 1px solid rgba(77, 124, 255, 0.26);
    color: #d4e0ff;
}

.log-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.log-text {
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.empty-state {
    padding: 14px;
    border-radius: 14px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    color: var(--muted);
    font-size: 14px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(2, 4, 10, 0.66);
    backdrop-filter: blur(8px);
    z-index: 20;
}

.hidden {
    display: none !important;
}

.modal {
    width: min(92vw, 420px);
    padding: 24px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(28, 36, 56, 0.98), rgba(18, 24, 39, 0.98));
    box-shadow: var(--shadow);
}

.modal-title {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.modal-caller {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 18px;
    overflow-wrap: anywhere;
}

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

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .content,
    .sidebar {
        padding: 18px;
    }

    .topbar {
        flex-direction: column;
    }

    .keypad button {
        min-height: 70px;
        font-size: 24px;
    }

    .quick-actions,
    .mini-actions,
    .dial-actions,
    .in-call-actions,
    .modal-actions {
        flex-direction: column;
    }
}
