:root {
  --ink: #17211d;
  --muted: #69756f;
  --paper: #f6f4ee;
  --panel: #fffefb;
  --line: #dedfd8;
  --green: #155e4b;
  --green-dark: #0d4638;
  --mint: #dcece6;
  --orange: #d8612e;
  --red: #b23a31;
  --shadow: 0 18px 50px rgba(26, 43, 36, .08);
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.topbar {
  height: 68px; padding: 0 max(24px, calc((100vw - 1440px) / 2));
  display: flex; align-items: center; justify-content: space-between;
  background: var(--green-dark); color: white; border-bottom: 3px solid #c99a47;
}
.brand { font-family: "Microsoft YaHei UI", sans-serif; font-weight: 800; font-size: 20px; letter-spacing: .08em; }
.topbar nav { display: flex; align-items: center; gap: 22px; font-size: 14px; }
.topbar nav a { opacity: .82; }
.topbar nav a:hover { opacity: 1; }
.account { padding: 7px 12px; border: 1px solid #ffffff40; border-radius: 999px; }

.page { max-width: 1440px; margin: auto; padding: 32px 24px 56px; }
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, #39745e 0, transparent 33%),
    radial-gradient(circle at 80% 80%, #183e34 0, transparent 36%), #0d2f27;
}
.auth-card {
  width: min(440px, 100%); padding: 42px; border-radius: 22px;
  background: var(--panel); box-shadow: 0 30px 80px #001f1880;
}
.logo-mark {
  width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 26px;
  border-radius: 16px; background: var(--green); color: white; font-weight: 900; font-size: 21px;
}
.eyebrow { color: var(--orange); font-weight: 800; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 8px 0 10px; font-size: clamp(28px, 4vw, 42px); line-height: 1.12; }
h2 { margin: 0; font-size: 19px; }
h3 { font-size: 16px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; }

form label { display: grid; gap: 8px; margin: 20px 0; font-weight: 700; font-size: 14px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
  background: white; padding: 11px 13px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px #155e4b1c; }
button {
  border: 1px solid var(--line); background: white; color: var(--ink);
  border-radius: 9px; padding: 10px 15px; font-weight: 700;
}
button:hover { border-color: #a8aca6; transform: translateY(-1px); }
.primary { border-color: var(--green); background: var(--green); color: white; }
.primary:hover { background: var(--green-dark); }
.wide { width: 100%; }
.ghost { background: transparent; }
.danger, .danger.used { border-color: #f0d0ca; color: var(--red); background: #fff7f5; }
.danger-text { color: var(--red); }
.text-button { border: 0; padding: 0; color: var(--muted); background: none; }
.alert { max-width: 1440px; margin: 0 auto 18px; padding: 12px 15px; border-radius: 10px; font-size: 14px; }
.alert.error { color: #8b2621; background: #fbe7e4; border: 1px solid #f1c5bf; }
.alert.success { color: #155542; background: #e2f1eb; border: 1px solid #c4ded4; }

.tool-heading, .page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 26px; }
.tool-heading p { margin: 0; color: var(--muted); }
.license-card {
  min-width: 180px; padding: 14px 16px; border-left: 3px solid #c99a47; background: #eee9dc;
  display: grid; gap: 4px;
}
.license-card span { color: var(--muted); font-size: 12px; }
.license-card strong { font-size: 15px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
.workspace { padding: 22px; }
.history-panel { padding: 22px; grid-column: 2; grid-row: 1 / span 2; }
.filters { padding: 22px; }
.section-title { min-height: 34px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-title > div { display: flex; align-items: center; gap: 10px; }
.section-title > span, .section-title small { color: var(--muted); font-size: 12px; }
.step {
  width: 28px; height: 28px; display: grid; place-items: center; color: var(--green);
  border-radius: 50%; background: var(--mint); font-size: 11px; font-weight: 900;
}
.count { display: flex; align-items: baseline; gap: 4px; }
.count strong { color: var(--green); font-size: 29px; }
.count span { color: var(--muted); font-size: 12px; }
.load-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px; }
.load-buttons button { display: flex; justify-content: space-between; border-color: #cfdbd6; }
.load-buttons small { color: var(--muted); font-weight: 500; }
.number-pool {
  min-height: 270px; resize: vertical; border-radius: 12px; background: #f9faf7;
  font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 1.85;
}
.workspace-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 12px; }
.operation-log { margin: 0; padding-left: 25px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.operation-log li { padding: 8px 2px; border-bottom: 1px solid #ecece6; }
.empty-log { list-style: none; margin-left: -25px; }
.operation-script {
  min-height: 430px; resize: vertical; background: #f9faf7;
  font-family: Consolas, "Microsoft YaHei UI", monospace; font-size: 13px; line-height: 1.7;
}
.history-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.history-panel > .hint { margin: 10px 0 0; line-height: 1.6; }
.filter-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.filter-card { padding: 17px; border: 1px solid #e5e5df; border-radius: 12px; background: #fbfbf8; }
.filter-card h3 { margin-bottom: 12px; }
.filter-card > input + .two-actions,
.filter-card > input + .button-matrix,
.filter-card > select + select,
.filter-card > select + button { margin-top: 10px; }
.position-row, .mode-row { display: flex; align-items: center; gap: 14px; margin: 11px 0; }
.position-row label, .mode-row label { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; }
.position-row input, .mode-row input { width: auto; accent-color: var(--green); }
.position-row small { margin-left: auto; color: var(--muted); }
.two-actions, .button-matrix { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.button-matrix.quick { grid-template-columns: repeat(4, 1fr); }
.button-matrix.quick button { padding: 8px 5px; font-size: 13px; }
.used { color: var(--red); border-color: #e5b9b3; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid #ecece7; text-align: left; white-space: nowrap; font-size: 13px; }
th { color: var(--muted); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; }
td small { display: block; color: var(--muted); margin-top: 3px; }
.page > .panel { margin-bottom: 18px; }
.badge, .status { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #eee; font-size: 11px; font-weight: 800; }
.status.active { color: #146247; background: #dcefe7; }
.status.disabled { color: #9d332a; background: #f9e1de; }
.actions { display: flex; gap: 6px; }
.actions button { padding: 6px 9px; font-size: 12px; }
dialog { width: min(460px, calc(100% - 32px)); border: 0; border-radius: 16px; padding: 0; box-shadow: 0 25px 80px #10241c50; }
dialog::backdrop { background: #10241c99; backdrop-filter: blur(3px); }
.dialog-form { padding: 24px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head button { border: 0; background: none; font-size: 25px; color: var(--muted); }
.dialog-form label small { color: var(--muted); font-weight: 400; }
.toast {
  position: fixed; left: 50%; bottom: 30px; translate: -50% 20px; opacity: 0;
  pointer-events: none; padding: 11px 18px; border-radius: 999px; background: #14271f; color: white;
  box-shadow: 0 10px 35px #0003; transition: .2s ease;
}
.toast.show { opacity: 1; translate: -50% 0; }

@media (max-width: 920px) {
  .tool-grid { grid-template-columns: 1fr; }
  .history-panel { grid-column: 1; grid-row: auto; }
  .filter-columns { grid-template-columns: 1fr; }
  .load-buttons { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 620px) {
  .page { padding: 22px 10px 40px; }
  .topbar { height: auto; min-height: 60px; padding: 10px; align-items: center; gap: 8px; }
  .brand { flex: 0 0 auto; white-space: nowrap; font-size: 16px; letter-spacing: .03em; }
  .topbar nav {
    min-width: 0; flex: 1; flex-wrap: nowrap; justify-content: flex-end;
    gap: 3px; font-size: 12px; white-space: nowrap;
  }
  .topbar nav a { padding: 7px 4px; }
  .account { display: none; }
  .tool-heading, .page-heading { align-items: flex-start; gap: 14px; }
  .tool-heading { display: grid; }
  .license-card { min-width: 0; }
  .workspace, .filters, .history-panel { padding: 13px; }
  .load-buttons { grid-template-columns: repeat(2, 1fr); }
  .workspace-actions { display: grid; grid-template-columns: repeat(2, 1fr); }
  .button-matrix.quick { grid-template-columns: repeat(3, 1fr); }
  .workspace button, .filters button, .history-panel button { min-height: 42px; }
  .text-button { min-height: auto !important; }
  .number-pool { min-height: 220px; }
  .operation-script { min-height: 260px; }
  .position-row { gap: 9px; flex-wrap: wrap; }
  .position-row small { width: 100%; margin-left: 0; }
  .auth-card { padding: 28px 22px; }
}
