:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #14213d;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #163d63;
  --brand-2: #1d5f87;
  --accent: #0e7490;
  --good: #067647;
  --warn: #b54708;
  --bad: #b42318;
  --shadow: 0 10px 30px rgba(16, 24, 40, .08);
  --radius: 14px;
}
* { box-sizing: border-box; }
html { font-family: "Noto Sans CJK SC", "Microsoft YaHei", "PingFang SC", Arial, sans-serif; color: var(--ink); background: var(--bg); }
body { margin: 0; min-height: 100vh; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: linear-gradient(180deg, #0d2338, #123a58); color: #fff; overflow-y: auto; }
.brand { padding: 4px 10px 24px; border-bottom: 1px solid rgba(255,255,255,.15); }
.brand strong { display: block; font-size: 24px; letter-spacing: .02em; }
.brand span { display: block; color: rgba(255,255,255,.68); font-size: 12px; margin-top: 6px; line-height: 1.5; }
.nav { display: grid; gap: 6px; margin-top: 20px; }
.nav a { color: rgba(255,255,255,.76); padding: 11px 12px; border-radius: 9px; font-size: 14px; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.sidebar-footer { margin-top: 24px; padding: 16px 10px 0; border-top: 1px solid rgba(255,255,255,.15); font-size: 12px; color: rgba(255,255,255,.68); }
.sidebar-footer button { margin-top: 10px; width: 100%; }
.main { min-width: 0; padding: 26px 30px 48px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.page-header h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.page-header p { margin: 7px 0 0; color: var(--muted); max-width: 900px; line-height: 1.65; }
.kicker { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; }
.flash { margin: 0 0 18px; padding: 12px 15px; border: 1px solid #a6f4c5; background: #ecfdf3; color: #05603a; border-radius: 10px; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card h2, .card h3 { margin: 0 0 14px; }
.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { margin-top: 7px; font-size: 29px; font-weight: 750; letter-spacing: -.03em; }
.metric .sub { margin-top: 4px; color: var(--muted); font-size: 12px; }
.section { margin-top: 20px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 10px; }
.section-title h2 { margin: 0; font-size: 18px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 13px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; color: #475467; font-size: 12px; font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fcfcfd; }
.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef2f6; color: #344054; white-space: nowrap; }
.status.good, .status.ACTIVE, .status.PAID, .status.PUBLISHED, .status.COMPLETED, .status.CONVERTED { background: #dcfae6; color: var(--good); }
.status.warn, .status.EXPIRING, .status.PENDING_PAYMENT, .status.UNDER_REVIEW, .status.STAGED, .status.GRACE_PERIOD { background: #fef0c7; color: var(--warn); }
.status.bad, .status.FAILED, .status.EXPIRED, .status.OPEN, .status.SUSPENDED, .status.REJECTED { background: #fee4e2; color: var(--bad); }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: #344054; font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #d0d5dd; border-radius: 9px; padding: 9px 10px; background: #fff; color: var(--ink); font: inherit; font-size: 13px; }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(14,116,144,.12); border-color: var(--accent); }
button, .button { border: 0; border-radius: 9px; padding: 9px 13px; background: var(--brand); color: #fff; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: 6px; }
button:hover, .button:hover { background: var(--brand-2); text-decoration: none; }
button.secondary, .button.secondary { color: var(--brand); background: #eaf2f8; }
button.danger { background: var(--bad); }
button.small-button { padding: 6px 9px; font-size: 11px; }
.action-list { display: grid; gap: 10px; }
.action { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.action-priority { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #eef4ff; color: #3538cd; font-weight: 800; }
.progress { height: 7px; background: #eaecf0; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.empty { padding: 30px; color: var(--muted); text-align: center; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #1c5276, #0c1f31 56%); }
.login-card { width: min(440px, 100%); padding: 34px; border-radius: 18px; background: rgba(255,255,255,.98); box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.login-card h1 { margin: 0; font-size: 28px; }
.login-card p { color: var(--muted); line-height: 1.6; }
.login-card form { display: grid; gap: 14px; margin-top: 24px; }
.login-card button { padding: 12px; font-size: 14px; }
.error { padding: 11px; color: var(--bad); background: #fef3f2; border: 1px solid #fecdca; border-radius: 9px; }
.details { padding: 12px 0; border-top: 1px solid var(--line); }
summary { cursor: pointer; color: var(--brand-2); font-weight: 700; }
pre { white-space: pre-wrap; word-break: break-word; background: #101828; color: #d1e9ff; padding: 12px; border-radius: 9px; max-height: 280px; overflow: auto; font-size: 11px; }
@media (max-width: 1120px) { .grid.cards { grid-template-columns: repeat(2, 1fr); } .grid.three { grid-template-columns: 1fr; } }
@media (max-width: 840px) { .app-shell { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } .nav { grid-template-columns: repeat(2, 1fr); } .main { padding: 20px 16px 40px; } .grid.two, .form-grid { grid-template-columns: 1fr; } .page-header { display: block; } }

/* v1.3.1 white-label control shell. Keep product controls externally mountable. */
html[data-theme="dark"] {
  --bg: #0b1420;
  --panel: #111f2d;
  --ink: #e6edf5;
  --muted: #a4b2c1;
  --line: #294055;
  --brand: #2f759f;
  --brand-2: #68b5df;
  --accent: #4fb8c9;
  --shadow: 0 10px 30px rgba(0, 0, 0, .28);
}
html[data-theme="dark"] th { background: #172a3b; color: #c3cfdb; }
html[data-theme="dark"] tr:hover td { background: #162737; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background: #0d1a26; color: var(--ink); border-color: #395269; }
html[data-theme="dark"] .login-card { background: rgba(17, 31, 45, .98); }
html[data-theme="dark"] .flash { background: #0d392c; color: #a7f3d0; border-color: #176b4a; }

.control-bar { display: flex; justify-content: flex-end; margin: -4px 0 18px; min-height: 36px; }
.login-control-bar { position: fixed; z-index: 5; top: 18px; right: 18px; }
.control-key-mount { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; min-height: 34px; }
.control-key {
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(16, 24, 40, .08);
}
.control-key:hover { background: var(--bg); color: var(--brand-2); }
.control-key[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 560px) {
  .control-key span:last-child { display: none; }
  .control-key { width: 34px; height: 34px; padding: 0; }
}
