:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #121722;
    --muted: #6f7785;
    --line: #e4e8ef;
    --primary: #1769e0;
    --primary-dark: #0f56bd;
    --success: #138a4b;
    --success-bg: #eaf8f0;
    --danger: #c93636;
    --danger-bg: #fff0f0;
    --shadow: 0 10px 30px rgba(25, 39, 66, .08);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

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

a {
    color: inherit;
}

button,
input,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.login-body {
    display: grid;
    place-items: center;
    padding: 24px;
}

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

.login-card,
.panel,
.site-card,
.empty-state {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-card {
    padding: 30px;
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--text);
    color: #fff;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 22px;
}

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

h1 {
    font-size: clamp(22px, 5vw, 30px);
    line-height: 1.15;
    margin-bottom: 8px;
}

h2 {
    font-size: 18px;
    margin-bottom: 4px;
}

.muted {
    color: var(--muted);
}

.form-stack {
    display: grid;
    gap: 18px;
}

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

.field > span {
    font-size: 14px;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid #d8dee8;
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    padding: 14px 15px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input {
    min-height: 50px;
}

textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.45;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(23, 105, 224, .1);
}

.phone-input {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    border: 1px solid #d8dee8;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
}

.phone-input:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(23, 105, 224, .1);
}

.phone-input > span {
    padding: 0 0 0 15px;
    font-weight: 800;
    color: var(--muted);
}

.phone-input input {
    border: 0;
    box-shadow: none;
}

.button {
    min-height: 48px;
    border-radius: 14px;
    padding: 0 18px;
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    gap: 8px;
}

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

.button-primary:hover {
    background: var(--primary-dark);
}

.button-secondary {
    background: #eef3fb;
    color: #23416c;
}

.button-ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid #cbd8ec;
}

.button-full {
    width: 100%;
}

.topbar {
    min-height: 92px;
    padding: 18px max(20px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(16px);
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
}

.topbar.compact {
    min-height: 70px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
}

.topbar.compact h1 {
    font-size: 18px;
    text-align: center;
}

.eyebrow {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 4px;
}

.icon-button,
.back-link {
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
    color: var(--muted);
}

.container {
    width: min(100% - 32px, 980px);
    margin: 0 auto;
    padding: 24px 0 96px;
}

.container.narrow {
    width: min(100% - 32px, 620px);
}

.summary-row {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.summary-row > div {
    display: flex;
    align-items: baseline;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 11px 14px;
}

.summary-row strong {
    font-size: 20px;
}

.summary-row span {
    font-size: 13px;
    color: var(--muted);
}

.summary-row .button {
    justify-self: end;
}

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

.site-card {
    padding: 20px;
}

.site-card-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.site-card-head a {
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
    word-break: break-all;
}

.status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 800;
    flex: 0 0 auto;
}

.status-active {
    color: var(--success);
    background: var(--success-bg);
}

.status-passive {
    color: var(--muted);
    background: #eef0f4;
}

.phone-line {
    font-size: 24px;
    font-weight: 850;
    letter-spacing: -.03em;
    margin: 26px 0;
}

.card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.panel {
    padding: 22px;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 15px;
}

.switch-row > div {
    display: grid;
    gap: 3px;
}

.switch-row span {
    font-size: 13px;
    color: var(--muted);
}

.switch-row input {
    appearance: none;
    width: 50px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #ccd2db;
    position: relative;
    cursor: pointer;
}

.switch-row input::after {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
    transition: transform .18s ease;
}

.switch-row input:checked {
    background: var(--success);
}

.switch-row input:checked::after {
    transform: translateX(20px);
}

.install-section {
    display: grid;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.install-section > div {
    display: grid;
    gap: 3px;
}

.install-section span {
    color: var(--muted);
    font-size: 13px;
}

.code-box {
    min-height: 96px;
    background: #101722;
    color: #e9f2ff;
    border: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

.danger-link {
    border: 0;
    background: transparent;
    color: var(--danger);
    font-weight: 800;
    padding: 10px;
    cursor: pointer;
}

.alert {
    border-radius: 14px;
    padding: 13px 15px;
    margin-bottom: 18px;
    font-size: 14px;
    transition: opacity .25s ease, transform .25s ease;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #ffd5d5;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #c8eed8;
}

.alert.is-hidden {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}

.empty-state {
    text-align: center;
    padding: 42px 24px;
}

.empty-state p {
    color: var(--muted);
    max-width: 420px;
    margin: 0 auto 22px;
}

.empty-icon {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    background: #eef3fb;
    color: var(--primary);
    font-size: 28px;
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: end center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 14, 24, .52);
}

.modal-card {
    width: min(100%, 560px);
    position: relative;
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 22px;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, .18);
    z-index: 2;
}

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

.modal-close {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: #f0f3f7;
    color: var(--text);
    font-size: 26px;
    cursor: pointer;
}

.modal-open {
    overflow: hidden;
}

.floating-add {
    display: none;
}

@media (max-width: 720px) {
    .topbar {
        min-height: 76px;
        padding: 14px 16px;
    }

    .topbar h1 {
        font-size: 19px;
    }

    .container {
        width: min(100% - 24px, 980px);
        padding-top: 16px;
    }

    .summary-row {
        grid-template-columns: auto auto;
    }

    .summary-row .button {
        display: none;
    }

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

    .site-card {
        padding: 18px;
    }

    .phone-line {
        font-size: 23px;
        margin: 22px 0;
    }

    .panel {
        padding: 17px;
        border-radius: 18px;
    }

    .sticky-submit {
        position: sticky;
        bottom: 10px;
        box-shadow: 0 10px 26px rgba(23, 105, 224, .28);
    }

    .floating-add {
        position: fixed;
        right: 18px;
        bottom: max(18px, env(safe-area-inset-bottom));
        width: 58px;
        height: 58px;
        border-radius: 18px;
        display: grid;
        place-items: center;
        text-decoration: none;
        color: #fff;
        background: var(--primary);
        font-size: 30px;
        box-shadow: 0 14px 30px rgba(23, 105, 224, .32);
        z-index: 40;
    }
}
