:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --ink: #172033;
    --muted: #64748b;
    --line: #dbe3ee;
    --line-strong: #c6d0df;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --blue: #2563eb;
    --amber: #b45309;
    --red: #b91c1c;
    --green: #15803d;
    --shadow: 0 18px 45px rgba(20, 35, 65, 0.08);
    --radius: 8px;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

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

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

button {
    border: 0;
}

a {
    color: inherit;
}

.app-loading,
.callback-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.loading-panel,
.callback-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    text-align: center;
}

.callback-card h1 {
    margin: 18px 0 8px;
    font-size: 24px;
}

.callback-card p,
.loading-panel p {
    margin: 0;
    color: var(--muted);
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius);
    background: #0f766e;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

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

.auth-visual {
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(37, 99, 235, 0.08)),
        #edf4f7;
    border-right: 1px solid var(--line);
}

.auth-copy {
    max-width: 720px;
}

.auth-copy h1 {
    margin: 24px 0 14px;
    font-size: clamp(36px, 5vw, 64px);
    line-height: 1.04;
    letter-spacing: 0;
}

.auth-copy p {
    max-width: 580px;
    margin: 0;
    color: #445166;
    font-size: 18px;
    line-height: 1.7;
}

.flow-map {
    margin-top: 42px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.flow-node {
    min-height: 108px;
    border: 1px solid rgba(23, 32, 51, 0.12);
    background: rgba(255, 255, 255, 0.72);
    border-radius: var(--radius);
    padding: 14px;
}

.flow-node span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 10px;
}

.flow-node strong {
    display: block;
    font-size: 16px;
    line-height: 1.4;
}

.auth-foot {
    color: #5c687a;
    font-size: 13px;
}

.auth-panel {
    background: var(--panel);
    min-height: 100vh;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.panel-title {
    margin-bottom: 22px;
}

.panel-title h2 {
    margin: 12px 0 6px;
    font-size: 26px;
}

.panel-title p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 18px;
}

.tab {
    min-height: 38px;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.tab.active {
    background: var(--panel);
    color: var(--ink);
    box-shadow: 0 1px 4px rgba(20, 35, 65, 0.08);
}

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

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

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

.field label {
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

.textarea {
    min-height: 92px;
    resize: vertical;
    line-height: 1.5;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.checkline {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: #334155;
    font-size: 14px;
}

.checkline input {
    width: 16px;
    height: 16px;
}

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

.btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 0 14px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}

.btn.secondary {
    background: #fff;
    color: var(--ink);
    border-color: var(--line-strong);
}

.btn.danger {
    background: #fff;
    color: var(--red);
    border-color: rgba(185, 28, 28, 0.28);
}

.btn.blue {
    background: var(--blue);
}

.btn.small {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
}

.icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    flex: 0 0 auto;
}

.google-btn {
    width: 100%;
    margin-top: 12px;
}

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

.error,
.notice,
.success {
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.5;
}

.error {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fecdd3;
}

.notice {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #bbf7d0;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    background: #111827;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-head h1 {
    margin: 0;
    font-size: 17px;
}

.sidebar-head p {
    margin: 2px 0 0;
    color: #9ca3af;
    font-size: 12px;
}

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

.nav-button {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    color: #cbd5e1;
    background: transparent;
    border-radius: var(--radius);
    padding: 0 10px;
    text-align: left;
    cursor: pointer;
}

.nav-button.active,
.nav-button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    margin-top: auto;
    display: grid;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user strong,
.sidebar-user span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.sidebar-user strong {
    display: block;
    font-size: 14px;
}

.sidebar-user span {
    display: block;
    margin-top: 3px;
    color: #9ca3af;
    font-size: 12px;
}

.main {
    min-width: 0;
    padding: 24px;
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.topbar h2 {
    margin: 0;
    font-size: 26px;
}

.topbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

.mobile-brand {
    display: none;
}

.section {
    display: grid;
    gap: 18px;
}

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

.metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}

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

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 26px;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    min-width: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 15px;
}

.panel-header h3 {
    margin: 0;
    font-size: 18px;
}

.panel-header p {
    margin: 5px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

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

.empty {
    min-height: 132px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
    padding: 18px;
}

.item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: #fff;
}

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

.item h4 {
    margin: 0;
    font-size: 16px;
    overflow-wrap: anywhere;
}

.item p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--panel-soft);
    color: #475569;
    border: 1px solid var(--line);
    font-size: 12px;
    font-weight: 700;
}

.pill.green {
    color: var(--green);
    background: #ecfdf5;
    border-color: #bbf7d0;
}

.pill.amber {
    color: var(--amber);
    background: #fffbeb;
    border-color: #fde68a;
}

.pill.red {
    color: var(--red);
    background: #fff1f2;
    border-color: #fecdd3;
}

.code-box {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: #0f172a;
    color: #e2e8f0;
    font: 12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.table th,
.table td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: top;
    font-size: 13px;
}

.table th {
    color: #475569;
    background: var(--panel-soft);
    font-weight: 800;
}

.table tr:last-child td {
    border-bottom: 0;
}

.nowrap {
    white-space: nowrap;
}

.log-text {
    max-width: 360px;
    overflow-wrap: anywhere;
}

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

.toolbar-grid {
    display: grid;
    gap: 12px;
}

.otp-secret {
    display: grid;
    gap: 8px;
}

.secret-line {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.secret-line input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

    .auth-visual {
        min-height: auto;
        padding: 32px;
        order: 2;
    }

    .auth-panel {
        min-height: auto;
        padding: 32px;
        order: 1;
    }

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

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

    .sidebar {
        position: static;
        height: auto;
        padding: 14px;
    }

    .sidebar-head,
    .sidebar-user {
        display: none;
    }

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

    .nav-button {
        justify-content: center;
        text-align: center;
        padding: 0 8px;
    }

    .nav-button .icon {
        display: none;
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .main {
        padding: 16px;
    }

    .content-grid,
    .metric-grid,
    .form-grid.two,
    .toolbar-grid.two {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 560px) {
    .auth-visual,
    .auth-panel {
        padding: 22px;
    }

    .auth-copy h1 {
        font-size: 34px;
    }

    .auth-copy p {
        font-size: 16px;
    }

    .flow-map {
        grid-template-columns: 1fr;
    }

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

    .panel,
    .metric {
        padding: 14px;
    }

    .table {
        display: block;
        overflow-x: auto;
    }
}
