:root {
    color-scheme: dark;
    --bg: #071019;
    --surface: #0d1925;
    --surface-2: #122232;
    --surface-3: #172b3e;
    --line: #253b4e;
    --text: #ecf5fb;
    --muted: #91a9ba;
    --cyan: #38d6e8;
    --cyan-strong: #05b8ce;
    --green: #42dc9b;
    --yellow: #f1c75b;
    --red: #ff6b78;
    --blue: #65a9ff;
    --shadow: 0 18px 55px rgba(0, 0, 0, 0.26);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 10% 0%, rgba(56, 214, 232, 0.09), transparent 31rem),
        var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 1.35rem;
    line-height: 1.15;
}

h2 {
    margin-bottom: 0;
    font-size: 1.3rem;
}

h3 {
    margin-bottom: 0;
    font-size: 1.05rem;
}

.eyebrow {
    margin-bottom: 0.25rem;
    color: var(--cyan);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 78px;
    padding: 0.8rem clamp(1rem, 4vw, 3rem);
    border-bottom: 1px solid rgba(145, 169, 186, 0.17);
    background: rgba(7, 16, 25, 0.9);
    backdrop-filter: blur(18px);
}

.brand-row,
.topbar-actions,
.field-row,
.panel-heading,
.section-heading {
    display: flex;
    align-items: center;
}

.brand-row,
.topbar-actions {
    gap: 0.9rem;
}

.brand-mark {
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    border: 1px solid rgba(56, 214, 232, 0.42);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(56, 214, 232, 0.22), rgba(5, 184, 206, 0.05));
    box-shadow: 0 0 35px rgba(56, 214, 232, 0.12);
    color: var(--cyan);
    font-weight: 900;
    letter-spacing: -0.04em;
}

.brand-mark-small {
    width: 46px;
    height: 46px;
    border-radius: 13px;
}

.workspace {
    width: min(1480px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 4rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.metric-card,
.panel,
.group-card,
.loading-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: linear-gradient(150deg, rgba(18, 34, 50, 0.96), rgba(10, 23, 34, 0.96));
    box-shadow: var(--shadow);
}

.metric-card {
    position: relative;
    overflow: hidden;
    padding: 1.15rem 1.25rem;
}

.metric-card::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--cyan);
    content: "";
}

.metric-monitor::before {
    background: var(--green);
}

.metric-card strong {
    display: block;
    margin: 0.25rem 0 0.05rem;
    font-size: clamp(1.55rem, 3vw, 2.1rem);
    line-height: 1;
}

.metric-label,
.metric-note,
.last-update,
.field-help,
.user-name {
    color: var(--muted);
}

.metric-label {
    font-size: 0.86rem;
    font-weight: 700;
}

.metric-note,
.field-help,
.last-update {
    font-size: 0.82rem;
}

.control-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    gap: 1rem;
    margin: 1rem 0 2rem;
}

.panel {
    padding: 1.25rem;
}

.panel-heading,
.section-heading {
    justify-content: space-between;
    gap: 1rem;
}

.supervisor-control {
    margin-top: 1rem;
}

.supervisor-control label,
.login-form label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.field-row {
    gap: 0.65rem;
}

select,
input {
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    background: #081521;
    color: var(--text);
}

select {
    flex: 1;
    padding: 0 0.85rem;
}

input {
    width: 100%;
    padding: 0 0.9rem;
}

select:focus,
input:focus,
button:focus-visible {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(56, 214, 232, 0.18);
}

.button {
    min-height: 42px;
    padding: 0.55rem 0.9rem;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 800;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

.button-primary {
    background: var(--cyan);
    color: #031217;
}

.button-secondary {
    border-color: rgba(56, 214, 232, 0.4);
    background: rgba(56, 214, 232, 0.12);
    color: var(--cyan);
}

.button-danger {
    border-color: rgba(255, 107, 120, 0.45);
    background: rgba(255, 107, 120, 0.14);
    color: #ff9da6;
}

.button-quiet {
    border-color: var(--line);
    background: transparent;
    color: var(--muted);
}

.button-full {
    width: 100%;
}

.connection-pill,
.badge,
.state-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.connection-pill {
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--line);
    color: var(--muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
}

.connection-pill.is-online {
    color: var(--green);
}

.connection-pill.is-offline {
    color: var(--red);
}

.badge,
.state-chip {
    padding: 0.3rem 0.6rem;
}

.badge-neutral,
.state-idle {
    background: rgba(145, 169, 186, 0.12);
    color: var(--muted);
}

.badge-active,
.state-active,
.state-monitoring {
    background: rgba(56, 214, 232, 0.14);
    color: var(--cyan);
}

.state-ringing,
.state-dialing {
    background: rgba(241, 199, 91, 0.14);
    color: var(--yellow);
}

.registration-online {
    color: var(--green);
}

.registration-offline,
.registration-unreachable {
    color: var(--red);
}

.monitor-description {
    margin: 1rem 0;
    color: var(--muted);
}

.notice,
.alert {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border-radius: 10px;
}

.notice-success {
    border: 1px solid rgba(66, 220, 155, 0.36);
    background: rgba(66, 220, 155, 0.1);
    color: var(--green);
}

.notice-error,
.alert-error {
    border: 1px solid rgba(255, 107, 120, 0.38);
    background: rgba(255, 107, 120, 0.1);
    color: #ff9da6;
}

.section-heading {
    margin-bottom: 1rem;
}

.extension-groups {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.group-card {
    overflow: hidden;
}

.group-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--line);
}

.extension-list {
    display: grid;
}

.extension-row {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto;
    gap: 0.7rem;
    align-items: center;
    min-height: 92px;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(37, 59, 78, 0.7);
}

.extension-row:last-child {
    border-bottom: 0;
}

.extension-number {
    display: block;
    font-size: 1.1rem;
    font-weight: 900;
}

.registration-line,
.detail-line {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.registration-line {
    font-weight: 800;
}

.extension-state {
    min-width: 0;
}

.detail-line {
    overflow: hidden;
    margin-top: 0.25rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-button {
    min-width: 78px;
}

.events-panel {
    margin-top: 2rem;
}

.table-scroll {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

th,
td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid rgba(37, 59, 78, 0.72);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.loading-card {
    grid-column: 1 / -1;
    padding: 2rem;
    color: var(--muted);
    text-align: center;
}

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

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
}

.login-shell {
    width: min(440px, 100%);
}

.login-card {
    padding: clamp(1.5rem, 5vw, 2.3rem);
}

.login-card h1 {
    margin-top: 1.25rem;
    font-size: clamp(1.8rem, 6vw, 2.5rem);
}

.login-description {
    margin: 0.65rem 0 1.5rem;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 0.6rem;
}

.login-form .button {
    margin-top: 0.65rem;
}

@media (max-width: 1100px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .extension-groups {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .topbar {
        position: static;
        align-items: flex-start;
    }

    .topbar-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .user-name {
        display: none;
    }

    .connection-pill {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .control-grid,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .extension-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .extension-state {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}
