:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1f2328; --muted: #6b7280; --line: #e5e7eb;
  --pos: #15803d; --neg: #c2410c; --accent: #2563eb; --danger: #b91c1c;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { word-break: break-all; background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: #111827; color: #fff; }
.top .brand { color: #fff; font-weight: 700; font-size: 15px; }
.top nav a { color: #cbd5e1; margin-right: 18px; }
.top nav a:hover { color: #fff; }
main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 60px; }

h1 { margin: 2px 0 0; font-size: 22px; }
h2 { margin: 0 0 12px; font-size: 16px; }
h3 { margin: 0 0 8px; font-size: 14px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card img { width: 100%; height: auto; display: block; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.grid2 form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.tile.alert { border-left: 3px solid var(--neg); }
.tile .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tile .v { font-size: 20px; font-weight: 650; margin-top: 2px; }
.tile .v small { font-size: 12px; font-weight: 400; color: var(--muted); }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--muted); }
.small { font-size: 12px; } .sub { font-size: 11px; color: var(--muted); }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; letter-spacing: .03em; }
.tag.sell { background: #fee2e2; color: #991b1b; } .tag.buy { background: #dbeafe; color: #1e40af; }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: 12px; background: #fafbfc; position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: #f8fafc; }
th.sorthead { cursor: pointer; user-select: none; }
th.sorthead:hover { color: var(--ink); }
th[data-dir=asc]::after { content: " ▲"; font-size: 9px; }
th[data-dir=desc]::after { content: " ▼"; font-size: 9px; }
table.matrix td { vertical-align: top; }

form.picker, form.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
form.filters { margin-bottom: 10px; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.grow { flex: 1; min-width: 220px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: var(--ink); }
input.w6 { width: 7em; }
textarea { width: 100%; }
button, .btn { font: inherit; font-weight: 550; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }
button.ghost, .btn.ghost { background: #fff; color: var(--ink); border-color: #d1d5db; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.small, .btn.small { padding: 4px 10px; font-size: 12px; }
.summary { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.bulkbar { display: flex; gap: 10px; align-items: center; margin: 6px 0 10px; flex-wrap: wrap; }

.editform { display: flex; flex-direction: column; gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.formactions { display: flex; gap: 10px; }

.flash { padding: 9px 14px; border-radius: 8px; background: #ecfdf5; border: 1px solid #a7f3d0; margin-bottom: 12px; font-size: 13px; }
.flash.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.top .who { margin-left: auto; font-size: 12.5px; color: #94a3b8; }
.top .who a { color: #cbd5e1; margin-left: 10px; }
.login { max-width: 360px; margin: 60px auto; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login input { width: 100%; }
