/* Layui overlay. Tokens stay for tests; do not restyle Layui chrome. */

@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-body: #f4f6fa;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-input: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #eef1f5;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #edf2f7;
  --border-dark: #cbd5e1;
  --border-focus: #1e9fff;
  --text-main: #182433;
  --text-regular: #334155;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-dim: #cbd5e1;
  --primary: #1e9fff;
  --primary-hover: #0d8aee;
  --primary-active: #0b7ad4;
  --primary-light: #e8f4ff;
  --primary-border: #9ed2ff;
  --primary-text: #0d8aee;
  --success: #16b777;
  --success-light: #edf8f3;
  --success-border: #b8e5c1;
  --success-text: #16b777;
  --warning: #ffb800;
  --warning-light: #fff8e6;
  --warning-border: #fcdfa2;
  --warning-text: #d48806;
  --danger: #ff5722;
  --danger-light: #fff1ee;
  --danger-border: #f2aaaa;
  --danger-text: #ff5722;
  --info: #31bdec;
  --info-light: #ebf5fa;
  --info-border: #bee3f8;
  --info-text: #2b6cb0;
  --font-sans: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

html, body, button, input, select, textarea,
.layui-layout, .layui-layout-body, .layui-header, .layui-side, .layui-body,
.layui-nav, .layui-nav-item, .layui-nav-item a, .layui-logo, .layui-btn,
.layui-table, .layui-input, .layui-textarea, .layui-form, .layui-form-label,
.layui-card, .layui-elem-quote, .layui-laypage, .layui-tab-title {
  font-family: var(--font-sans) !important;
}
body {
  background: var(--bg-body);
  color: rgba(0, 0, 0, 0.85);
  font-size: 14px;
}

table {
  width: 100%;
  background: #fff;
  color: #666;
  margin: 10px 0;
  border-collapse: collapse;
}
table th,
table td {
  padding: 9px 15px;
  border: 1px solid #eee;
  font-size: 14px;
}
table th {
  background: #fafafa;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  color: #333;
}
.table-card table,
.table-card .layui-table { margin: 0; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="email"],
input:not([type]),
select,
textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 38px;
  line-height: 1.3;
  padding: 8px 15px;
  border: 1px solid #eee;
  background: #fff;
  border-radius: 2px;
  color: rgba(0, 0, 0, 0.85);
  font-size: 14px;
}
textarea {
  height: auto;
  min-height: 90px;
  line-height: 1.6;
  resize: vertical;
}
input:focus, select:focus, textarea:focus { border-color: #16b777; }
input[readonly] { background: #f6f6f6; color: #999; }
input[type="checkbox"],
input[type="radio"] {
  display: inline-block;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0 6px 0 0;
  border: none;
  background: none;
  vertical-align: middle;
}
.actions input[type="text"],
.actions input:not([type]),
.actions input[type="number"],
.page-head select,
.actions select {
  display: inline-block;
  width: auto;
  min-width: 160px;
}
.center-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.center-line label {
  flex-direction: row;
  align-items: center;
  white-space: nowrap;
  margin: 0;
}
.center-line input {
  display: inline-block;
  width: 280px;
}
.search-box input {
  display: inline-block;
  width: 100%;
  height: 30px;
  border: 0;
  padding: 0 8px;
}
#batch-text, textarea.mono { font-family: var(--font-mono) !important; }

.qk-top-only .layui-side { display: none !important; }
.qk-top-only .layui-body,
.qk-top-only .layui-footer { left: 0 !important; }
.qk-top-only .layui-logo { width: 180px; font-weight: 700; }
.qk-top-only .layui-body.wrap { padding: 16px; overflow: auto; }

.alert-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #fff1f0;
  border-bottom: 1px solid #ffccc7;
  color: #cf1322;
  padding: 8px 16px;
  font-weight: 600;
}
.alert-banner a { color: #cf1322; }

.page-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; font-size: 20px; }
.page-head p { margin: 6px 0 0; color: var(--text-secondary); font-size: 13px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px;
}
.stat-card.alert { border-color: var(--warning); background: var(--warning-light); }
.stat-card .stat-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.stat-card .stat-label { font-size: 12px; color: var(--text-secondary); }
.stat-card .stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: left;
}
.stat-card .stat-sub { margin-top: 6px; font-size: 12px; color: var(--text-secondary); display: flex; justify-content: space-between; }

.filter-toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.filters { display: flex; gap: 0; }
.filters a {
  display: inline-block;
  padding: 0 14px;
  height: 32px;
  line-height: 30px;
  border: 1px solid #d2d2d2;
  margin-left: -1px;
  background: #fff;
  color: #333;
  text-decoration: none;
  font-size: 13px;
}
.filters a:hover { color: #1e9fff; }
.filters a.on { background: #1e9fff; border-color: #1e9fff; color: #fff; }
.search-box { display: flex; align-items: center; border: 1px solid #d2d2d2; background: #fff; padding: 0 8px; width: 260px; }
.search-box input { border: 0; outline: 0; height: 30px; width: 100%; }

.table-card { background: #fff; border: 1px solid var(--border); }
.table-card .layui-table { margin: 0; }

.mono, .num, .col-id, .col-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
th.col-id, td.col-id { text-align: left; }
.num, th.col-num, td.col-num, th.col-act, td.col-act { text-align: right; }
td.col-id > a, td.col-id > .meta, td.col-id > .num,
td.col-num > a, td.col-num > .meta, td.col-num > .num, td.col-num > div {
  display: block;
  text-align: inherit;
}
th.col-num, td.col-num { white-space: nowrap; }
.meta { font-size: 12px; color: var(--text-secondary); }
.err-line, .cell-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-line { color: var(--danger); font-size: 12px; }
td.empty { text-align: center; padding: 40px 16px; color: var(--text-secondary); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; margin-right: 4px; vertical-align: middle; }
.dot.on { background: #16b777; }
.dot.off { background: #cbd5e1; }

.pill {
  display: inline-block;
  padding: 0 8px;
  height: 20px;
  line-height: 18px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
}
.pill.pending_assign, .pill.unlocked { background: #f1f5f9; }
.pill.dispatched, .pill.betting { background: #e8f4ff; color: #0d8aee; border-color: #9ed2ff; }
.pill.success, .pill.settled, .pill.enabled, .pill.locked, .pill.acked_success { background: #edf8f3; color: #16b777; border-color: #b8e5c1; }
.pill.pending_confirm, .pill.warn { background: #fff8e6; color: #d48806; border-color: #fcdfa2; }
.pill.failed, .pill.conflict, .pill.disabled, .pill.frozen, .pill.bad, .pill.acked_failed { background: #fff1ee; color: #ff5722; border-color: #f2aaaa; }

.ball-tag {
  display: inline-block;
  font-family: var(--font-mono);
  padding: 0 6px;
  background: #e8f4ff;
  color: #0d8aee;
  border: 1px solid #9ed2ff;
  margin-left: 4px;
}

.card, .alert-box, .kv-box {
  background: #fff;
  border: 1px solid var(--border);
  padding: 14px;
  margin-bottom: 12px;
}
.alert-box.warn-alert { background: var(--warning-light); border-color: var(--warning-border); }
.alert-box.bad-alert { background: var(--danger-light); border-color: var(--danger-border); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.kv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.actions { display: flex; gap: 8px; align-items: center; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.quick-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

button:not(.layui-btn):not(.chip-btn), .btn:not(.layui-btn) {
  display: inline-block;
  height: 32px;
  line-height: 30px;
  padding: 0 14px;
  background: #1e9fff;
  border: 1px solid #1e9fff;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
}
button.ghost, .btn.ghost {
  background: #fff;
  border-color: #d2d2d2;
  color: #333;
}
button.sm, .btn.sm { height: 28px; line-height: 26px; padding: 0 10px; font-size: 12px; }
button.success, .btn.success { background: #16b777; border-color: #16b777; }
button.warn, .btn.warn { background: #ffb800; border-color: #ffb800; color: #fff; }
button.bad, .btn.bad { background: #ff5722; border-color: #ff5722; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #666; }
.chip-btn {
  background: #f6f6f6;
  border: 1px solid #d2d2d2;
  padding: 2px 8px;
  cursor: pointer;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #2f363c;
}
.login-card { width: 420px; }
.login-card h1 { margin: 8px 0 4px; font-size: 20px; }
.login-card .sub, .login-card .meta { color: #999; font-size: 13px; }
.login-card .meta { text-align: center; }
.error {
  background: #fff1ee;
  border: 1px solid #ff5722;
  color: #ff5722;
  padding: 8px 10px;
  margin-bottom: 10px;
}

@media (max-width: 1100px) {
  .stats-grid, .grid, .grid.two, .kv-grid { grid-template-columns: 1fr 1fr; }
}
