:root {
  --bg: #f4f6f3;
  --card: #ffffff;
  --text: #1b2a1f;
  --muted: #5f6f63;
  --line: #dfe5dd;
  --brand: #1f7a3f;
  --brand-dark: #165c2f;
  --brand-soft: #e5f2e8;
  --red: #b42318;
  --red-soft: #fdecea;
  --amber: #a15c07;
  --amber-soft: #fff4e0;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); padding: 7px 14px;
}
button:hover { border-color: var(--brand); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--brand-dark); }
button.ghost { background: transparent; }
button.danger { color: var(--red); }
button.small { padding: 4px 10px; font-size: 13px; }
input, select {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label { display: block; font-weight: 600; margin-bottom: 12px; }
label > input, label > select { margin-top: 5px; font-weight: 400; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
label.check input { width: auto; margin: 0; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; margin: 4px 0 0; }
.error { color: var(--red); background: var(--red-soft); padding: 8px 10px; border-radius: 8px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand small { color: var(--muted); font-weight: 500; }
.logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800;
}

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.login-card { width: 100%; max-width: 360px; padding: 28px; }
.login-card .brand { margin-bottom: 22px; }
.login-card button { width: 100%; padding: 10px; }

.top {
  display: flex; align-items: center; gap: 20px; padding: 10px 20px;
  background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
#nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
#nav button { border: none; background: transparent; color: var(--muted); font-weight: 600; }
#nav button.active { background: var(--brand-soft); color: var(--brand-dark); }
.me { display: flex; align-items: center; gap: 10px; color: var(--muted); }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.head h1 { font-size: 20px; margin: 0; }
.head .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head .tools input, .head .tools select { width: auto; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); }
.stat.red .n { color: var(--red); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbf9; }
tr:last-child td { border-bottom: none; }
td .sub { color: var(--muted); font-size: 12px; word-break: break-all; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button + button { margin-left: 6px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef0ed; color: var(--muted); }
.pill.green { background: var(--brand-soft); color: var(--brand-dark); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

dialog { border: none; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 30, 22, .45); }
#modal-form { padding: 22px; }
#modal-form h2 { margin: 0 0 16px; font-size: 18px; }
#modal-body { max-height: 65vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.site-picks { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; max-height: 220px; overflow-y: auto; margin-top: 5px; }
.site-picks label.check { margin: 6px 0; }
.site-picks .sub { color: var(--muted); font-size: 12px; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 10;
}
.more { text-align: center; margin-top: 12px; }
.mt { margin-top: 12px; }
.hint.lead { margin: -6px 0 12px; }
