:root {
    color-scheme: light;
    --bg: #edf2f8;
    --glass: rgba(255, 255, 255, 0.66);
    --glass-strong: rgba(255, 255, 255, 0.82);
    --glass-soft: rgba(255, 255, 255, 0.48);
    --line: rgba(34, 50, 74, 0.12);
    --line-bright: rgba(255, 255, 255, 0.78);
    --text: #111827;
    --muted: #607087;
    --soft: rgba(236, 242, 249, 0.78);
    --primary: #0a9b8e;
    --primary-dark: #067e75;
    --blue: #0a84ff;
    --amber: #c78316;
    --danger: #d2473d;
    --danger-soft: rgba(255, 69, 58, 0.1);
    --focus: rgba(10, 132, 255, 0.28);
    --shadow: 0 18px 52px rgba(26, 39, 57, 0.14);
    --shadow-soft: 0 10px 30px rgba(26, 39, 57, 0.1);
    --blur: blur(24px) saturate(1.4);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    position: relative;
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(10, 132, 255, 0.12) 0%, rgba(10, 132, 255, 0) 34%),
        linear-gradient(315deg, rgba(10, 155, 142, 0.13) 0%, rgba(10, 155, 142, 0) 38%),
        linear-gradient(180deg, #f8fbff 0%, #eef4fa 46%, #e8eef6 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.46) 0 1px, transparent 1px 100%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0 1px, transparent 1px 100%);
    background-size: 64px 64px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
    -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}

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

button {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text);
    padding: 0 14px;
    cursor: pointer;
    box-shadow: 0 1px 0 var(--line-bright) inset, 0 8px 20px rgba(26, 39, 57, 0.06);
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover {
    border-color: rgba(10, 132, 255, 0.24);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 1px 0 var(--line-bright) inset, 0 12px 26px rgba(26, 39, 57, 0.09);
}

button:active {
    transform: translateY(1px);
}

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

button.primary {
    border-color: rgba(6, 126, 117, 0.18);
    background: linear-gradient(180deg, #12b8aa 0%, #079184 100%);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.36) inset, 0 14px 28px rgba(10, 155, 142, 0.24);
}

button.primary:hover {
    border-color: rgba(6, 126, 117, 0.24);
    background: linear-gradient(180deg, #11a99c 0%, #087f76 100%);
}

button.danger {
    border-color: rgba(210, 71, 61, 0.26);
    background: linear-gradient(180deg, #ef635a 0%, #d2473d 100%);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.34) inset, 0 14px 28px rgba(210, 71, 61, 0.22);
}

button.danger.ghost {
    background: rgba(255, 255, 255, 0.72);
    color: var(--danger);
    box-shadow: 0 1px 0 var(--line-bright) inset, 0 8px 20px rgba(210, 71, 61, 0.08);
}

button.danger.ghost:hover {
    background: var(--danger-soft);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(34, 50, 74, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--text);
    outline: none;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.78) inset, 0 1px 2px rgba(26, 39, 57, 0.03);
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

input,
select {
    height: 40px;
    padding: 0 12px;
}

textarea {
    resize: vertical;
    min-height: 82px;
    padding: 10px 12px;
    line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
    color: rgba(96, 112, 135, 0.72);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
    border-color: rgba(10, 132, 255, 0.56);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 0 4px var(--focus), 0 1px 0 rgba(255, 255, 255, 0.85) inset;
}

.shell {
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 34px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--line-bright);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.46);
    box-shadow: var(--shadow-soft);
    padding: 12px 14px;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.16;
}

h2 {
    font-size: 18px;
    line-height: 1.25;
}

.account-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    border: 1px solid var(--line-bright);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
    padding: 0 14px;
    color: var(--muted);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.account-pill strong {
    min-width: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}

.logout-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line-bright);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
    color: var(--muted);
    padding: 0 12px;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
}

.logout-link:hover {
    color: var(--danger);
    background: rgba(255, 255, 255, 0.82);
}

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

.metric {
    position: relative;
    min-height: 52px;
    overflow: hidden;
    border: 1px solid var(--line-bright);
    border-radius: 8px;
    background: var(--glass);
    padding: 10px 12px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

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

.metric:nth-child(2)::before {
    background: var(--blue);
}

.metric:nth-child(3)::before {
    background: var(--amber);
}

.metric:nth-child(4)::before {
    background: #6b7280;
}

.metric span,
.field span,
.code-box span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    display: block;
    margin-top: 3px;
    font-size: 20px;
    line-height: 1.12;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
    grid-template-areas:
        "phone tasks"
        "settings tasks"
        "response response";
    gap: 10px;
    align-items: start;
}

.panel {
    border: 1px solid var(--line-bright);
    border-radius: 8px;
    background: var(--glass);
    padding: 14px;
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.phone-panel {
    grid-area: phone;
}

.task-panel {
    grid-area: tasks;
    min-width: 0;
}

.settings-panel {
    grid-area: settings;
}

.settings-panel {
    padding: 0;
}

.settings-panel[open] {
    padding: 0 14px 14px;
}

.settings-summary {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    padding: 0 14px;
    user-select: none;
}

.settings-summary span {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 18px;
    font-weight: 800;
}

.settings-summary span::before {
    content: "";
    width: 8px;
    height: 20px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--primary), var(--blue));
}

.settings-summary small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.settings-panel .form-grid {
    padding-top: 8px;
}

.response-panel {
    grid-area: response;
}

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

.panel-head h2 {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.panel-head h2::before {
    content: "";
    width: 8px;
    height: 20px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--primary), var(--blue));
}

.soft-label {
    min-height: 28px;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid rgba(34, 50, 74, 0.08);
    border-radius: 999px;
    background: rgba(236, 242, 249, 0.72);
    color: var(--muted);
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

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

.phone-panel .form-grid > .field:not(.span-2) {
    grid-column: span 1;
}

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

.advanced-options {
    grid-column: 1 / -1;
    border: 1px solid rgba(34, 50, 74, 0.09);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.38);
    padding: 0;
}

.advanced-options summary {
    min-height: 40px;
    display: flex;
    align-items: center;
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
    padding: 0 12px;
    user-select: none;
}

.advanced-options[open] summary {
    border-bottom: 1px solid rgba(34, 50, 74, 0.08);
}

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

.advanced-grid .field.span-2 {
    grid-column: span 2;
}

.inline-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.project-hint {
    display: none;
    margin: 0;
    border: 1px solid rgba(199, 131, 22, 0.18);
    border-radius: 8px;
    background: rgba(255, 245, 220, 0.72);
    color: #8a5a0a;
    padding: 10px 12px;
    line-height: 1.5;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
}

.project-hint.show {
    display: block;
}

.span-2 {
    grid-column: span 2;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.button-row.vertical {
    flex-direction: column;
}

.task-tools {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: -2px 0 8px;
}

.task-tools button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
}

.task-table-wrap {
    overflow: auto;
    max-height: calc(100vh - 250px);
    min-height: 320px;
    border: 1px solid rgba(34, 50, 74, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.32);
}

.task-table {
    width: 100%;
    min-width: 920px;
    border-collapse: separate;
    border-spacing: 0 7px;
    padding: 6px;
}

.task-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(244, 248, 252, 0.92);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-align: left;
    padding: 8px 10px;
    backdrop-filter: blur(16px) saturate(1.25);
    -webkit-backdrop-filter: blur(16px) saturate(1.25);
}

.task-table td {
    vertical-align: top;
    border-top: 1px solid rgba(34, 50, 74, 0.08);
    border-bottom: 1px solid rgba(34, 50, 74, 0.08);
    background: rgba(255, 255, 255, 0.66);
    padding: 9px 10px;
}

.task-table td:first-child {
    border-left: 1px solid rgba(34, 50, 74, 0.08);
    border-radius: 8px 0 0 8px;
}

.task-table td:last-child {
    border-right: 1px solid rgba(34, 50, 74, 0.08);
    border-radius: 0 8px 8px 0;
}

.task-table td strong,
.task-table td small {
    display: block;
}

.task-table td small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 9px;
    font-size: 12px;
    font-weight: 900;
}

.status-badge.is-running {
    background: rgba(10, 132, 255, 0.12);
    color: #075eb4;
}

.status-badge.is-done {
    background: rgba(10, 155, 142, 0.14);
    color: var(--primary-dark);
}

.status-badge.is-warn {
    background: rgba(199, 131, 22, 0.14);
    color: #875807;
}

.status-badge.is-muted {
    background: rgba(96, 112, 135, 0.12);
    color: var(--muted);
}

.status-badge.is-danger {
    background: rgba(210, 71, 61, 0.13);
    color: var(--danger);
}

.text-copy {
    min-height: 28px;
    border: 0;
    background: transparent;
    padding: 0;
    color: var(--blue);
    font-weight: 900;
    box-shadow: none;
    text-align: left;
}

.text-copy:hover {
    background: transparent;
    box-shadow: none;
}

.text-copy:disabled {
    color: var(--muted);
    opacity: 1;
}

.code-copy {
    color: var(--primary-dark);
    font-size: 18px;
}

.sms-cell {
    width: 32%;
}

.sms-cell div {
    max-height: 62px;
    overflow: auto;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 174px;
}

.row-actions button {
    min-height: 30px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 800;
}

.empty-row td {
    height: 140px;
    color: var(--muted);
    font-weight: 800;
    text-align: center;
    vertical-align: middle;
}

.current-number {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: 1px solid rgba(34, 50, 74, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.56);
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.current-number strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 28px;
    line-height: 1.15;
}

.details {
    display: grid;
    gap: 7px;
    margin: 0;
}

.details div {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
    border: 1px solid rgba(34, 50, 74, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.42);
    padding: 8px 10px;
}

.details dt {
    color: var(--muted);
    font-weight: 800;
}

.details dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.code-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    align-items: center;
    border: 1px solid rgba(10, 155, 142, 0.16);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(240, 250, 249, 0.62));
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.84) inset;
}

.code-box span {
    grid-column: 1 / -1;
}

.code-box strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 30px;
    line-height: 1.08;
    color: var(--primary-dark);
}

.response-panel pre {
    max-height: 220px;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(17, 24, 39, 0.86);
    color: #eaf2fb;
    padding: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    box-shadow: 0 12px 30px rgba(17, 24, 39, 0.18);
}

.log-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.log-item {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    border: 1px solid rgba(34, 50, 74, 0.09);
    border-radius: 8px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.52);
    color: var(--muted);
}

.log-item strong {
    color: var(--text);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20;
    max-width: min(420px, calc(100vw - 36px));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(17, 24, 39, 0.88);
    color: #fff;
    padding: 12px 14px;
    box-shadow: 0 16px 42px rgba(17, 24, 39, 0.28);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    backdrop-filter: blur(18px) saturate(1.35);
    -webkit-backdrop-filter: blur(18px) saturate(1.35);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.auth-body {
    display: grid;
    place-items: center;
}

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

.auth-card {
    display: grid;
    gap: 14px;
    border: 1px solid var(--line-bright);
    border-radius: 8px;
    background: var(--glass-strong);
    padding: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.auth-card h1 {
    font-size: 30px;
}

.auth-error {
    margin: 0;
    border: 1px solid rgba(210, 71, 61, 0.18);
    border-radius: 8px;
    background: var(--danger-soft);
    color: var(--danger);
    padding: 10px 12px;
    font-weight: 800;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .topbar,
    .account-pill,
    .metric,
    .panel,
    .toast,
    .auth-card {
        background: rgba(255, 255, 255, 0.92);
    }

    .toast,
    .response-panel pre {
        background: #111827;
    }
}

@media (max-width: 900px) {
    .shell {
        width: min(100% - 22px, 720px);
        padding-top: 18px;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
        padding: 14px;
    }

    .account-pill {
        justify-content: space-between;
        box-shadow: none;
    }

    .top-actions {
        align-items: stretch;
        flex-direction: column;
    }

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

    .workspace {
        grid-template-columns: 1fr;
        grid-template-areas:
            "phone"
            "tasks"
            "settings"
            "response";
    }

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

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

    .task-table-wrap {
        max-height: none;
    }
}

@media (max-width: 560px) {
    body::before {
        background-size: 48px 48px;
    }

    .shell {
        width: min(100% - 18px, 520px);
    }

    h1 {
        font-size: 28px;
    }

    .status-grid,
    .form-grid,
    .phone-panel .form-grid,
    .advanced-grid {
        grid-template-columns: 1fr;
    }

    .phone-panel .form-grid > .field:not(.span-2),
    .advanced-grid .field.span-2 {
        grid-column: auto;
    }

    .span-2 {
        grid-column: auto;
    }

    .panel {
        padding: 14px;
    }

    .button-row,
    .button-row.vertical {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .current-number,
    .code-box,
    .inline-search {
        grid-template-columns: 1fr;
    }

    .task-tools {
        justify-content: stretch;
        flex-direction: column;
    }

    .task-table {
        min-width: 760px;
    }

    .metric {
        min-height: 84px;
    }

    .metric strong,
    .current-number strong,
    .code-box strong {
        font-size: 26px;
    }

    .log-item {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
