* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #f5b301; --brand-d: #e0a200; --ink: #1f2430; --muted: #6b7280;
  --line: #e9ebef; --bg: #f3f4f6; --side: #20222e; --side-2: #2a2d3b; --side-ink: #c7cbd6;
}
html, body { height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #272b3a, #3b4256); padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.login-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.login-head h1 { font-size: 20px; }
.field { margin-bottom: 14px; }
.field input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; }
.captcha-row { display: flex; gap: 10px; }
.captcha-row input { flex: 1; }
.captcha-img { width: 120px; height: 44px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fafafa; object-fit: contain; }
.err { color: #c0392b; font-size: 13px; min-height: 18px; margin-bottom: 10px; }

/* ---------- Buttons ---------- */
.btn { padding: 10px 16px; border: none; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--brand-d); }
.btn.block { width: 100%; padding: 12px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.lang { display: inline-flex; gap: 3px; }
.lang button { border: 1px solid var(--line); background: #fff; padding: 4px 9px; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--muted); }
.lang button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: 212px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 8px; padding: 18px 18px 14px; color: #fff; font-weight: 700; }
.logo .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; color: #20222e; font-size: 13px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 0; }
.nav-item, .nav-sub a { display: flex; align-items: center; gap: 10px; padding: 11px 18px; color: var(--side-ink); cursor: pointer; text-decoration: none; font-size: 14px; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover, .nav-sub a:hover { background: var(--side-2); color: #fff; }
.nav-item.active, .nav-sub a.active { background: var(--brand); color: #20222e; border-radius: 22px; margin: 0 10px; width: auto; padding: 11px 16px; font-weight: 600; }
.nav-ico { width: 18px; text-align: center; opacity: .9; }
.nav-sub a { padding-left: 46px; font-size: 13px; }
.nav-caret { margin-left: auto; font-size: 11px; opacity: .6; }
.side-foot { padding: 14px 18px; }
.logout { width: 100%; border: 1px solid var(--brand); color: var(--brand); background: none; padding: 9px; border-radius: 20px; cursor: pointer; font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--brand); color: #20222e; height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.crumb { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.hamb { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: #20222e; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #20222e; color: #fff; display: grid; place-items: center; font-size: 13px; }
.content { padding: 22px; }

/* ---------- Cards / dashboard ---------- */
.section-title { font-size: 18px; font-weight: 700; margin: 4px 0 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border-radius: 10px; padding: 16px 18px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.stat h4 { font-size: 14px; margin-bottom: 12px; }
.stat .split { display: flex; gap: 12px; }
.stat .cell { flex: 1; background: #f6f7f9; border-radius: 8px; padding: 12px; text-align: center; }
.stat .cell .n { font-size: 24px; font-weight: 700; }
.stat .cell .l { color: var(--muted); font-size: 12px; margin-top: 2px; }

.panel { background: #fff; border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.panel h3 { font-size: 15px; margin-bottom: 14px; }
.panel .legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.panel .legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-right: 5px; vertical-align: middle; }
.chart-box { width: 100%; overflow-x: auto; }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 18px; }
.form-row > label { display: block; font-weight: 600; margin-bottom: 7px; }
.form-row .req { color: #e4572e; }
.form-row input[type=text], .form-row textarea, .form-row select { width: 100%; max-width: 560px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.form-row textarea { min-height: 84px; resize: vertical; }
.radio-row { display: flex; gap: 20px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.upload-box { width: 120px; height: 120px; border: 1px dashed #cfd3da; border-radius: 10px; display: grid; place-items: center; color: #b4b9c2; font-size: 30px; cursor: pointer; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.badge { padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.done { background: #e6f6ec; color: #1f9254; }
.badge.failed { background: #fdeaea; color: #c0392b; }
.badge.queued, .badge.building, .badge.sending { background: #fff5e0; color: #b7791f; }

/* ---------- Responsive ---------- */
.overlay { display: none; }
@media (max-width: 820px) {
  .side { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .25s; height: 100vh; }
  .shell.open .side { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .shell.open .overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .hamb { display: block; }
  .content { padding: 16px; }
  .section-title { font-size: 16px; }
}
@media (max-width: 420px) {
  .content { padding: 12px; }
  .stat .cell .n { font-size: 20px; }
  .cards { gap: 12px; }
  .crumb { font-size: 13px; }
}
