:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --line: #e2e5ea;
    --text: #1c2330;
    --muted: #6b7482;
    --primary: #1f5fd1;
    --primary-dark: #184ba6;
    --pos: #12733a;
    --neg: #c0271d;
    --warn: #9a6400;
    --radius: 8px;
}

* { box-sizing: border-box; }

html { font-size: 14px; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { margin: 0; font-size: 1.5rem; }
h2 { margin: 0; font-size: 1.05rem; }
h3 { margin: 0; font-size: 1.1rem; }
h2 small { margin-left: 6px; color: var(--muted); font-weight: 400; font-size: .85rem; }

.sub { color: var(--muted); font-size: .82rem; margin: 2px 0 0; }
.sub.inline { display: inline; margin-left: 6px; }

/* top bar */
.top {
    display: flex; align-items: center; gap: 24px;
    padding: 0 20px; height: 52px;
    background: var(--card); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { padding: 6px 12px; border-radius: 6px; color: var(--muted); }
.top nav a.on { background: #e9f0fd; color: var(--primary); font-weight: 600; }
.top nav a:hover { text-decoration: none; color: var(--text); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); }

.wrap { max-width: 1680px; margin: 0 auto; padding: 18px 20px 48px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .two { grid-template-columns: minmax(0, 1fr); } }

.tiles { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tile { flex: 1 1 170px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfc; }
.tile span { display: block; color: var(--muted); font-size: .8rem; }
.tile b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* tables */
.scroll { overflow-x: auto; }
.scroll.tall { max-height: 46vh; overflow-y: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; white-space: nowrap; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
tfoot td { font-weight: 700; background: #fafbfc; border-top: 2px solid var(--line); border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.wrap-text { max-width: 320px; overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--muted); }
tr.dim td { opacity: .6; }
tr.picked td { background: #eef4ff; }
tr.group td { background: #f4f6f9; font-weight: 600; }
td.indent { padding-left: 28px; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: #eceff3; color: var(--muted); white-space: nowrap; }
.tag.ok, .tag.success { background: #e3f4ea; color: var(--pos); }
.tag.pending { background: #fdf1d8; color: var(--warn); }
.tag.failed, .tag.cancelled { background: #fbe6e4; color: var(--neg); }

/* buttons and fields */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 14px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f1f3f6; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn:disabled, .btn.off { opacity: .5; cursor: not-allowed; }

input, select {
    width: 100%; padding: 7px 10px; border: 1px solid #cfd4dc; border-radius: 6px;
    background: #fff; color: var(--text); font: inherit;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid #9dbdf5; outline-offset: 1px; border-color: var(--primary); }
input[readonly] { background: #f4f5f7; color: var(--muted); }
label { display: block; font-size: .85rem; font-weight: 600; color: #3a4350; }
label input, label select { margin-top: 4px; font-weight: 400; }
[hidden] { display: none !important; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; padding: 4px 8px; }
.filters input[type=search] { width: 190px; }

.grid { display: grid; gap: 12px 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-all { grid-column: 1 / -1; }
.right { display: flex; justify-content: flex-end; gap: 8px; }
.hint { margin: 0; color: var(--muted); font-size: .85rem; min-height: 1.2em; }
@media (max-width: 640px) { .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); } }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }

/* messages */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; overflow-wrap: anywhere; }
.flash.ok { background: #e9f6ee; border-color: #b9dfc7; color: #0d5a2c; }
.flash.bad { background: #fdecea; border-color: #f2c1bc; color: #96201a; }

/* dialogs */
dialog { width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 18px; border: 0; border-radius: 10px; box-shadow: 0 18px 60px rgba(15, 23, 42, .3); color: var(--text); }
dialog.wide { width: min(900px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.x { border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.x:hover { color: var(--text); }

/* login */
.login { max-width: 340px; margin: 12vh auto 0; padding: 24px; display: grid; gap: 14px; }
.login h1 { text-align: center; }
