:root {
    --red: #e4002b;
    --red-dark: #bd0024;
    --navy: #092b73;
    --navy-dark: #061d4e;
    --ink: #151a26;
    --muted: #687083;
    --line: #e5e8ee;
    --surface: #f5f6f8;
    --white: #fff;
    --success: #12824c;
    --warning: #a86100;
    --danger: #b42318;
    --sidebar: 244px;
    --radius: 8px;
    --shadow: 0 12px 35px rgba(13, 31, 68, .08);
}

* { box-sizing: border-box; }
html { background: var(--surface); }
body {
    margin: 0;
    color: var(--ink);
    background: var(--surface);
    font: 14px/1.45 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    width: var(--sidebar);
    flex-direction: column;
    color: #d9e2fa;
    background: var(--navy-dark);
    transition: transform .24s ease;
}
.brand {
    display: flex;
    height: 84px;
    align-items: center;
    gap: 13px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,.09);
}
.brand-mark {
    display: grid;
    width: 42px;
    height: 50px;
    place-items: center;
    overflow: hidden;
    border-radius: 6px;
    background: #fff;
}
.brand-mark img { width: 34px; height: 42px; object-fit: contain; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy strong { color: #fff; font-size: 19px; }
.brand-copy small { margin-top: 5px; color: #9fb1d8; font-size: 10px; letter-spacing: .18em; }
.nav { flex: 1; overflow-y: auto; padding: 20px 12px; }
.nav-label {
    display: block;
    padding: 0 12px 9px;
    color: #7188b5;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
}
.nav-item {
    position: relative;
    display: flex;
    height: 45px;
    align-items: center;
    gap: 12px;
    margin: 3px 0;
    padding: 0 12px;
    border-radius: 6px;
    color: #b9c7e5;
    font-weight: 560;
    transition: color .16s, background .16s, transform .16s;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); transform: translateX(2px); }
.nav-item.active { color: #fff; background: rgba(228,0,43,.98); }
.sidebar-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.09);
}
.user-mini { display: flex; min-width: 0; flex: 1; align-items: center; gap: 10px; }
.user-mini > span:last-child { display: flex; min-width: 0; flex-direction: column; }
.user-mini strong { overflow: hidden; color: #fff; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.user-mini small { color: #8297c0; font-size: 10px; }
.avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: #23417d;
    font-weight: 750;
}
.logout-link { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 6px; color: #91a5cc; }
.logout-link:hover { color: #fff; background: rgba(255,255,255,.08); }

.main { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    height: 64px;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(14px);
}
.topbar-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; font-weight: 650; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(18,130,76,.1); }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.topbar-time { margin-right: 8px; color: var(--muted); font-size: 12px; }
.icon-button {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}
.icon-button:hover { color: var(--navy); background: #eef1f6; }
.mobile-menu { display: none; }
.workspace { max-width: 1560px; margin: 0 auto; padding: 30px 32px 50px; }
.page-heading { display: flex; min-height: 64px; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; font-size: 28px; font-weight: 720; line-height: 1.12; }
.page-heading p { margin: 7px 0 0; color: var(--muted); }
.page-actions { display: flex; align-items: center; gap: 9px; }

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-weight: 680;
    cursor: pointer;
    transition: background .16s, border .16s, transform .16s;
}
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--red); }
.button.primary:hover { background: var(--red-dark); }
.button.secondary { color: var(--navy); border-color: #d8dee9; background: #fff; }
.button.secondary:hover { border-color: #aebbd0; background: #f9fafc; }
.button.danger { color: var(--danger); border-color: #f1c7c3; background: #fff; }
.button.small { min-height: 32px; padding: 0 10px; font-size: 12px; }

.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 13px 15px;
    border: 1px solid;
    border-radius: var(--radius);
    animation: slide-in .28s ease both;
}
.flash.success { color: #0d683d; border-color: #bde2cf; background: #edf8f2; }
.flash.error, .flash.danger { color: #8e2119; border-color: #f0c5c0; background: #fff1ef; }
.flash.warning { color: #805000; border-color: #ead19b; background: #fff8e8; }
.flash span { flex: 1; }
.flash button { display: grid; width: 28px; height: 28px; place-items: center; border: 0; color: inherit; background: transparent; cursor: pointer; }

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.metric { min-width: 0; padding: 21px 22px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-label .icon { width: 18px; height: 18px; color: #8d98aa; }
.metric strong { display: block; margin-top: 10px; font-size: 29px; line-height: 1; }
.metric small { display: block; margin-top: 9px; color: var(--muted); font-size: 11px; }
.metric small.positive { color: var(--success); }
.metric small.attention { color: var(--warning); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 20px; margin-top: 20px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 8px 26px rgba(13,31,68,.045); }
.panel-head { display: flex; min-height: 61px; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.panel-body { padding: 20px; }
.panel-body.flush { padding: 0; }

.throughput { height: 270px; padding: 20px 20px 12px; }
.bars { display: flex; height: 210px; align-items: flex-end; gap: 13px; border-bottom: 1px solid var(--line); }
.bar-column { display: flex; min-width: 0; flex: 1; height: 100%; align-items: flex-end; justify-content: center; }
.bar {
    position: relative;
    width: min(34px, 65%);
    min-height: 4px;
    border-radius: 4px 4px 0 0;
    background: var(--navy);
    transform-origin: bottom;
    animation: grow-bar .7s cubic-bezier(.2,.8,.2,1) both;
}
.bar:hover { background: var(--red); }
.bar span {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    padding: 3px 6px;
    border-radius: 4px;
    color: #fff;
    background: var(--ink);
    font-size: 10px;
    opacity: 0;
    transform: translateX(-50%) translateY(3px);
    transition: .15s;
    pointer-events: none;
}
.bar:hover span { opacity: 1; transform: translateX(-50%) translateY(0); }
.bar-labels { display: flex; gap: 13px; padding-top: 9px; color: var(--muted); font-size: 10px; }
.bar-labels span { min-width: 0; flex: 1; text-align: center; }

.queue-list { display: flex; flex-direction: column; }
.queue-item { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.queue-item:last-child { border-bottom: 0; }
.queue-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warning); }
.queue-dot.danger { background: var(--danger); }
.queue-copy { min-width: 0; }
.queue-copy strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.queue-copy small { color: var(--muted); font-size: 11px; }
.queue-count { font-size: 19px; font-weight: 750; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.search-box { position: relative; width: min(380px, 100%); }
.search-box .icon { position: absolute; top: 50%; left: 12px; width: 18px; height: 18px; color: #8993a3; transform: translateY(-50%); }
.search-box input { width: 100%; height: 42px; padding: 0 13px 0 39px; border: 1px solid var(--line); border-radius: 6px; outline: none; background: #fff; }
.search-box input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(9,43,115,.09); }
.select, .input, .textarea {
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    outline: none;
    background: #fff;
}
.textarea { min-height: 100px; padding-top: 10px; resize: vertical; }
.select:focus, .input:focus, .textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(9,43,115,.09); }
.toolbar .spacer { flex: 1; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
    color: #737d8e;
    background: #fafbfc;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .07em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr { transition: background .14s; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.cell-main { display: block; font-size: 12px; font-weight: 690; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; }
.badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 750;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge.success { color: #0b6d3e; background: #e7f5ed; }
.badge.warning { color: #855300; background: #fff1d2; }
.badge.danger { color: #92241b; background: #feeae8; }
.badge.neutral { color: #596275; background: #eef0f4; }
.progress-track { width: 120px; height: 6px; overflow: hidden; border-radius: 99px; background: #e9ecf1; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--red); }
.empty { padding: 50px 20px; color: var(--muted); text-align: center; }
.empty .icon { width: 38px; height: 38px; margin-bottom: 10px; color: #a5adba; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 700; }
.field small { color: var(--muted); font-size: 11px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.upload-zone {
    display: grid;
    min-height: 230px;
    place-items: center;
    padding: 25px;
    border: 1px dashed #b7c0ce;
    border-radius: var(--radius);
    background: #fafbfc;
    text-align: center;
    transition: .16s;
}
.upload-zone:hover { border-color: var(--navy); background: #f5f7fb; }
.upload-zone .icon { width: 34px; height: 34px; color: var(--navy); }
.upload-zone strong { display: block; margin-top: 12px; }
.upload-zone p { margin: 5px 0 15px; color: var(--muted); font-size: 12px; }
.upload-zone input { max-width: 100%; }

.split { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.4fr); gap: 20px; }
.detail-list { display: grid; grid-template-columns: 135px 1fr; gap: 11px 16px; margin: 0; }
.detail-list dt { color: var(--muted); font-size: 11px; }
.detail-list dd { margin: 0; font-weight: 630; }
.stat-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stat-line:last-child { border-bottom: 0; }

.pagination { display: flex; justify-content: flex-end; gap: 5px; padding: 16px; border-top: 1px solid var(--line); }
.pagination a { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: #fff; font-size: 12px; }
.pagination a.active { color: #fff; border-color: var(--navy); background: var(--navy); }

.login-page { min-height: 100vh; background: var(--navy-dark); }
.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(420px, .9fr) minmax(500px, 1.1fr); }
.login-brand {
    position: relative;
    display: flex;
    overflow: hidden;
    flex-direction: column;
    justify-content: space-between;
    padding: 54px;
    color: #fff;
    background: var(--navy-dark);
}
.login-brand::after {
    position: absolute;
    right: -230px;
    bottom: -280px;
    width: 660px;
    height: 660px;
    border: 95px solid var(--red);
    border-radius: 50%;
    content: "";
    opacity: .95;
}
.login-logo { position: relative; z-index: 2; display: flex; align-items: center; gap: 15px; }
.login-logo .brand-mark { width: 54px; height: 66px; }
.login-logo .brand-mark img { width: 44px; height: 56px; }
.login-logo strong { display: block; font-size: 25px; }
.login-logo small { display: block; margin-top: 5px; color: #9eb0d4; font-size: 11px; letter-spacing: .18em; }
.login-statement { position: relative; z-index: 2; max-width: 490px; margin-bottom: 40px; }
.login-statement h1 { margin: 0; font-size: 43px; line-height: 1.04; }
.login-statement p { max-width: 440px; margin: 18px 0 0; color: #b4c2df; font-size: 15px; }
.login-security { position: relative; z-index: 2; display: flex; align-items: center; gap: 9px; color: #9fb0d3; font-size: 11px; }
.login-form-side { display: grid; place-items: center; padding: 42px; background: #fff; }
.login-box { width: min(410px, 100%); animation: login-in .5s ease both; }
.login-box h2 { margin: 0; font-size: 28px; }
.login-box > p { margin: 8px 0 30px; color: var(--muted); }
.login-box .field { margin-bottom: 17px; }
.login-box .input { width: 100%; height: 52px; }
.login-box .button { width: 100%; min-height: 52px; margin-top: 7px; }
.login-error { display: flex; gap: 9px; margin-bottom: 16px; padding: 11px 13px; border-radius: 6px; color: var(--danger); background: #fff0ee; font-size: 12px; }
.login-foot { margin-top: 28px; color: #8a93a2; font-size: 10px; text-align: center; }

.sidebar-backdrop { display: none; }
@keyframes grow-bar { from { transform: scaleY(0); } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes login-in { from { opacity: 0; transform: translateY(18px); } }

@media (max-width: 1100px) {
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .metric:nth-child(2) { border-right: 0; }
    .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .dashboard-grid, .split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { position: fixed; inset: 0; z-index: 40; display: block; background: rgba(4,15,40,.48); }
    .main { margin-left: 0; }
    .mobile-menu { display: grid; }
    .topbar { padding: 0 16px; }
    .workspace { padding: 24px 16px 40px; }
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { min-height: 270px; padding: 30px; }
    .login-statement { margin: 36px 0 20px; }
    .login-statement h1 { max-width: 520px; font-size: 34px; }
    .login-security { display: none; }
    .login-form-side { padding: 40px 24px; }
}
@media (max-width: 600px) {
    .metrics { grid-template-columns: 1fr; }
    .metric { border-right: 0; border-bottom: 1px solid var(--line); }
    .metric:last-child { border-bottom: 0; }
    .page-heading { flex-direction: column; }
    .page-actions { width: 100%; flex-wrap: wrap; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar .search-box { width: 100%; }
    .form-grid { grid-template-columns: 1fr; }
    .field.full { grid-column: auto; }
    .topbar-time { display: none; }
}

