:root {
    --bg: #eef3f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --ink: #111827;
    --text: #243044;
    --muted: #657084;
    --line: #dce4ee;
    --sidebar: #0d1524;
    --sidebar-2: #162235;
    --primary: #1d4ed8;
    --primary-2: #0f766e;
    --success: #047857;
    --warning: #b45309;
    --danger: #be123c;
    --violet: #6d28d9;
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, .08);
    --shadow-md: 0 18px 45px rgba(15, 23, 42, .12);
    --radius: 8px;
    --font: "Segoe UI", Roboto, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(29, 78, 216, .28);
    outline-offset: 3px;
}

.skip-link {
    background: var(--primary);
    color: #fff;
    left: 16px;
    padding: 10px 14px;
    position: fixed;
    top: 12px;
    transform: translateY(-150%);
    z-index: 100;
}

.skip-link:focus {
    transform: translateY(0);
}

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

.sidebar {
    background: linear-gradient(180deg, var(--sidebar), #111827);
    color: #dbe4f0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    padding: 24px 18px;
    position: sticky;
    top: 0;
}

.brand,
.login-brand {
    align-items: center;
    display: flex;
    gap: 13px;
}

.brand-mark {
    align-items: center;
    background: linear-gradient(135deg, #14b8a6, #1d4ed8);
    border-radius: var(--radius);
    color: #fff;
    display: inline-flex;
    font-weight: 800;
    height: 44px;
    justify-content: center;
    width: 44px;
}

.brand-mark.large {
    height: 58px;
    width: 58px;
}

.brand strong,
.login-brand h2 {
    color: #fff;
    display: block;
    font-size: 16px;
    margin: 0;
}

.login-brand h2 {
    color: var(--ink);
    font-size: 19px;
}

.brand small,
.login-brand p {
    color: #9aa8bb;
    display: block;
    font-size: 12px;
    margin: 2px 0 0;
}

.nav-menu {
    display: grid;
    gap: 7px;
}

.nav-menu a,
.logout-link {
    align-items: center;
    border-radius: var(--radius);
    color: #cbd5e1;
    display: flex;
    gap: 11px;
    min-height: 46px;
    padding: 11px 13px;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-menu a span,
.logout-link span {
    align-items: center;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 7px;
    color: #e2e8f0;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    height: 28px;
    justify-content: center;
    width: 28px;
}

.nav-menu a:hover,
.nav-menu a.is-active,
.logout-link:hover {
    background: var(--sidebar-2);
    color: #fff;
    transform: translateX(2px);
}

.nav-menu a.is-active span {
    background: #e0f2fe;
    color: #075985;
}

.logout-link {
    margin-top: auto;
}

.sidebar-scrim {
    display: none;
}

.main-shell {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 18px;
    justify-content: space-between;
    min-height: 82px;
    padding: 18px 30px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h1 {
    color: var(--ink);
    font-size: 25px;
    line-height: 1.15;
    margin: 0;
}

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

.icon-button {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    display: none;
    height: 44px;
    padding: 10px;
    width: 44px;
}

.icon-button span {
    background: var(--ink);
    display: block;
    height: 2px;
    margin: 4px 0;
}

.user-chip {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 10px;
    min-height: 44px;
    padding: 7px 8px 7px 14px;
}

.user-chip strong {
    align-items: center;
    background: #ecfeff;
    border-radius: 50%;
    color: #0f766e;
    display: inline-flex;
    height: 30px;
    justify-content: center;
    width: 30px;
}

.content-shell {
    flex: 1;
    padding: 30px;
}

.stats-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    margin-bottom: 18px;
}

.stat-card,
.panel,
.login-card,
.module-hero {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 145px;
    overflow: hidden;
    padding: 20px;
    position: relative;
}

.stat-card::before {
    background: var(--primary);
    content: "";
    height: 4px;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

.stat-card p {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 10px;
}

.stat-card strong {
    color: var(--ink);
    display: block;
    font-size: 34px;
    line-height: 1;
}

.stat-card > span {
    color: var(--muted);
    font-size: 13px;
    margin-top: 18px;
}

.stat-card.green::before { background: var(--success); }
.stat-card.amber::before { background: var(--warning); }
.stat-card.violet::before { background: var(--violet); }
.stat-card.rose::before { background: var(--danger); }

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

.panel {
    padding: 20px;
}

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

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

.panel-header h2,
.module-hero h2 {
    color: var(--ink);
    font-size: 18px;
    line-height: 1.25;
    margin: 0;
}

.panel-header span,
.empty-state,
.footer,
.module-hero p,
.clean-list {
    color: var(--muted);
}

.chart-placeholder {
    align-items: end;
    background: linear-gradient(180deg, #f8fafc, #eef6ff);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(6, 1fr);
    height: 220px;
    padding: 18px;
}

.chart-placeholder span {
    background: linear-gradient(180deg, #14b8a6, #1d4ed8);
    border-radius: 7px 7px 0 0;
    min-height: 60px;
}

.chart-placeholder span:nth-child(2) { height: 75%; }
.chart-placeholder span:nth-child(3) { height: 48%; }
.chart-placeholder span:nth-child(4) { height: 88%; }
.chart-placeholder span:nth-child(5) { height: 58%; }
.chart-placeholder span:nth-child(6) { height: 70%; }

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

.timeline-item {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary-2);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.timeline-item strong {
    color: var(--ink);
}

.timeline-item p,
.timeline-item time {
    color: var(--muted);
    display: block;
    margin: 4px 0 0;
}

.table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    min-width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 13px 14px;
    text-align: left;
    white-space: nowrap;
}

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

th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.status-pill,
.module-badge {
    background: #eef2ff;
    border-radius: 999px;
    color: #3730a3;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    padding: 5px 9px;
}

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

.screenshot-tile {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
}

.screenshot-tile strong,
.screenshot-tile span {
    display: block;
}

.screenshot-tile span {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

.screenshot-thumb {
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg, #dbeafe, #ccfbf1);
    border-radius: 6px;
    margin-bottom: 10px;
}

.module-hero {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 24px;
}

.module-hero p {
    margin: 8px 0 0;
    max-width: 760px;
}

.clean-list {
    margin: 0;
    padding-left: 20px;
}

.clean-list li + li {
    margin-top: 8px;
}

.footer {
    border-top: 1px solid var(--line);
    display: flex;
    font-size: 13px;
    justify-content: space-between;
    padding: 16px 30px;
}

.auth-page {
    background:
        linear-gradient(135deg, rgba(13, 21, 36, .94), rgba(17, 24, 39, .90)),
        linear-gradient(90deg, #0f766e, #1d4ed8);
}

.auth-shell {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100dvh;
    padding: 28px;
}

.login-panel {
    display: grid;
    gap: 36px;
    grid-template-columns: minmax(0, 1fr) 440px;
    max-width: 1040px;
    width: 100%;
}

.login-copy {
    align-self: center;
    color: #e5edf8;
}

.login-copy h1 {
    color: #fff;
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.05;
    margin: 18px 0 18px;
    max-width: 720px;
}

.login-copy p {
    color: #cbd5e1;
    font-size: 18px;
    margin: 0;
    max-width: 650px;
}

.trust-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 26px;
}

.trust-strip span {
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 999px;
    color: #f8fafc;
    font-size: 13px;
    font-weight: 800;
    padding: 8px 11px;
}

.login-card {
    box-shadow: var(--shadow-md);
    padding: 32px;
    width: 100%;
}

.form-stack {
    display: grid;
    gap: 16px;
    margin-top: 28px;
}

.toolbar {
    align-items: center;
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}

.toolbar input,
.toolbar select {
    min-height: 46px;
}

.form-field {
    display: grid;
    gap: 8px;
}

label {
    color: var(--ink);
    font-weight: 800;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="date"],
select {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    min-height: 46px;
    padding: 12px 13px;
    width: 100%;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, .14);
    outline: none;
}

.input-action {
    display: grid;
    grid-template-columns: 1fr auto;
}

.input-action input {
    border-radius: var(--radius) 0 0 var(--radius);
}

.input-action button {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--primary);
    cursor: pointer;
    font-weight: 800;
    min-height: 46px;
    padding: 0 13px;
}

.form-field small {
    color: var(--danger);
    min-height: 16px;
}

.form-row {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.form-row a {
    color: var(--primary);
    font-weight: 800;
}

.checkbox {
    align-items: center;
    display: inline-flex;
    gap: 8px;
}

.checkbox input {
    height: 18px;
    width: 18px;
}

.primary-button {
    align-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border: 0;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font-weight: 800;
    gap: 10px;
    justify-content: center;
    min-height: 48px;
    padding: 12px 18px;
    transition: opacity .18s ease, transform .18s ease, box-shadow .18s ease;
}

.secondary-button,
.small-button {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    font-weight: 800;
    justify-content: center;
    min-height: 44px;
    padding: 10px 14px;
    transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.secondary-button:hover,
.small-button:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.small-button {
    font-size: 13px;
    min-height: 36px;
    padding: 7px 10px;
}

.text-link {
    color: var(--primary);
    font-weight: 800;
}

.command-grid,
.settings-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
}

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

.command-card form {
    display: grid;
    gap: 12px;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-actions {
    display: grid;
    gap: 10px;
}

.status-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.status-list div {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 12px 14px;
}

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

.status-list dd {
    color: var(--ink);
    margin: 0;
    text-align: right;
}

.config-box {
    background: #0f172a;
    border-radius: var(--radius);
    color: #e2e8f0;
    margin: 0;
    overflow: auto;
    padding: 16px;
}

.switch-row {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
}

.rich-timeline {
    gap: 14px;
}

.rich-item {
    display: grid;
    gap: 12px;
    grid-template-columns: 38px 1fr;
}

.activity-icon {
    align-items: center;
    background: #ecfeff;
    border-radius: var(--radius);
    color: #0f766e;
    display: inline-flex;
    font-weight: 900;
    height: 38px;
    justify-content: center;
    width: 38px;
}

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

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

.detail-tile {
    display: grid;
    gap: 6px;
}

.screenshot-preview {
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
    width: 100%;
}

.screenshot-preview img,
.screenshot-thumb-img {
    aspect-ratio: 16 / 10;
    border-radius: 6px;
    display: block;
    object-fit: cover;
    width: 100%;
}

.modal {
    align-items: center;
    background: rgba(15, 23, 42, .64);
    bottom: 0;
    display: none;
    justify-content: center;
    left: 0;
    padding: 24px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 80;
}

.modal.is-open {
    display: flex;
}

.modal-dialog {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: grid;
    gap: 14px;
    max-height: 92vh;
    max-width: 980px;
    padding: 16px;
    width: 100%;
}

.modal-dialog img {
    border-radius: 6px;
    max-height: 70vh;
    object-fit: contain;
    width: 100%;
}

.modal-close {
    justify-self: end;
}

.status-pending { background: #fffbeb; color: #92400e; }
.status-processing { background: #eff6ff; color: #1d4ed8; }
.status-completed { background: #ecfdf5; color: #047857; }
.status-failed { background: #fff1f2; color: #be123c; }

.primary-button:hover {
    box-shadow: 0 12px 28px rgba(29, 78, 216, .24);
    transform: translateY(-1px);
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: .65;
    transform: none;
}

.button-loader {
    border: 2px solid rgba(255, 255, 255, .4);
    border-radius: 50%;
    border-top-color: #fff;
    display: none;
    height: 16px;
    width: 16px;
}

.primary-button.is-loading .button-loader {
    animation: spin .8s linear infinite;
    display: inline-block;
}

.alert {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    border-radius: var(--radius);
    color: var(--danger);
    padding: 11px 13px;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
    margin-top: 22px;
}

.is-hidden {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

@media (max-width: 1180px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .login-panel {
        grid-template-columns: 1fr;
        max-width: 620px;
    }

    .login-copy h1 {
        font-size: 40px;
    }
}

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

    .sidebar {
        bottom: 0;
        height: auto;
        max-width: 310px;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        width: 84vw;
        z-index: 40;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-scrim.is-visible {
        background: rgba(15, 23, 42, .55);
        bottom: 0;
        display: block;
        left: 0;
        position: fixed;
        right: 0;
        top: 0;
        z-index: 30;
    }

    .icon-button {
        display: block;
        flex: 0 0 auto;
    }

    .topbar {
        align-items: flex-start;
        padding: 16px;
    }

    .user-chip span {
        display: none;
    }

    .content-shell {
        padding: 16px;
    }

    .dashboard-grid,
    .command-grid,
    .placeholder-grid,
    .screenshot-grid,
    .settings-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .panel-wide {
        grid-column: auto;
    }

    .module-hero {
        align-items: flex-start;
        display: grid;
        gap: 16px;
    }

    .footer {
        display: grid;
        gap: 6px;
        padding: 16px;
    }
}

@media (max-width: 560px) {
    .auth-shell {
        padding: 16px;
    }

    .login-card {
        padding: 24px;
    }

    .login-copy {
        display: none;
    }

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

    .chart-placeholder {
        gap: 8px;
        height: 180px;
        padding: 12px;
    }

    .toolbar,
    .item-head,
    .status-list div {
        align-items: stretch;
        flex-direction: column;
    }

    .status-list dd {
        text-align: left;
    }
}
