:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --panel-soft: #f9fafb;
    --ink: #111827;
    --ink-soft: #374151;
    --muted: #6b7280;
    --line: #e5e7eb;
    --line-strong: #d1d5db;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --danger: #b42318;
    --success: #067647;
    --radius: 10px;
    --radius-lg: 14px;
    --sidebar: 268px;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --shadow-soft: 0 1px 2px rgba(15, 23, 42, .06);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 12% 0%, rgba(37, 99, 235, .08), transparent 28%),
        linear-gradient(180deg, #fbfbfc 0%, var(--bg) 100%);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
}

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

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

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .02);
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input, select {
    min-height: 44px;
    padding: 10px 12px;
}

textarea {
    min-height: 92px;
    padding: 10px 12px;
    resize: vertical;
}

input:focus, select:focus, textarea:focus {
    outline: 0;
    border-color: rgba(37, 99, 235, .55);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .10);
}

label {
    display: grid;
    gap: 7px;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 650;
}

h1, h2, p { margin-top: 0; }

h1 {
    margin-bottom: 10px;
    font-size: clamp(28px, 3vw, 38px);
    line-height: 1.08;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 16px;
    font-size: 18px;
    line-height: 1.2;
    letter-spacing: 0;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        linear-gradient(135deg, rgba(255,255,255,.72), rgba(245,247,251,.86)),
        radial-gradient(circle at 20% 20%, rgba(37,99,235,.10), transparent 26%),
        #eef2f7;
}

.login-card {
    width: min(100%, 980px);
    display: grid;
    grid-template-columns: 1.08fr .92fr;
    overflow: hidden;
    border: 1px solid rgba(209, 213, 219, .9);
    border-radius: 18px;
    background: rgba(255,255,255,.88);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .13);
    backdrop-filter: blur(18px);
}

.login-copy {
    min-height: 560px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 42px;
    border-right: 1px solid var(--line);
    background:
        linear-gradient(160deg, #ffffff 0%, #f8fafc 62%, #eef4ff 100%);
}

.login-copy h1 {
    max-width: 540px;
    font-size: clamp(34px, 4vw, 52px);
    font-weight: 720;
}

.login-subtitle {
    max-width: 470px;
    color: var(--muted);
    font-size: 16px;
}

.login-panel {
    display: grid;
    align-content: center;
    gap: 20px;
    padding: 42px;
    background: #fff;
}

.login-panel-head h2 {
    margin-bottom: 4px;
    font-size: 26px;
}

.login-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.login-highlights span {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 10px;
    background: rgba(255,255,255,.72);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 650;
}

.brand-line, .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 760;
    letter-spacing: 0;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 12px;
    background: linear-gradient(145deg, #111827, #334155);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-mark.small {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 12px;
}

.stack { display: grid; gap: 15px; }

.button {
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    background: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .10);
}

.button.primary {
    background: linear-gradient(180deg, #2563eb, #1d4ed8);
    color: #fff;
    border-color: rgba(29, 78, 216, .85);
}

.button.primary:hover { background: linear-gradient(180deg, #1d4ed8, #1e40af); }

.mobile-topbar { display: none; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 18px;
    border-right: 1px solid var(--line);
    background: rgba(255,255,255,.92);
    box-shadow: 1px 0 0 rgba(15, 23, 42, .02);
    backdrop-filter: blur(18px);
}

.sidebar-brand {
    min-height: 40px;
    padding: 2px 4px;
}

.workspace-card {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
}

.workspace-card span {
    overflow: hidden;
    color: var(--ink);
    font-size: 13px;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-card strong {
    color: var(--muted);
    font-size: 11px;
    font-weight: 680;
    text-transform: uppercase;
}

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

.nav a, .logout-link, .nav-toggle {
    min-height: 38px;
    border-radius: var(--radius);
    padding: 9px 11px;
    color: var(--ink-soft);
    font-weight: 650;
}

.nav a:hover, .logout-link:hover {
    background: var(--panel-soft);
    color: var(--ink);
}

.logout-link {
    margin-top: auto;
    border: 1px solid var(--line);
    background: #fff;
}

.nav-toggle {
    border: 1px solid var(--line);
    background: #fff;
}

.app-main {
    width: min(1220px, calc(100% - var(--sidebar) - 64px));
    margin: 0 32px 56px calc(var(--sidebar) + 32px);
    padding-top: 28px;
}

.app-main.narrow { width: min(720px, calc(100% - var(--sidebar) - 64px)); }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.eyebrow {
    margin-bottom: 7px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 760;
    letter-spacing: .08em;
    text-transform: uppercase;
}

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

.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }

.card {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,.92);
    box-shadow: var(--shadow-soft);
    padding: 20px;
}

.metric {
    min-height: 132px;
    display: grid;
    align-content: space-between;
}

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

.metric strong {
    color: var(--ink);
    font-size: 32px;
    font-weight: 760;
    line-height: 1;
}

.status-pill, .tag {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(37, 99, 235, .14);
    border-radius: 999px;
    padding: 4px 10px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 720;
    white-space: nowrap;
}

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

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    background: #fff;
}

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

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }

th {
    background: #fbfbfc;
    color: var(--muted);
    font-size: 11px;
    font-weight: 760;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.toolbar { margin-bottom: 12px; }

.alert {
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-weight: 650;
}

.alert.error { color: var(--danger); background: #fff7f5; border-color: #fecdca; }
.alert.success { color: var(--success); background: #f6fef9; border-color: #abefc6; }

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

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

.form-grid.single { grid-template-columns: 1fr; }
.span-2 { grid-column: span 2; }

.import-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
}

.link-action {
    color: var(--primary-dark);
    font-weight: 720;
}

.inline-convert summary {
    cursor: pointer;
    color: var(--primary-dark);
    font-weight: 720;
}

.mini-form {
    width: min(300px, 78vw);
    display: grid;
    gap: 10px;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
}

.mini-form label { font-size: 12px; }
.mini-form input, .mini-form select { min-height: 38px; }
.button.compact { min-height: 38px; }

@media (max-width: 1020px) {
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .two-cols { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 30;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 16px;
        border-bottom: 1px solid var(--line);
        background: rgba(255,255,255,.94);
        backdrop-filter: blur(16px);
    }

    .sidebar {
        display: none;
        position: sticky;
        top: 59px;
        width: 100%;
        height: auto;
        padding: 12px 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        box-shadow: none;
    }

    .sidebar.open { display: grid; }
    .sidebar-brand { display: none; }
    .workspace-card { display: none; }
    .nav { width: 100%; }
    .logout-link { margin-top: 4px; }

    .app-main, .app-main.narrow {
        width: min(100% - 28px, 1220px);
        margin: 0 auto 42px;
        padding-top: 18px;
    }

    .form-grid, .import-row { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .page-head { display: block; }
}

@media (max-width: 680px) {
    .login-shell { padding: 18px; }
    .login-card { grid-template-columns: 1fr; }
    .login-copy {
        min-height: auto;
        gap: 26px;
        padding: 26px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .login-copy h1 { font-size: 32px; }
    .login-panel { padding: 26px; }
    .cards { grid-template-columns: 1fr; }
    .card { padding: 16px; }
}
