:root {
    --bg: #f7f9fc;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #e1e7ef;
    --line-strong: #ccd6e2;
    --text: #172033;
    --muted: #667085;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #0f766e;
    --warning: #b7791f;
    --danger: #b42318;
    --shadow: 0 8px 18px rgba(15, 23, 42, .045);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background:
        linear-gradient(180deg, #ffffff 0, #f7f9fc 260px, #f7f9fc 100%),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.55;
}
body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto 0;
    height: 120px;
    pointer-events: none;
    background:
        radial-gradient(circle at 18% 18%, rgba(37,99,235,.08), transparent 32%),
        radial-gradient(circle at 82% 8%, rgba(14,165,233,.07), transparent 28%);
    z-index: -1;
}
a { color: var(--primary); text-decoration: none; }
.app-shell, .shell { max-width: 1280px; margin: 0 auto; padding: 18px clamp(14px, 3vw, 32px) 38px; }
.app-header, .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    margin-bottom: 18px;
    padding: 12px 0;
}
.brand, .brand-inline { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #e8f0ff;
    color: var(--primary);
    font-weight: 850;
}
.brand-title { color: var(--text); font-size: 16px; font-weight: 820; }
.brand-sub { color: var(--muted); font-size: 12px; }
.nav-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.nav-link, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: #344054;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}
.nav-link.light, .btn.primary, .btn.gold {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.btn { width: 100%; margin-top: 12px; }
.btn.secondary { width: auto; margin-top: 0; color: #344054; background: #fff; border-color: var(--line); }
.btn:hover, .nav-link:hover { border-color: var(--line-strong); }
.btn.primary:hover, .btn.gold:hover, .nav-link.light:hover { background: var(--primary-dark); }

.page-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 16px;
    margin: 10px 0 18px;
}
.eyebrow { margin: 0 0 6px; color: #475467; font-size: 12px; font-weight: 800; text-transform: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.12; letter-spacing: 0; }
h2 { font-size: 20px; line-height: 1.25; }
.muted { color: var(--muted); font-size: 13px; margin-top: 6px; }
.summary-row, .hero-stats, .metric-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.summary-card, .hero-stat, .metric-card {
    min-width: 120px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .04);
}
.summary-card strong, .hero-stat strong, .metric-card strong { display: block; font-size: 24px; line-height: 1; color: var(--text); }
.summary-card span, .hero-stat span, .metric-card span { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }

.workbench {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.sidebar, .card, .account-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.sidebar { padding: 14px; position: sticky; top: 14px; }
.side-title { padding: 8px 8px 12px; color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; }
.module-list { display: grid; gap: 8px; }
.module-btn {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.module-btn strong { font-size: 14px; }
.module-btn span { color: var(--muted); font-size: 12px; }
.module-btn.active { border-color: #c7d7fe; background: #f0f5ff; }
.panel-stack { display: grid; gap: 14px; }
.panel { display: none; }
.panel.active { display: grid; gap: 14px; }
.card.pad { padding: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.segmented, .section-tabs {
    display: inline-flex;
    gap: 4px;
    max-width: 100%;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-soft);
    overflow-x: auto;
}
.segmented button, .section-tabs a, .section-tabs button {
    min-height: 34px;
    padding: 7px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
}
.segmented button.active, .section-tabs a.active, .section-tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,.08); }
.mode-panel { display: none; }
.mode-panel.active { display: block; }
.section-panel { display: none; }
.section-panel.active { display: block; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label, .label { color: #344054; font-size: 13px; font-weight: 750; }
input, select {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cdd6e3;
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    padding: 8px 11px;
    font: inherit;
    outline: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.upload-box { border: 1px dashed #a7b4c5; border-radius: 12px; padding: 16px; background: var(--surface-soft); }
.template-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.tasks { margin-top: 16px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 13px; border-bottom: 1px solid #edf1f6; text-align: left; white-space: nowrap; }
th { background: #f8fafc; color: #344054; font-weight: 850; }
tr:hover td { background: #fbfdff; }
.badge { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge.pending, .badge.running { background: #e0f2fe; color: #075985; }
.badge.completed, .badge.active { background: #dff7ef; color: var(--success); }
.badge.failed, .badge.banned { background: #fee2e2; color: var(--danger); }
.footer { text-align: center; margin-top: 30px; color: var(--muted); font-size: 13px; }

.hero { color: var(--text); background: transparent; border: 0; box-shadow: none; padding: 0; }
.hero-main { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 18px; align-items: end; }
.hero p { color: var(--muted); }
.auth-page { min-height: 100vh; background: var(--bg); }
.auth-page .container { max-width: 480px; margin: 0 auto; padding: 48px 16px; }
.auth-page .card { border: 1px solid var(--line) !important; border-radius: 14px !important; box-shadow: var(--shadow) !important; }
.auth-page .card-header { padding: 26px 26px 0 !important; }
.auth-page .card-body { padding: 22px 26px 26px !important; }
.auth-page h1 { font-size: 28px !important; margin: 0 0 8px !important; }
.auth-page .subtitle { color: var(--muted) !important; }
.auth-page label { color: #344054 !important; font-weight: 750 !important; }
.auth-page input { min-height: 44px !important; border: 1px solid #cdd6e3 !important; border-radius: 9px !important; background: #fff !important; }
.auth-page .btn { min-height: 44px !important; border-radius: 9px !important; background: var(--primary) !important; border-color: var(--primary) !important; }
.auth-page .btn-secondary { background: #fff !important; color: var(--primary) !important; border-color: var(--line) !important; }
.auth-page .footer a { color: var(--primary) !important; font-weight: 750; }

.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.side-stack, .content-stack { display: grid; gap: 16px; }
.account-card { padding: 20px; }
.avatar { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: #e8f0ff; color: var(--primary); font-size: 22px; font-weight: 850; }
.account-name { margin: 14px 0 4px; font-size: 22px; font-weight: 850; }
.account-meta { color: var(--muted); font-size: 13px; word-break: break-all; }
.account-links { display: grid; gap: 9px; margin-top: 16px; }
.account-links a { display: flex; justify-content: space-between; align-items: center; min-height: 40px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-weight: 750; }
.metric-row { margin-bottom: 0; }

@media (max-width: 960px) {
    .page-intro, .hero-main, .workbench, .workspace { grid-template-columns: 1fr; }
    .sidebar { position: static; }
}
@media (max-width: 680px) {
    .app-shell, .shell { padding: 12px 10px 28px; }
    .app-header, .topbar, .section-head { align-items: stretch; flex-direction: column; }
    .nav-actions { justify-content: stretch; }
    .nav-link, .nav-link.light { width: 100%; }
    .summary-row, .hero-stats, .metric-row { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .card.pad { padding: 15px; }
    .template-row .btn.secondary { width: 100%; }
}

/* Console shell: fixed sidebar + switchable content, inspired by modern analytics dashboards. */
.console-layout {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
    gap: 16px;
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 12px 18px 24px;
}
.console-sidebar {
    position: sticky;
    top: 12px;
    align-self: start;
    height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow);
}
.console-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.console-logo {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
}
.console-brand strong { display: block; font-size: 16px; }
.console-brand span { display: block; color: var(--muted); font-size: 12px; }
.console-nav {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}
.console-nav a, .console-nav button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: #344054;
    font: inherit;
    font-size: 14px;
    font-weight: 780;
    text-align: left;
    cursor: pointer;
}
.console-nav a:hover, .console-nav button:hover,
.console-nav a.active, .console-nav button.active {
    border-color: #c7d7fe;
    background: #eff5ff;
    color: var(--primary);
}
.console-sidebar-foot {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}
.console-main {
    min-width: 0;
    display: grid;
    gap: 10px;
}
.console-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    min-height: 0;
    padding: 2px 0 4px;
}
.console-title h1 { font-size: clamp(26px, 3vw, 34px); }
.console-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.console-actions .nav-link { min-width: 82px; }
.console-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}
.compact-stats { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.console-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.console-card.pad { padding: 16px; }
.console-stat {
    min-height: 58px;
    padding: 10px 12px;
}
.console-stat span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 780;
}
.console-stat strong {
    display: block;
    margin-top: 4px;
    font-size: 20px;
    line-height: 1;
    font-weight: 900;
}
.console-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 10px;
    align-items: start;
}
.console-grid.single-column { grid-template-columns: 1fr; }
.console-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f3f6fa;
    overflow-x: auto;
}
.work-area .console-card.pad { padding: 14px 16px; }
.work-area .section-head { margin-bottom: 12px; }
.work-area .section-head h2 { font-size: 19px; }
.work-area .section-head .muted { margin-top: 3px; }
.work-area .form-grid { gap: 10px; }
.work-area .btn.primary { margin-top: 10px; min-height: 38px; }
.console-tabs button {
    min-height: 34px;
    padding: 7px 13px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 820;
    white-space: nowrap;
    cursor: pointer;
}
.console-tabs button.active {
    background: #fff;
    color: var(--text);
    box-shadow: 0 1px 4px rgba(15,23,42,.08);
}
.console-panel { display: none; }
.console-panel.active { display: grid; gap: 16px; }
.module-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.module-summary .console-card { padding: 16px; }
.module-summary strong { display: block; margin-top: 8px; font-size: 24px; line-height: 1; }
.side-note {
    display: grid;
    gap: 12px;
}
.side-note .console-card { padding: 14px; }
.side-note h3 { font-size: 16px; }
.side-note p { color: var(--muted); font-size: 13px; }
.console-layout .section-tabs {
    width: fit-content;
    background: #f3f6fa;
}
.account-tools .console-card { box-shadow: none; }
.account-tools .btn.secondary { width: 100%; margin-top: 10px; }
.admin-frame {
    width: 100%;
    min-height: 720px;
    border: 0;
    display: block;
    background: #fff;
}

@media (max-width: 1100px) {
    .console-layout { grid-template-columns: 1fr; width: 100%; padding: 10px; }
    .console-sidebar { position: static; height: auto; }
    .console-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .console-grid { grid-template-columns: 1fr; }
    .console-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
    .console-layout { width: 100%; gap: 12px; }
    .console-sidebar, .console-card { border-radius: 14px; }
    .console-topbar { flex-direction: column; align-items: stretch; }
    .console-actions .nav-link { width: 100%; }
    .console-nav, .console-stats, .module-summary { grid-template-columns: 1fr; }
    .console-card.pad { padding: 15px; }
}
