:root {
  --bg: #eef2fb; --card: #ffffff; --ink: #1d2433; --muted: #6b7489; --line: #e3e8f2;
  --primary: #2f5bea; --primary-ink: #ffffff; --primary-soft: #e8eefe;
  --ok: #16a34a; --ok-soft: #e7f6ec; --warn: #d97706; --warn-soft: #fdf3e3; --bad: #dc2626; --bad-soft: #fdecec;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* Topbar */
.topbar { background: linear-gradient(120deg, #2f5bea, #5b7cf5); color: #fff; padding: 14px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.2); display: grid; place-items: center; font-weight: 700; }
.brand small { display: block; font-weight: 400; opacity: .85; font-size: 12px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: .95; }
.topbar .btn { background: rgba(255,255,255,.16); color: #fff; border-color: transparent; }
.topbar .btn:hover { background: rgba(255,255,255,.28); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 24px 60px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }

/* Buttons & inputs */
.btn { font: inherit; font-size: 13px; font-weight: 500; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: #f5f7fc; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
label.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.field > input, label.field > select, label.field > textarea { color: var(--ink); }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { border: 0; background: transparent; font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 10px; color: var(--muted); cursor: pointer; }
.tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.seg { display: inline-flex; background: #f0f3fa; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; font: inherit; font-size: 13px; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); font-weight: 500; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; background: #f8faff; position: sticky; top: 0; white-space: nowrap; }
th.sortable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8faff; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f0f3fa; color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.blue { background: var(--primary-soft); color: var(--primary); }

.bar { height: 8px; background: #edf0f7; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.stat { display: grid; gap: 2px; }
.stat b { font-size: 26px; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 28, 50, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1100px, 100%); }
.modal h3 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 99; font-size: 13px; box-shadow: var(--shadow); }
.toast.err { background: var(--bad); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

@media (max-width: 720px) {
  .wrap { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
