:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #718096;
    --line: #e7ebf2;
    --navy: #141b31;
    --navy-soft: #202a46;
    --primary: #6657e8;
    --primary-dark: #5345d5;
    --purple-soft: #eeeafe;
    --blue: #3787ef;
    --green: #20ae7b;
    --orange: #f59b45;
    --danger: #e45561;
    --shadow: 0 10px 30px rgba(25, 34, 58, .06);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(145deg, #8879ff, #5f50e2);
    box-shadow: 0 8px 20px rgba(102, 87, 232, .35);
    font: 800 20px/1 Georgia, serif;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand small { margin-top: 3px; color: #8e98b5; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow { display: inline-block; color: #b7aefe; font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.eyebrow-dark { color: var(--primary); }
.muted { color: var(--muted) !important; }
.nowrap { white-space: nowrap; }

.login-page { overflow-x: hidden; background: #12192d; }
.login-shell { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(480px, .85fr); min-height: 100vh; }
.login-intro {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100vh;
    padding: 52px clamp(48px, 8vw, 130px) 62px;
    color: #fff;
    background:
        radial-gradient(circle at 76% 24%, rgba(106, 84, 233, .42), transparent 28%),
        radial-gradient(circle at 24% 82%, rgba(53, 121, 214, .18), transparent 35%),
        linear-gradient(145deg, #151d35 0%, #11172a 100%);
}
.login-intro::before, .login-intro::after {
    content: "";
    position: absolute;
    pointer-events: none;
    border: 1px solid rgba(255,255,255,.045);
    border-radius: 50%;
}
.login-intro::before { width: 540px; height: 540px; right: -140px; top: 80px; }
.login-intro::after { width: 350px; height: 350px; right: -42px; top: 175px; }
.brand-light { position: relative; z-index: 1; }
.login-copy { position: relative; z-index: 1; max-width: 650px; margin: auto 0; padding: 80px 0; }
.login-copy h1 { margin: 22px 0 24px; font-size: clamp(48px, 5.3vw, 76px); line-height: 1.13; letter-spacing: -.055em; }
.login-copy p { max-width: 510px; margin: 0; color: #aab3c9; font-size: 17px; line-height: 1.9; }
.login-feature-row { position: relative; z-index: 1; display: flex; gap: 34px; color: #78849f; font-size: 12px; }
.login-feature-row span::before { content: "✓"; margin-right: 8px; color: #8e80f7; }
.login-panel { display: grid; place-items: center; padding: 56px; background: #fff; }
.login-card { width: min(100%, 410px); }
.login-card h2 { margin: 12px 0 8px; color: #192238; font-size: 34px; letter-spacing: -.04em; }
.login-card > .muted { margin: 0 0 32px; }
.mobile-brand { display: none; }
.stack-form { display: grid; gap: 20px; }
.stack-form label, .create-form label, .modal label { display: grid; gap: 9px; color: #3b465b; font-size: 13px; font-weight: 700; }
.stack-form input, .create-form input, .modal input, .search-form input {
    width: 100%;
    min-height: 48px;
    border: 1px solid #dfe4ed;
    border-radius: 10px;
    padding: 0 14px;
    outline: none;
    color: var(--ink);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
}
.stack-form input:focus, .create-form input:focus, .modal input:focus, .search-form input:focus {
    border-color: #897cf0;
    box-shadow: 0 0 0 3px rgba(102, 87, 232, .1);
}
.password-field { position: relative; }
.password-field input { padding-right: 64px; }
.reveal-password { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); border: 0; color: var(--primary); background: transparent; font-size: 12px; cursor: pointer; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 42px;
    border: 0;
    border-radius: 9px;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
    transition: transform .18s, background .18s, box-shadow .18s;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--primary); box-shadow: 0 8px 18px rgba(102, 87, 232, .2); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: #fff; background: #17223b; }
.button-danger { color: #fff; background: var(--danger); }
.button-ghost { color: #526078; border: 1px solid var(--line); background: #fff; }
.button-block { width: 100%; }
.button-tall { min-height: 52px; margin-top: 4px; }
.login-note { margin: 24px 0 0; color: #9aa4b5; font-size: 11px; text-align: center; }

.alert { border-radius: 9px; padding: 12px 14px; font-size: 13px; line-height: 1.5; }
.alert-error { color: #a83442; border: 1px solid #f3c7ce; background: #fff1f3; }
.alert-success { color: #147053; border: 1px solid #bfe8da; background: #edfaf5; }
.login-card .alert { margin: -14px 0 22px; }
.alert-floating { position: fixed; z-index: 100; top: 82px; right: 28px; box-shadow: 0 14px 30px rgba(21, 31, 52, .14); }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    width: 242px;
    padding: 28px 20px 22px;
    color: #9ba5be;
    background: var(--navy);
}
.sidebar .brand { padding: 0 9px; }
.main-nav { display: grid; gap: 7px; margin-top: 46px; }
.main-nav a {
    display: flex;
    align-items: center;
    gap: 13px;
    height: 46px;
    border-radius: 9px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 650;
    transition: color .2s, background .2s;
}
.main-nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.main-nav a.active { color: #fff; background: linear-gradient(90deg, #6455e1, #7264eb); box-shadow: 0 8px 20px rgba(69, 54, 172, .28); }
.main-nav svg { width: 18px; height: 18px; }
.sidebar-help { margin-top: auto; border: 1px solid rgba(255,255,255,.075); border-radius: 13px; padding: 16px; background: rgba(255,255,255,.035); }
.help-icon { display: grid; place-items: center; width: 28px; height: 28px; margin-bottom: 12px; border-radius: 8px; color: #c9c3ff; background: rgba(116, 100, 234, .22); font-weight: 800; }
.sidebar-help strong { color: #eef0f7; font-size: 12px; }
.sidebar-help p { margin: 7px 0 12px; color: #7e8aa5; font-size: 10px; line-height: 1.65; }
.sidebar-help a { color: #aaa0ff; font-size: 11px; font-weight: 750; }
.logout-form { margin-top: 16px; }
.logout-form button { display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; border: 0; padding: 0 12px; color: #808ca8; background: transparent; cursor: pointer; font-size: 12px; }
.logout-form button:hover { color: #fff; }
.logout-form svg { width: 17px; }

.main-area { min-height: 100vh; margin-left: 242px; }
.topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    border-bottom: 1px solid var(--line);
    padding: 0 clamp(24px, 3vw, 44px);
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(12px);
}
.topbar-title { display: flex; gap: 7px; font-size: 12px; }
.breadcrumb { color: #9aa4b4; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; margin-right: 16px; border-radius: 99px; padding: 7px 11px; color: #438068; background: #eff9f5; font-size: 10px; font-weight: 700; }
.status-pill i, .health-dot { width: 7px; height: 7px; border-radius: 50%; background: #26b47e; box-shadow: 0 0 0 3px rgba(38,180,126,.12); }
.admin-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; background: #202c49; font-size: 12px; font-weight: 800; }
.admin-name strong, .admin-name small { display: block; }
.admin-name strong { font-size: 11px; }
.admin-name small { margin-top: 2px; color: #9aa3b4; font-size: 9px; }
.menu-button { display: none; width: 38px; height: 38px; border: 0; border-radius: 8px; background: #f2f4f8; }
.menu-button span { display: block; width: 17px; height: 2px; margin: 3px auto; background: #4e596d; }

.content { padding: 38px clamp(24px, 3vw, 44px) 64px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 8px 0 5px; font-size: 28px; letter-spacing: -.04em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.panel { border: 1px solid var(--line); border-radius: 13px; background: var(--panel); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 23px 24px 18px; }
.panel-heading h2 { margin: 0 0 6px; font-size: 14px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 10px; }
.soft-tag { display: inline-flex; align-items: center; min-height: 29px; border-radius: 7px; padding: 0 11px; color: #6e7890; background: #f4f6f9; font-size: 10px; font-weight: 650; }
.text-link { color: var(--primary); font-size: 11px; font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.stat-card { display: flex; align-items: center; gap: 17px; min-height: 126px; border: 1px solid var(--line); border-radius: 13px; padding: 23px; background: #fff; box-shadow: var(--shadow); }
.stat-icon { display: grid; place-items: center; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px; }
.stat-icon svg { width: 21px; height: 21px; }
.stat-icon.purple { color: #705de3; background: #efeafd; }
.stat-icon.blue { color: #3683e9; background: #e9f3fe; }
.stat-icon.green { color: #1ca777; background: #e6f8f1; }
.stat-icon.orange { color: #e98a36; background: #fff2e6; }
.stat-card div > span, .stat-card small { display: block; color: var(--muted); font-size: 10px; }
.stat-card strong { display: block; margin: 5px 0 4px; font-size: 24px; letter-spacing: -.04em; }
.stat-card small { font-size: 9px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .8fr); gap: 18px; margin-top: 18px; }
.bar-chart { display: flex; align-items: flex-end; gap: clamp(14px, 4vw, 42px); height: 220px; padding: 12px 32px 24px; }
.bar-column { display: flex; flex: 1; flex-direction: column; align-items: center; height: 100%; }
.bar-value { height: 20px; color: #919aad; font-size: 9px; }
.bar-track { position: relative; flex: 1; width: min(28px, 70%); border-radius: 6px 6px 2px 2px; background: #f0f2f7; }
.bar-track i { position: absolute; right: 0; bottom: 0; left: 0; min-height: 5px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #8374f2, #6254df); }
.bar-column small { margin-top: 9px; color: #9aa3b5; font-size: 9px; }
.quick-panel { padding-bottom: 10px; }
.quick-panel > a { display: flex; align-items: center; gap: 13px; margin: 0 16px; border-top: 1px solid #f0f2f6; padding: 14px 7px; }
.quick-panel > a:hover strong { color: var(--primary); }
.quick-panel > a > span:nth-child(2) { min-width: 0; flex: 1; }
.quick-panel strong, .quick-panel small { display: block; }
.quick-panel strong { font-size: 11px; }
.quick-panel small { margin-top: 5px; color: var(--muted); font-size: 9px; }
.quick-panel b { color: #aab1bf; font-size: 20px; font-weight: 400; }
.quick-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; font-size: 16px; }
.quick-icon.violet { color: #705de3; background: #eeeafd; }
.quick-icon.cyan { color: #218eae; background: #e7f6fa; }
.quick-icon.amber { color: #d18326; background: #fff3df; }
.recent-panel { margin-top: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { height: 42px; color: #8c96a9; background: #fafbfc; font-size: 9px; font-weight: 750; letter-spacing: .03em; text-align: left; }
td, th { border-top: 1px solid #edf0f4; padding: 11px 24px; vertical-align: middle; }
td { color: #566277; }
td strong { color: #2b3549; font-size: 11px; }
.right { text-align: right; }
.doc-cell { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.doc-cell.wide { min-width: 330px; }
.doc-cell.wide > span:last-child { min-width: 0; }
.doc-cell small { display: block; max-width: 390px; overflow: hidden; margin-top: 5px; color: #9aa4b5; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.pdf-badge { display: grid; place-items: center; flex: 0 0 auto; width: 28px; height: 32px; border-radius: 5px; color: #df4e59; background: #fff0f1; font-size: 7px; font-weight: 850; }
.pdf-badge.large { width: 34px; height: 40px; }
.empty-state { display: grid; place-items: center; min-height: 290px; padding: 45px; text-align: center; }
.empty-state.compact { min-height: 210px; }
.empty-state strong { margin-top: 13px; font-size: 13px; }
.empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 10px; }
.empty-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 14px; color: #7566e8; background: #eeeafe; font-size: 11px; font-weight: 850; }

.create-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.create-card { position: relative; padding: 24px 24px 22px 82px; }
.create-card-icon { position: absolute; top: 24px; left: 24px; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; font-size: 20px; font-weight: 700; }
.create-card-icon.violet { color: #725fe4; background: #efebfd; }
.create-card-icon.cyan { color: #1c91b4; background: #e6f7fb; }
.create-card h2 { margin: 2px 0 7px; font-size: 14px; }
.create-card > div > p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.create-form { display: grid; gap: 13px; margin-top: 22px; margin-left: -58px; }
.create-form label > span small { color: #a4adbc; font-weight: 500; }
.create-form input { min-height: 42px; font-size: 11px; }
.create-form .button { justify-self: start; }
.file-picker { position: relative; cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-picker b { display: flex; align-items: center; min-height: 42px; border: 1px dashed #cfd6e2; border-radius: 9px; padding: 0 13px; color: #8d97aa; background: #fafbfd; font-size: 10px; font-weight: 500; }
.document-panel { overflow: hidden; }
.panel-toolbar { padding-bottom: 20px; }
.search-form { position: relative; width: min(320px, 45%); }
.search-form svg { position: absolute; left: 12px; top: 50%; width: 15px; transform: translateY(-50%); color: #9ba5b8; }
.search-form input { min-height: 38px; padding-left: 36px; font-size: 10px; background: #fafbfd; }
.source-pill { display: inline-flex; border-radius: 99px; padding: 5px 8px; color: #43715f; background: #ecf8f3; font-size: 8px; font-weight: 700; white-space: nowrap; }
.source-pill.remote { color: #5f56a9; background: #f0edfc; }
.source-pill.tracked { color: #69758a; background: #f0f2f5; }
.row-actions { display: flex; justify-content: flex-end; gap: 12px; white-space: nowrap; }
.row-actions a, .row-actions button { border: 0; padding: 0; color: #6355da; background: transparent; font-size: 9px; font-weight: 700; cursor: pointer; }
.row-actions .danger-link { color: #d95864; }
.qr-slot-cell { display: flex; align-items: center; gap: 12px; min-width: 340px; }
.qr-slot-cell img { width: 54px; height: 54px; border: 1px solid #e7ebf2; border-radius: 6px; image-rendering: pixelated; }
.qr-slot-cell span { min-width: 0; }
.qr-slot-cell small { display: block; max-width: 360px; overflow: hidden; margin-top: 5px; color: #9aa4b5; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.scan-stat { min-width: 126px; }
.scan-stat strong { display: block; color: #2e3850; font-size: 15px; font-variant-numeric: tabular-nums; }
.scan-stat small { display: block; margin-top: 5px; color: #9aa4b5; font-size: 8px; white-space: nowrap; }
.slot-document-name { display: block; max-width: 180px; overflow: hidden; margin-top: 7px; color: #7d8799; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.slot-upload-form { display: flex; align-items: center; gap: 8px; min-width: 280px; }
.slot-upload-form label { position: relative; cursor: pointer; }
.slot-upload-form input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.slot-upload-form b { display: block; width: 150px; overflow: hidden; border: 1px dashed #cfd6e2; border-radius: 8px; padding: 9px 10px; color: #7f899b; background: #fafbfd; font-size: 9px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.slot-upload-form .button { min-height: 34px; padding: 0 11px; font-size: 9px; white-space: nowrap; }
.inline-action-form { display: inline; margin: 0; }
.inline-action-form button { font: inherit; }

.modal { width: min(92vw, 460px); border: 0; border-radius: 16px; padding: 0; box-shadow: 0 30px 80px rgba(20, 28, 47, .25); }
.modal::backdrop { background: rgba(18, 25, 45, .55); backdrop-filter: blur(2px); }
.modal form { padding: 26px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; text-align: left; }
.modal-heading h2 { margin: 7px 0 0; font-size: 20px; }
.modal-heading > button { border: 0; color: #8c96a8; background: transparent; font-size: 25px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.danger-modal { text-align: center; }
.danger-symbol { display: grid; place-items: center; width: 52px; height: 52px; margin: 2px auto 16px; border-radius: 50%; color: #d34d5a; background: #fff0f2; font-size: 24px; font-weight: 800; }
.danger-modal h2 { margin: 0; font-size: 19px; }
.danger-modal p { margin: 12px auto 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.modal-actions.centered { justify-content: center; }

.activity-panel { overflow: hidden; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-card { padding: 24px; }
.settings-card.full-width { grid-column: 1 / -1; }
.settings-title { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.settings-title h2 { margin: 0 0 5px; font-size: 14px; }
.settings-title p { margin: 0; color: var(--muted); font-size: 9px; }
.settings-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: #fff; background: #6b5ce3; font-weight: 800; }
.settings-icon.lock { color: #27799b; background: #e7f5fa; }
.settings-icon.server { color: #19815e; background: #e6f7f0; }
.setting-row { display: flex; justify-content: space-between; border-top: 1px solid #edf0f4; padding: 15px 0; color: var(--muted); font-size: 11px; }
.setting-row strong { color: #364156; }
.compact-form { max-width: 520px; gap: 13px; }
.compact-form input { min-height: 42px; font-size: 11px; }
.compact-form .button { justify-self: start; margin-top: 4px; }
.health-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.health-grid > div { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 5px 10px; border: 1px solid var(--line); border-radius: 10px; padding: 15px; }
.health-grid i { grid-row: 1 / 3; }
.health-grid span { color: var(--muted); font-size: 9px; }
.health-grid strong { font-size: 11px; }
.toast { position: fixed; z-index: 200; right: 28px; bottom: 28px; transform: translateY(20px); border-radius: 9px; padding: 12px 16px; color: #fff; background: #17233b; box-shadow: 0 15px 35px rgba(15,23,42,.22); opacity: 0; pointer-events: none; font-size: 11px; transition: opacity .2s, transform .2s; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1180px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .create-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .health-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 800px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-intro { display: none; }
    .login-panel { min-height: 100vh; padding: 30px 22px; }
    .mobile-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 56px; }
    .mobile-brand strong { font-size: 16px; }
    .sidebar { transform: translateX(-100%); transition: transform .22s; }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 50px rgba(13,20,37,.24); }
    .main-area { margin-left: 0; }
    .menu-button { display: block; }
    .breadcrumb, .status-pill, .admin-name { display: none; }
    .content { padding: 27px 18px 50px; }
    .topbar { height: 62px; padding: 0 18px; }
    .stat-grid, .settings-grid { grid-template-columns: 1fr; }
    .settings-card.full-width { grid-column: auto; }
    .create-card { padding-right: 18px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .panel-toolbar { align-items: flex-start; flex-direction: column; }
    .search-form { width: 100%; }
    .health-grid { grid-template-columns: 1fr; }
    .alert-floating { top: 72px; right: 18px; left: 18px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .bar-chart { gap: 10px; padding-right: 14px; padding-left: 14px; }
    .create-card { padding: 20px 18px 20px 70px; }
    .create-card-icon { top: 20px; left: 18px; }
    .create-form { margin-left: -52px; }
}
