:root {
  --bg: #f6f7fb; --panel: #ffffff; --text: #151827; --muted: #6b7088; --line: #e6e8f0;
  --brand: #4f46e5; --brand-2: #eef0ff; --ok: #0f9d58; --ok-bg: #e7f6ee; --warn: #b26b00; --warn-bg: #fff4de;
  --bad: #d93025; --bad-bg: #fde9e7; --info: #1a73e8; --info-bg: #e8f0fe; --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1018; --panel: #171a26; --text: #e8eaf3; --muted: #9298b3; --line: #262a3b;
    --brand: #7c74ff; --brand-2: #23224a; --ok-bg: #12301f; --warn-bg: #352a10; --bad-bg: #3a1714; --info-bg: #14264a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 16px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Consolas, monospace; }
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 16px; padding: 4px 8px 16px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: #fff; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--brand-2); color: var(--brand); font-weight: 600; }
.nav .count { margin-left: auto; background: var(--brand); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; }
.nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.main { padding: 24px 28px 60px; max-width: 1300px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat .v { font-size: 26px; font-weight: 700; } .stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--brand); } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--bad); } .btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; } .grow { flex: 1; }
label.f { display: block; margin-bottom: 12px; } label.f > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
label.f > small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
input[type=text], input[type=number], input[type=password], input[type=email], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); border-color: var(--brand); }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; margin: 4px 14px 4px 0; }
.switch { position: relative; width: 40px; height: 22px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .15s; cursor: pointer; }
.switch span:before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); } .switch input:checked + span:before { transform: translateX(18px); }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.placed, .badge.awarded, .badge.on, .badge.auto { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.pending_review, .badge.draft, .badge.review, .badge.approved, .badge.queued { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.failed, .badge.off, .badge.rejected { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.dry_run, .badge.freelancer, .badge.upwork { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.awarded { background: #0f9d58; color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); font: inherit; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.bid { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: var(--panel); }
.bid .title { font-weight: 600; font-size: 15px; }
.bid .meta { color: var(--muted); font-size: 12px; margin: 4px 0 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.bid .desc { color: var(--muted); font-size: 13px; max-height: 64px; overflow: hidden; margin-bottom: 8px; white-space: pre-wrap; }
.bid .desc.open { max-height: none; }
.bid textarea { min-height: 140px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chip { background: var(--brand-2); color: var(--brand); border-radius: 99px; padding: 2px 10px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.chip button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }
.dropdown { position: relative; } .dropdown .menu { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; max-height: 260px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.dropdown .menu div { padding: 6px 10px; cursor: pointer; } .dropdown .menu div:hover { background: var(--brand-2); }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bar-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-chart .bar { width: 100%; max-width: 34px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bar-chart .bar.win { background: var(--ok); }
.bar-chart .lbl { font-size: 10px; color: var(--muted); }
.hbar { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 12px; }
.hbar .track { flex: 1; background: var(--bg); height: 8px; border-radius: 99px; overflow: hidden; } .hbar .fill { background: var(--warn); height: 100%; }
.engine { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.engine .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); } .engine.on .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--info-bg); color: var(--text); margin-bottom: 16px; border: 1px solid transparent; }
.notice.warn { background: var(--warn-bg); } .notice.bad { background: var(--bad-bg); }
.auth { max-width: 380px; margin: 10vh auto; }
#toast { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
#toast div { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
#toast div.err { background: var(--bad); color: #fff; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; padding: 20px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.mobile-top { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; } .side { position: fixed; z-index: 40; left: -260px; width: 240px; transition: .2s; } .side.open { left: 0; }
  .mobile-top { display: flex; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; }
  .main { padding: 16px; } .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } table { font-size: 12px; } }
