:root {
  --bg: #f4f6f5; --card: #ffffff; --ink: #18221c; --muted: #66746b; --line: #dde5df;
  --brand: #1f8f4a; --brand-dark: #17733b; --brand-bg: #e7f5ec;
  --red: #c0392b; --red-bg: #fbeae8; --amber: #a86400; --amber-bg: #fff3dd; --blue: #1f5fa8; --blue-bg: #e7f0fb; --gray-bg: #eef1ef;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111613; --card: #1a211d; --ink: #e8eee9; --muted: #9aa89f; --line: #2b352f;
    --brand: #39b768; --brand-dark: #4cc97a; --brand-bg: #183223;
    --red: #ff8a7d; --red-bg: #3a1e1b; --amber: #ffc066; --amber-bg: #3a2c14; --blue: #8cbcff; --blue-bg: #18273a; --gray-bg: #232b26;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
small { display: block; color: var(--muted); font-size: 12.5px; }
.btn { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 9px; padding: 8px 14px; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--brand); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 13px; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); }
input[type=checkbox] { width: auto; }
label { display: grid; gap: 5px; font-size: 13.5px; font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.error { background: var(--red-bg); color: var(--red); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 28px; display: grid; gap: 14px; text-align: center; }
.login-card img { margin: 0 auto; }
.login-card label { text-align: left; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand b { font-size: 18px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
.head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { padding: 14px 16px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 24px; margin-top: 4px; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 160px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.actions-cell { white-space: nowrap; text-align: right; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
a { color: var(--brand-dark); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--brand-bg); color: var(--brand-dark); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.gray { background: var(--gray-bg); color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(10, 20, 14, .45); }
dialog form { display: grid; gap: 14px; padding: 20px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields .full { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--gray-bg); padding: 2px 6px; border-radius: 6px; }
.detail { display: grid; gap: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 20px; padding: 16px; }
.detail-grid div span { color: var(--muted); font-size: 12.5px; display: block; }
.section-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 10px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: calc(100vw - 32px); }
.toast.error { background: var(--red); color: #fff; }
@media (max-width: 640px) { .fields { grid-template-columns: 1fr; } .top { padding: 10px 16px; } }
