:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --ink: #111111;
    --muted: #667085;
    --line: rgba(17, 17, 17, .12);
    --brand: #6aa8ff;
    --brand-2: #7c5cff;
    --nav: #344054;
    --green: #167a5b;
    --green-soft: #e8f5ef;
    --amber: #9a5b04;
    --amber-soft: #fff2d8;
    --red: #b42318;
    --red-soft: #fee4e2;
    --blue-soft: #e9f0fb;
    --radius: 16px;
    --shadow: 0 12px 35px rgba(0, 0, 0, .12);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

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

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

a:hover {
    opacity: .9;
}

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

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
    display: grid;
    grid-template-columns: minmax(220px, auto) 1fr auto;
    align-items: center;
    gap: 22px;
    padding: 12px min(4vw, 44px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-logo {
    width: 170px;
    height: auto;
    display: block;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #07101d;
    display: grid;
    place-items: center;
    font-weight: 800;
    box-shadow: 0 10px 25px rgba(106, 168, 255, .18);
}

.brand strong {
    display: block;
    font-size: 15px;
    line-height: 1.2;
}

.brand span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
}

.nav a {
    color: var(--nav);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 650;
    white-space: nowrap;
}

.nav a.active,
.nav a:hover {
    color: var(--ink);
    background: rgba(17, 17, 17, .06);
}

.nav i {
    display: none;
}

.sidebar-footer {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    text-align: right;
}

.main {
    min-width: 0;
    background:
        radial-gradient(900px 420px at 8% -12%, rgba(106, 168, 255, .16), transparent 58%),
        radial-gradient(820px 420px at 92% -14%, rgba(124, 92, 255, .15), transparent 56%),
        #ffffff;
}

.topbar {
    width: min(1120px, 92vw);
    margin: 20px auto 0;
    min-height: 98px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 24px;
}

.title h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.1;
    letter-spacing: 0;
}

.title p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 14px;
}

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

.btn {
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--ink);
    border-radius: 999px;
    min-height: 42px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    box-shadow: none;
}

.btn.primary,
.login .btn {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-color: transparent;
    color: #07101d;
    box-shadow: 0 12px 24px rgba(106, 168, 255, .18);
}

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

.content {
    width: min(1120px, 92vw);
    margin: 0 auto;
    padding: 22px 0 38px;
    display: grid;
    gap: 20px;
}

.alert,
.errors {
    border-radius: 14px;
    padding: 13px 15px;
    font-size: 14px;
}

.alert {
    border: 1px solid #a7d8c4;
    background: #ecfdf3;
    color: #075a42;
}

.errors {
    border: 1px solid #f2aaa5;
    background: #fff1f0;
    color: #912018;
}

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

.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .07);
    padding: 17px;
    min-height: 98px;
}

.metric span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
    line-height: 1;
}

.metric small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
    gap: 20px;
    align-items: start;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    padding: 17px 19px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #ffffff;
}

.panel-header h2 {
    margin: 0;
    font-size: 17px;
}

.panel-header span {
    color: var(--muted);
    font-size: 12px;
}

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

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

.table th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface-soft);
}

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

.doc-title {
    font-weight: 800;
    color: var(--ink);
}

.doc-meta {
    color: var(--muted);
    margin-top: 4px;
    line-height: 1.35;
}

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

.badge.blue {
    color: #245091;
    background: var(--blue-soft);
}

.badge.green {
    color: var(--green);
    background: var(--green-soft);
}

.badge.amber {
    color: var(--amber);
    background: var(--amber-soft);
}

.badge.red {
    color: var(--red);
    background: var(--red-soft);
}

.form {
    padding: 18px;
    display: grid;
    gap: 14px;
}

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

.field label {
    color: var(--nav);
    font-size: 12px;
    font-weight: 800;
}

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

.field textarea {
    min-height: 84px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.dropzone {
    border: 1px dashed rgba(17, 17, 17, .25);
    border-radius: 14px;
    background: var(--surface-soft);
    padding: 13px;
    color: var(--muted);
}

.workflow {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
}

.step {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .07);
    padding: 15px;
    min-height: 104px;
}

.step b {
    display: block;
    font-size: 13px;
}

.step p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.4;
    font-size: 12px;
}

.empty {
    padding: 28px 18px;
    color: var(--muted);
    text-align: center;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
    padding: 18px;
}

.config-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
    padding: 14px;
}

.link-card {
    color: inherit;
    display: block;
    min-height: 98px;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.link-card:hover {
    border-color: rgba(17, 17, 17, .24);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .08);
    opacity: 1;
    transform: translateY(-1px);
}

.config-card strong {
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
}

.config-card span,
.config-card p {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    margin: 0;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(900px 420px at 8% -12%, rgba(106, 168, 255, .18), transparent 58%),
        radial-gradient(820px 420px at 92% -14%, rgba(124, 92, 255, .18), transparent 56%),
        #ffffff;
}

.login {
    width: min(430px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

.login .brand {
    margin-bottom: 24px;
    padding: 0;
    border-bottom: 0;
    justify-content: center;
}

.login .brand-logo {
    width: 260px;
}

.login h1 {
    margin: 0;
    font-size: 21px;
    line-height: 1.2;
}

.login p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.login .errors {
    color: var(--red);
    margin-bottom: 14px;
    font-size: 13px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.check input {
    width: 16px;
    min-height: 16px;
}

@media (max-width: 1100px) {
    .sidebar {
        grid-template-columns: 1fr;
        gap: 12px;
        align-items: start;
    }

    .brand-logo {
        width: 142px;
    }

    .sidebar-footer {
        display: none;
    }

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

@media (max-width: 760px) {
    .sidebar {
        padding: 12px 16px;
    }

    .nav {
        width: 100%;
    }

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

    .content {
        padding-top: 16px;
    }

    .metrics,
    .workflow,
    .settings-grid,
    .form-row {
        grid-template-columns: 1fr;
    }

    .table {
        min-width: 760px;
    }

    .table-wrap {
        overflow-x: auto;
    }
}
