:root {
  --bg: #eef3fb;
  --card: #fff;
  --ink: #142033;
  --muted: #66758a;
  --line: #e4ebf5;
  --blue: #2f6bff;
  --blue-2: #1d4ed8;
  --nav: #101827;
  --ok: #12805c;
  --warn: #b45309;
  --bad: #c24141;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "PingFang SC", "Noto Sans SC", sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top, #dbe7ff, #eef3fb 45%); }
.login-card, .card { background: var(--card); border-radius: 20px; box-shadow: 0 20px 50px rgba(20, 32, 51, .06); }
.login-card { width: min(420px, calc(100% - 32px)); padding: 32px; }
.brand { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--blue); color: white; font-weight: 700; }
.login-card h1 { margin: 16px 0 8px; }
.login-card p, .muted { color: var(--muted); line-height: 1.6; }
label { display: block; margin: 16px 0; font-size: 14px; }
input, select, textarea { width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #f8fafc; }
textarea { min-height: 88px; resize: vertical; }
button { border: 0; border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.primary { background: var(--blue); color: white; }
.primary:hover { background: var(--blue-2); }
.ghost { background: #eef3fb; color: var(--ink); }
.danger { background: #fee2e2; color: var(--bad); }
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
aside { background: #1b2433; color: #d5deea; padding: 18px 12px; max-height: 100vh; overflow: auto; position: sticky; top: 0; }
.brand-row { display: flex; gap: 10px; align-items: center; margin-bottom: 22px; color: white; }
.brand-row small { display: block; color: #8ea0b8; }
nav { display: grid; gap: 4px; }
nav button { text-align: left; background: transparent; color: #c5d0de; border-radius: 8px; padding: 10px 12px; }
nav button.active, nav button:hover { background: #2f6bff; color: white; }
.nav-parent { font-weight: 700; color: #fff; }
.nav-parent::after { content: "▾"; float: right; color: #8ea0b8; }
.nav-group.open .nav-parent::after { content: "▴"; }
.nav-sub { display: none; margin: 2px 0 6px; padding-left: 8px; }
.nav-group.open .nav-sub { display: grid; gap: 2px; }
.nav-sub button { font-size: 13px; padding: 8px 12px; }
main { padding: 22px 24px 40px; background: #f5f7fb; }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
header h2 { margin: 0 0 4px; font-size: 20px; }
header p { margin: 0; color: var(--muted); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.live { background: #16a34a; color: white; border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.panel { background: white; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.panel-head, .metrics { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); margin-bottom: 14px; }
.metric { background: white; border-radius: 12px; padding: 14px 16px; text-align: left; border-top: 3px solid #94a3b8; }
.metric.ok { border-top-color: #16a34a; }
.metric.bad { border-top-color: #dc2626; }
.metric b { display: block; font-size: 26px; margin-top: 6px; }
.metric small, .muted { color: var(--muted); }
.table-wrap { overflow: auto; background: white; border-radius: 12px; }
.grid-table { width: 100%; border-collapse: collapse; background: white; }
.grid-table th, .grid-table td { text-align: left; padding: 12px; border-bottom: 1px solid #e8edf5; font-size: 13px; vertical-align: top; }
.grid-table th { color: #64748b; background: #f8fafc; font-weight: 600; }
.ops { display: flex; gap: 6px; flex-wrap: wrap; }
.ops button, .ghost { background: #fff; border: 1px solid #dbe3ee; border-radius: 8px; padding: 6px 8px; }
.danger { color: #dc2626; border-color: #fecaca !important; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.pill.on { background: #dcfce7; color: #15803d; }
.pill.off { background: #f1f5f9; color: #64748b; }
.ok-text { color: #16a34a; }
.bad-text { color: #dc2626; }
.mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; overflow: auto; z-index: 5; padding: 24px 0; }
.dialog { width: min(920px, calc(100% - 32px)); overflow: visible; background: white; border-radius: 12px; padding: 18px; }
.lang-bar, .btn-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.lang-bar button.on { background: #2f6bff; color: white; }
.btn-head { justify-content: space-between; }
.btn-row { display: flex; gap: 8px; margin-bottom: 8px; }
.btn-row input { flex: 1; }
#composer-preview { display: block; max-width: 240px; max-height: 160px; margin: 8px 0; border-radius: 8px; }
.cke_bottom .cke_voice_label { position: static; width: auto; height: auto; overflow: visible; clip: auto; margin-right: 6px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.packet-bar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; background: white; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.packet-bar label { margin: 0; min-width: 140px; }
.packet-actions { display: flex; gap: 8px; margin: 0 0 12px; }
.packet-actions .add { background: #16a34a; color: white; }
.packet-actions .del { background: #f97316; color: white; }
.packet-form .packet-row { display: grid; grid-template-columns: 148px 1fr; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid #eef2f7; }
.packet-form .packet-row[hidden] { display: none; }
.packet-form .packet-row > span { padding-top: 10px; color: #334155; }
.packet-form .hint { color: #94a3b8; font-size: 12px; margin-top: 4px; }
.radios { display: flex; gap: 18px; flex-wrap: wrap; padding-top: 8px; }
.radios label { display: flex; gap: 6px; align-items: center; margin: 0; }
.radios input { width: auto; margin: 0; }
.packet-form input[disabled], .packet-form select[disabled] { color: #64748b; }
.dialog-head button { font-size: 22px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.card { padding: 18px; }
.stat b { display: block; font-size: 28px; margin-top: 6px; }
.rule { border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; background: white; }
.rule-text { background: #f4f7ff; border-radius: 12px; padding: 12px 14px; line-height: 1.7; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row label { flex: 1; min-width: 140px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; background: white; border-radius: 16px; overflow: hidden; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.split { display: grid; grid-template-columns: 320px 1fr; gap: 14px; }
.list button { width: 100%; text-align: left; background: white; margin-bottom: 8px; border: 1px solid transparent; }
.list button.active { border-color: var(--blue); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #e8eefc; color: var(--blue-2); font-size: 12px; }
.tag.off { background: #f1f5f9; color: var(--muted); }
.tag.ok { background: #e7f6ef; color: var(--ok); }
.tag.bad { background: #fde8e8; color: var(--bad); }
.error { color: var(--bad); min-height: 1.2em; }
.toast { position: fixed; right: 16px; bottom: 16px; background: #142033; color: white; padding: 12px 16px; border-radius: 12px; opacity: 0; transform: translateY(8px); transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: #0f172a; color: #dbeafe; padding: 12px; border-radius: 12px; line-height: 1.6; }
.config-box { border: 1px solid #f3d48a; background: #fffaf0; border-radius: 12px; padding: 12px 14px; margin: 8px 0 4px; }
.config-box h4 { margin: 0 0 8px; font-size: 14px; }
.inserts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.inserts button { background: #eef3ff; color: var(--blue-2); border-radius: 8px; padding: 4px 8px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; margin: 0; }
.preview-box { white-space: pre-wrap; background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 12px; line-height: 1.6; font-size: 13px; }
.metric.warn { border-top-color: #d97706; }
@media (max-width: 980px) {
  .app, .grid, .split { grid-template-columns: 1fr; }
  aside { padding-bottom: 8px; }
}
