:root {
    --bg: #eef2f7;
    --ink: #172033;
    --muted: #667085;
    --line: #dfe6ef;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-strong: #ffffff;
    --nav: #101828;
    --nav-2: #1d2939;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-soft: #eaf1ff;
    --green: #0f766e;
    --green-dark: #115e59;
    --red: #dc2626;
    --shadow: 0 24px 70px rgba(16, 24, 40, 0.12);
    --radius: 22px;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 10%, rgba(37, 99, 235, 0.12), transparent 30%),
        radial-gradient(circle at 88% 0%, rgba(15, 118, 110, 0.14), transparent 26%),
        linear-gradient(135deg, #f8fafc 0%, var(--bg) 52%, #f7f0e8 100%) !important;
    color: var(--ink) !important;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    padding: 0 !important;
}

body.app-shell-mounted > .topbar {
    display: none !important;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: 276px;
    height: 100vh;
    flex: 0 0 276px;
    padding: 24px 18px;
    color: #f8fafc;
    background:
        linear-gradient(160deg, rgba(37, 99, 235, 0.22), transparent 38%),
        linear-gradient(180deg, var(--nav) 0%, var(--nav-2) 100%);
    box-shadow: 16px 0 40px rgba(16, 24, 40, 0.18);
    overflow-y: auto;
}

.brand-block {
    padding: 4px 8px 24px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-bottom: 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #14b8a6 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.08em;
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.35);
}

.brand-title {
    font-size: 19px;
    line-height: 1.25;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    margin-top: 8px;
    color: #bdc7d6;
    font-size: 12px;
    line-height: 1.6;
}

.side-nav {
    display: grid;
    gap: 8px;
    margin: 4px 0 24px;
}

.side-nav-link {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 11px;
    align-items: center;
    padding: 12px;
    color: #d7deea;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 16px;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.side-nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.10);
    transform: translateX(2px);
}

.side-nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: inset 3px 0 0 #60a5fa;
}

.side-nav-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.10);
    color: #bfdbfe;
    font-size: 12px;
    font-weight: 900;
}

.side-nav-link.active .side-nav-code {
    background: #ffffff;
    color: var(--brand);
}

.side-nav-title {
    display: block;
    font-size: 14px;
    font-weight: 850;
}

.side-nav-desc {
    display: block;
    margin-top: 3px;
    color: #aab7c9;
    font-size: 11px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-user-card {
    margin-top: auto;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
}

.language-switch {
    margin-bottom: 13px;
    padding-bottom: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.language-label {
    display: block;
    margin-bottom: 7px;
    color: #aab7c9 !important;
    font-size: 11px !important;
    font-weight: 800 !important;
}

.locale-select {
    width: 100% !important;
    height: 36px;
    padding: 0 10px !important;
    color: #fff !important;
    background: rgba(255, 255, 255, 0.10) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 12px !important;
    font-size: 13px !important;
    font-weight: 800;
}

.locale-select option {
    color: #172033;
    background: #fff;
}

.app-user-label {
    color: #aab7c9;
    font-size: 11px;
}

.app-user-name {
    margin-top: 4px;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    word-break: break-all;
}

.app-logout {
    width: 100%;
    margin-top: 12px;
    background: rgba(255, 255, 255, 0.10) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    box-shadow: none !important;
}

.app-logout:hover {
    background: rgba(220, 38, 38, 0.85) !important;
    border-color: rgba(220, 38, 38, 0.9) !important;
}

.app-main {
    min-width: 0;
    flex: 1;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 18px 30px 14px;
    border-bottom: 1px solid rgba(223, 230, 239, 0.92);
    background: rgba(248, 250, 252, 0.82);
    backdrop-filter: blur(16px);
}

.app-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.app-kicker {
    color: var(--brand);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.app-current-title {
    margin-top: 4px;
    color: var(--ink);
    font-size: 23px;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.app-current-desc {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.app-tabs {
    display: flex;
    gap: 8px;
    max-width: 54vw;
    overflow-x: auto;
    padding-bottom: 2px;
}

.app-tab {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: max-content;
    padding: 9px 10px 9px 14px;
    color: #475467;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(16, 24, 40, 0.06);
    cursor: pointer;
}

.app-tab-link {
    color: inherit;
    text-decoration: none;
}

.app-tab:hover {
    color: var(--brand);
    border-color: #b8cdfc;
}

.app-tab.active {
    color: #fff;
    background: linear-gradient(135deg, var(--brand) 0%, #0f766e 100%);
    border-color: transparent;
}

.app-tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 19px;
    min-height: 0;
    padding: 0;
    color: inherit;
    background: rgba(17, 24, 39, 0.06);
    border: 0;
    border-radius: 999px;
    box-shadow: none;
    font-size: 14px;
    line-height: 1;
}

.app-tab.active .app-tab-close {
    background: rgba(255, 255, 255, 0.18);
}

.app-tab-close:hover {
    transform: none;
    background: rgba(220, 38, 38, 0.18);
}

.app-content {
    padding: 30px;
}

.container {
    width: 100% !important;
    max-width: 1180px !important;
    margin: 0 auto !important;
}

.page-all-results .container {
    max-width: none !important;
    margin: 0 !important;
}

.panel {
    background: var(--panel) !important;
    border: 1px solid rgba(255, 255, 255, 0.86);
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
    padding: 24px !important;
    margin-bottom: 22px !important;
}

.section {
    background: rgba(248, 250, 252, 0.78) !important;
    border: 1px solid var(--line) !important;
    border-radius: 18px !important;
    padding: 18px !important;
}

h1 {
    color: var(--ink) !important;
    text-align: left !important;
    letter-spacing: -0.03em;
}

.intro {
    max-width: 900px;
    color: var(--muted) !important;
    text-align: left !important;
}

.section-title {
    color: var(--ink) !important;
    font-size: 16px !important;
    font-weight: 900 !important;
    letter-spacing: -0.01em;
}

.hint,
.empty,
.results-toolbar .left,
.toolbar .left {
    color: var(--muted) !important;
}

label {
    color: #344054 !important;
    font-weight: 800 !important;
}

input,
select,
textarea {
    color: var(--ink) !important;
    background: #fff !important;
    border: 1px solid #cfd8e6 !important;
    border-radius: 12px !important;
    font-family: inherit !important;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand) !important;
    outline: none !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.13) !important;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-height: 38px;
    padding: 10px 16px;
    color: #fff;
    background: var(--brand);
    border: 1px solid transparent;
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.20);
    font-size: 13px;
    font-weight: 850;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

button:hover {
    background: var(--brand-dark);
    transform: translateY(-1px);
}

button:disabled {
    color: #98a2b3 !important;
    background: #e4e7ec !important;
    border-color: #e4e7ec !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.secondary-button,
.detail-btn {
    background: var(--green) !important;
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.18) !important;
}

.secondary-button:hover,
.detail-btn:hover {
    background: var(--green-dark) !important;
}

.ghost-btn,
.refresh-btn,
.btn-cancel {
    color: #475467 !important;
    background: #fff !important;
    border: 1px solid #cfd8e6 !important;
    box-shadow: none !important;
}

.ghost-btn:hover,
.refresh-btn:hover,
.btn-cancel:hover {
    color: var(--brand) !important;
    background: var(--brand-soft) !important;
    border-color: #b8cdfc !important;
}

.danger-btn {
    background: var(--red) !important;
    box-shadow: 0 10px 24px rgba(220, 38, 38, 0.18) !important;
}

.danger-btn:hover {
    background: #b91c1c !important;
}

#analyzeBtn,
#startBtn,
#saveBtn {
    min-width: 180px;
}

.tavily-box,
.url-block,
.tpl-item,
.task-item,
.tpl-choice,
.tpl-detail {
    border-color: var(--line) !important;
    border-radius: 16px !important;
}

.url-block,
.tpl-item,
.task-item,
.tpl-choice {
    background: var(--panel-strong) !important;
}

.url-block .idx,
.tag,
.user-badge,
.snap-badge {
    background: var(--brand-soft) !important;
    color: var(--brand) !important;
}

.task-item:hover,
.tpl-item:hover,
.tpl-choice:hover,
tr:hover td {
    background: #f8fbff !important;
}

.task-item.active,
.tpl-choice.selected {
    background: var(--brand-soft) !important;
    border-color: #9bbcf8 !important;
}

.badge,
.status-tag,
.tag,
.tpl-chip,
.user-badge {
    border-radius: 999px !important;
}

.table-wrap {
    border: 1px solid var(--line) !important;
    border-radius: 16px !important;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

th {
    background: #f3f6fb !important;
    color: #475467 !important;
    font-weight: 850 !important;
}

td {
    color: #344054 !important;
}

a.link,
.modal-empty a {
    color: var(--brand) !important;
    font-weight: 750;
}

.status-box,
.msg,
.send-result {
    border-radius: 14px !important;
}

.modal-overlay {
    backdrop-filter: blur(6px);
}

.modal {
    border-radius: 22px !important;
    box-shadow: 0 30px 80px rgba(16, 24, 40, 0.32) !important;
}

.modal-head h3 {
    color: var(--ink) !important;
}

.modal-close {
    min-height: 0;
    width: auto !important;
    padding: 0 6px !important;
    color: #98a2b3 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    font-size: 22px !important;
}

.modal-close:hover {
    color: #344054 !important;
    background: transparent !important;
    transform: none !important;
}

body.auth-page {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 24px !important;
}

body.auth-page::before {
    content: "";
    position: fixed;
    inset: 9% auto auto 8%;
    width: 300px;
    height: 300px;
    border-radius: 42% 58% 62% 38%;
    background: rgba(37, 99, 235, 0.16);
    filter: blur(4px);
}

body.auth-page::after {
    content: "";
    position: fixed;
    right: 8%;
    bottom: 8%;
    width: 360px;
    height: 360px;
    border-radius: 58% 42% 40% 60%;
    background: rgba(15, 118, 110, 0.16);
    filter: blur(4px);
}

.auth-page .card {
    position: relative;
    z-index: 1;
    max-width: 430px !important;
    padding: 38px 34px !important;
    border: 1px solid rgba(255, 255, 255, 0.86);
    border-radius: 28px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    box-shadow: var(--shadow) !important;
    backdrop-filter: blur(14px);
}

.auth-page h1 {
    text-align: center !important;
    color: var(--ink) !important;
    font-size: 24px !important;
}

.auth-page .subtitle {
    color: var(--muted) !important;
}

.auth-page .tabs {
    padding: 4px;
    border: 1px solid var(--line) !important;
    border-radius: 999px !important;
    background: #f3f6fb !important;
}

.auth-page .tab {
    border-radius: 999px;
    background: transparent !important;
    color: #667085 !important;
}

.auth-page .tab.active {
    color: #fff !important;
    background: linear-gradient(135deg, var(--brand) 0%, #0f766e 100%) !important;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
}

.auth-page button {
    width: 100%;
    min-height: 44px;
}

.auth-language-switch {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 18px;
}

.auth-language-switch .language-label {
    margin: 0;
    color: var(--muted) !important;
}

.auth-language-switch .locale-select {
    width: 112px !important;
    color: var(--ink) !important;
    background: #fff !important;
    border-color: var(--line) !important;
}

@media (max-width: 980px) {
    .app-sidebar {
        width: 236px;
        flex-basis: 236px;
        padding: 20px 14px;
    }

    .app-header,
    .app-content {
        padding-left: 22px;
        padding-right: 22px;
    }

    .app-tabs {
        max-width: 48vw;
    }
}

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        position: relative;
        width: auto;
        height: auto;
        padding: 18px;
    }

    .brand-block {
        padding-bottom: 14px;
    }

    .side-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .side-nav-link {
        min-width: 180px;
    }

    .app-user-card {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 10px;
    }

    .language-switch {
        grid-column: 1 / -1;
        margin-bottom: 0;
    }

    .app-logout {
        width: auto;
        margin: 0;
    }

    .app-header {
        position: relative;
        padding: 18px;
    }

    .app-header-row {
        display: grid;
    }

    .app-tabs {
        max-width: 100%;
    }

    .app-content {
        padding: 18px;
    }

    .panel {
        padding: 18px !important;
    }

    .grid,
    .tavily-grid {
        grid-template-columns: 1fr !important;
    }

    button,
    #analyzeBtn,
    #startBtn,
    #saveBtn {
        width: 100%;
    }

    .btn-row,
    .toolbar,
    .results-toolbar,
    .filters,
    .modal-foot .btns {
        align-items: stretch !important;
    }
}
