:root {
    --bg: #f5f6f8;
    --card: #fff;
    --fg: #1c2230;
    --muted: #667085;
    --line: #e4e7ec;
    --acc: #2563eb;
    --danger: #dc2626;
    --sel: #e8f0fe;
    --ok: #16a34a
}

:root[data-theme=dark] {
    --bg: #0f1218;
    --card: #181c25;
    --fg: #e6e9ef;
    --muted: #93a0b4;
    --line: #2a3140;
    --acc: #5b8cff;
    --danger: #ef4444;
    --sel: #1e2a44
}

* {
    box-sizing: border-box
}

html,
body {
    margin: 0
}

body {
    background: var(--bg);
    color: var(--fg);
    font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif
}

.hidden {
    display: none !important
}

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

.err {
    color: var(--danger)
}

.top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line)
}

.brand {
    font-weight: 700;
    font-size: 16px
}

.spacer {
    flex: 1
}

nav {
    display: flex;
    gap: 4px
}

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

button {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer
}

button:hover {
    border-color: var(--acc)
}

button.primary {
    background: var(--acc);
    border-color: var(--acc);
    color: #fff
}

button.danger {
    color: var(--danger);
    border-color: var(--danger)
}

button.ghost {
    background: transparent
}

a.btn {
    display: inline-block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 12px;
    color: inherit;
    text-decoration: none
}

a.btn:hover {
    border-color: var(--acc)
}

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap
}

nav button {
    border: 0;
    background: transparent
}

nav button.active {
    background: var(--sel);
    color: var(--acc);
    font-weight: 600
}

input[type=search],
input[type=date],
select {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 10px
}

input[type=search] {
    flex: 1;
    min-width: 180px
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px
}

.card h3 {
    margin: 0 0 8px
}

.card.center,
.center {
    text-align: center;
    justify-content: center
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px
}

.row {
    display: flex;
    gap: 8px;
    margin-top: 12px
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px
}

.actions {
    position: sticky;
    top: 49px;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--line)
}

.chk {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0
}

.chip {
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    cursor: pointer;
    font-size: 13px
}

.chip:hover,
.chip.on {
    border-color: var(--acc);
    color: var(--acc)
}

.chip b {
    margin-left: 4px;
    color: var(--muted);
    font-weight: 500
}

.list {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 8px
}

.item {
    display: grid;
    grid-template-columns: 28px minmax(120px, 200px) 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    content-visibility: auto;
    contain-intrinsic-size: auto 44px
}

.item:last-child {
    border-bottom: 0
}

.item:hover {
    background: var(--sel)
}

.item.sel {
    background: var(--sel)
}

.item.unread .s {
    font-weight: 700
}

.item .s,
.item .n {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.item .meta {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    text-align: right
}

.item .snip {
    color: var(--muted);
    font-weight: 400
}

.item.drv {
    grid-template-columns: 28px 1fr 90px 100px
}

.group {
    padding: 6px 12px;
    background: var(--bg);
    font-weight: 600;
    border-bottom: 1px solid var(--line)
}

.bar {
    height: 10px;
    border-radius: 6px;
    background: var(--line);
    overflow: hidden;
    margin-top: 8px
}

.bar>div {
    height: 100%;
    background: var(--acc);
    width: 0
}

.trow {
    display: grid;
    grid-template-columns: 110px 1fr 90px 80px;
    gap: 8px;
    align-items: center;
    padding: 4px 0
}

.trow .bar {
    margin: 0
}

#jobs {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(320px, 90vw)
}

.job {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 4px 14px #0003
}

#toast {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    z-index: 60;
    background: var(--fg);
    color: var(--bg);
    padding: 8px 16px;
    border-radius: 8px;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none
}

#toast.show {
    opacity: 1
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: #0008;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px
}

.sheet {
    position: relative;
    background: var(--card);
    border-radius: 12px;
    width: min(900px, 100%);
    max-height: 92vh;
    overflow: auto;
    padding: 16px
}

.close {
    position: absolute;
    right: 12px;
    top: 12px
}

.sheet iframe {
    width: 100%;
    height: 55vh;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff
}

.sheet pre {
    white-space: pre-wrap;
    word-break: break-word
}

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

th,
td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line)
}

@media(max-width:700px) {
    .item {
        grid-template-columns: 24px 1fr auto
    }

    .item .s {
        grid-column: 2/4;
        grid-row: 2
    }

    .item.drv {
        grid-template-columns: 24px 1fr 80px
    }

    .item.drv .meta:last-child {
        display: none
    }

    .brand {
        display: none
    }

    .trow {
        grid-template-columns: 80px 1fr 70px
    }

    .trow span:last-child {
        display: none
    }
}
:root { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; }
button:disabled { opacity: .6; cursor: wait; }
input[type=number] { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.sheet { overflow-wrap: anywhere; }
.sheet h3 { margin-right: 70px; }
.row { flex-wrap: wrap; }
.item .cb { display: flex; align-items: center; justify-content: center; min-height: 28px; }
button.link {
    border: 0;
    background: none;
    padding: 0;
    color: var(--acc);
    text-decoration: underline;
    cursor: pointer
}
#toast.act { pointer-events: auto; }
#toast.act button.link { color: inherit; font-weight: 600; margin-left: 8px; }
.ico { width: 16px; height: 16px; fill: var(--muted); vertical-align: -3px; margin-right: 6px; flex: none; }
.tag { font-size: 11px; color: var(--acc); border: 1px solid var(--acc); border-radius: 999px; padding: 0 6px; margin-left: 6px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 0; }
.item.dir .n { font-weight: 600; }
.sheet h4 { margin: 18px 0 6px; }
.sheet .list { max-height: 50vh; overflow: auto; }
button.item { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; text-align: left; font: inherit; }
.item.pick { grid-template-columns: 1fr auto; }
.item.pick .n { display: flex; align-items: center; }
label.item { cursor: pointer; }
.form { display: grid; gap: 10px; margin: 12px 0; }
.form > label:not(.chk) { display: grid; gap: 4px; font-weight: 600; }
.form input[type=text], .form select { font-weight: 400; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.form .field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.form .field > span { font-weight: 600; min-width: 120px; }
input[type=text], input[type=password] { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 0; }
.sheet .row > input[type=text] { flex: 1; }
td.acts { white-space: nowrap; }
td.acts button, td.acts .btn { padding: 3px 8px; font-size: 13px; }
tr.off td { opacity: .55; }
.row.head { margin: 0 0 4px; align-items: center; }
.row.head h3 { margin: 0; }
code { overflow-wrap: anywhere; }
#appLoginForm input { min-width: 220px; }

@media(max-width:480px) {
    .top { gap: 4px; padding-inline: 8px; }
    .top button { padding-inline: 8px; }
    main { padding: 10px; }
    .grid { grid-template-columns: 1fr; }
    .toolbar > input, .toolbar > select { min-width: 0; max-width: 100%; }
    .actions { position: static; }
    .sheet { padding: 12px; }
    table { font-size: 12px; }
    td, th { padding: 5px 3px; }
    td.acts { white-space: normal; }
    .top { flex-wrap: wrap; }
    .top .spacer { display: none; }
}
