:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-soft: #f2f4f7;
    --ink: #101828;
    --muted: #667085;
    --soft: #98a2b3;
    --line: #e4e7ec;
    --primary: #3ecfa0;
    --primary-dark: #14956f;
    --blue: #2f80ed;
    --amber: #f59e0b;
    --red: #e5484d;
    --shadow: 0 20px 60px rgba(16, 24, 40, 0.11);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 12% 12%, rgba(62, 207, 160, 0.12), transparent 26%),
        linear-gradient(180deg, #ffffff, var(--bg));
}

.auth-panel {
    width: min(500px, 100%);
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 650;
}

.brand-mark {
    width: 32px;
    height: 32px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    align-items: center;
    justify-items: center;
    padding: 6px;
    border-radius: 8px;
    background: var(--primary);
}

.brand-mark span {
    display: block;
    width: 2px;
    border-radius: 999px;
    background: white;
}

.brand-mark span:nth-child(1),
.brand-mark span:nth-child(5) {
    height: 6px;
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(4) {
    height: 10px;
}

.brand-mark span:nth-child(3) {
    height: 16px;
}

.auth-panel h1 {
    margin: 28px 0 12px;
    font-size: 34px;
    line-height: 1.08;
    font-weight: 740;
}

.auth-panel p,
.panel p,
.command-panel p {
    color: var(--muted);
    line-height: 1.6;
}

.notice {
    margin: 22px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--muted);
}

.notice.warning {
    border-color: rgba(245, 158, 11, .36);
    background: rgba(245, 158, 11, .08);
}

.notice[data-mode="ready"] {
    color: #087443;
    border-color: rgba(62, 207, 160, .36);
    background: rgba(62, 207, 160, .09);
}

.notice[data-mode="error"] {
    color: #b42318;
    border-color: rgba(229, 72, 77, .36);
    background: rgba(229, 72, 77, .08);
}

code {
    padding: 4px 7px;
    border-radius: 6px;
    color: #175cd3;
    background: rgba(47, 128, 237, .08);
}

.primary,
.secondary,
.ghost,
.call-actions button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 15px;
    color: var(--ink);
    background: white;
    font-weight: 650;
}

.primary {
    color: white;
    border-color: transparent;
    background: var(--primary);
}

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

.secondary:hover,
.ghost:hover,
.call-actions button:hover {
    border-color: #c9d0dc;
    background: var(--surface-soft);
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 22px 0 16px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
}

.auth-tabs button {
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font-weight: 650;
}

.auth-tabs button.active {
    color: var(--ink);
    background: white;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .08);
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-form .primary,
.auth-form .ghost {
    width: 100%;
}

.form-hint {
    margin: -4px 0 0;
    font-size: 13px;
}

.auth-status {
    margin-bottom: 0;
}

.app-shell {
    display: grid;
    grid-template-columns: 246px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 24px;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(14px);
}

.sidebar nav {
    display: grid;
    gap: 6px;
}

.sidebar a {
    padding: 11px 12px;
    color: var(--muted);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 590;
}

.sidebar a.active,
.sidebar a:hover {
    color: var(--ink);
    background: var(--surface-soft);
}

.sidebar .ghost {
    margin-top: auto;
}

.workspace {
    width: min(1180px, calc(100vw - 292px));
    margin: 0 auto;
    padding: 30px 0 56px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    margin-bottom: 24px;
}

.topbar p {
    margin: 0 0 6px;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 650;
}

.topbar h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.12;
    font-weight: 740;
}

.account-pill {
    min-width: 190px;
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
}

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

.account-pill strong {
    font-weight: 650;
}

.panel {
    margin-bottom: 18px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
    box-shadow: 0 10px 32px rgba(16, 24, 40, .05);
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 22px;
}

.panel-heading span {
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 650;
}

.panel-heading h2 {
    margin: 6px 0 0;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 720;
}

.status-chip {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 13px;
    font-weight: 600;
}

.status-chip[data-mode="ready"] {
    color: #087443;
    border-color: rgba(62, 207, 160, .36);
    background: rgba(62, 207, 160, .08);
}

.status-chip[data-mode="error"] {
    color: #b42318;
    border-color: rgba(229, 72, 77, .42);
    background: rgba(229, 72, 77, .08);
}

label {
    display: grid;
    gap: 8px;
    color: #475467;
    font-size: 13px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 12px 13px;
    color: var(--ink);
    background: white;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(62, 207, 160, .14);
}

textarea {
    resize: vertical;
    line-height: 1.55;
}

.form-grid,
.rule-form,
.number-search {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    align-items: end;
}

.form-grid button,
.rule-form button,
.number-search button {
    height: 46px;
}

.number-search {
    grid-template-columns: minmax(180px, 280px) auto;
    justify-content: start;
}

.assigned-number {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin: 18px 0;
    padding: 18px;
    border: 1px solid rgba(62, 207, 160, .36);
    border-radius: 10px;
    background: rgba(62, 207, 160, .08);
}

.assigned-number.empty {
    display: block;
    color: var(--muted);
    border-color: var(--line);
    background: var(--surface-soft);
}

.assigned-number strong {
    font-size: 22px;
    font-weight: 720;
}

.assigned-number span {
    color: var(--muted);
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.number-card,
.data-row,
.command-panel,
.import-panel {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
}

.number-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "phone action"
        "meta action";
    gap: 6px 16px;
    align-items: center;
    padding: 16px 18px;
}

.number-card strong {
    grid-area: phone;
}

.number-card .secondary {
    grid-area: action;
    min-width: 96px;
}

.phone-number {
    font-size: 24px;
    font-weight: 720;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.number-meta {
    grid-area: meta;
    font-size: 14px;
    font-weight: 560;
}

.number-card span,
.data-row span {
    color: var(--muted);
}

.rule-form {
    grid-template-columns: 1fr 1fr 170px auto;
}

.import-panel {
    display: grid;
    gap: 12px;
    margin-top: 14px;
    padding: 16px;
    background: var(--surface-soft);
}

.import-panel button {
    justify-self: start;
}

.data-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.data-row {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 14px;
}

.data-row > div:first-child {
    display: grid;
    gap: 4px;
}

.data-row em {
    min-width: 90px;
    padding: 7px 10px;
    border-radius: 999px;
    text-align: center;
    font-size: 12px;
    font-style: normal;
    font-weight: 650;
    color: #175cd3;
    background: rgba(47, 128, 237, .09);
}

.data-row em[data-rule="allow"] {
    color: #087443;
    background: rgba(62, 207, 160, .12);
}

.data-row em[data-rule="block"] {
    color: #b42318;
    background: rgba(229, 72, 77, .1);
}

.data-row em[data-rule="slow-roll"] {
    color: #93370d;
    background: rgba(245, 158, 11, .12);
}

.call-row {
    align-items: flex-start;
}

.call-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.call-actions button {
    min-height: 36px;
    padding: 0 11px;
    font-size: 13px;
}

.command-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 14px;
    align-items: center;
    padding: 16px;
    margin-bottom: 14px;
    background: var(--surface-soft);
}

.command-panel p {
    margin: 6px 0 0;
}

.command-panel strong {
    font-weight: 700;
}

.empty-state {
    padding: 18px;
    border: 1px dashed #d0d5dd;
    border-radius: 10px;
    color: var(--muted);
    background: var(--surface-soft);
}

.empty-state.error {
    color: #b42318;
    border-color: rgba(229, 72, 77, .42);
    background: rgba(229, 72, 77, .08);
}

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

    .sidebar {
        position: relative;
        height: auto;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }

    .sidebar nav {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
    }

    .sidebar .ghost {
        margin: 0 0 0 auto;
    }

    .workspace {
        width: min(100% - 28px, 1180px);
    }

    .form-grid,
    .rule-form,
    .number-grid,
    .command-panel {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 680px) {
    .auth-panel {
        padding: 24px;
    }

    .topbar,
    .panel-heading,
    .data-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-grid,
    .rule-form,
    .number-search,
    .number-grid,
    .command-panel {
        grid-template-columns: 1fr;
    }

    .call-actions {
        justify-content: flex-start;
    }
}
