:root {
  color-scheme: light;
  --ink: #172b35;
  --ink-soft: #52656e;
  --muted: #74858d;
  --paper: #f2f6f7;
  --surface: #ffffff;
  --line: #dce5e8;
  --navy: #142a35;
  --navy-2: #1c3945;
  --teal: #167c80;
  --teal-soft: #e1f1ef;
  --amber: #9a6818;
  --amber-soft: #fbf1dc;
  --green: #237252;
  --green-soft: #e5f3eb;
  --red: #a3424a;
  --red-soft: #fae9e9;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-size: 14px; line-height: 1.55; }
a { color: inherit; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #42a9a6; outline-offset: 2px; }
.shell { min-height: 100vh; }
.rail { position: fixed; inset: 0 auto 0 0; z-index: 5; width: 232px; display: flex; flex-direction: column; padding: 25px 17px 18px; color: #e9f1f2; background: var(--navy); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 28px; text-decoration: none; }
.brand-mark { width: 37px; height: 37px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px 10px 10px 3px; color: #fff; background: var(--teal); font-weight: 800; font-size: 20px; }
.brand strong { display: block; font-size: 15px; letter-spacing: .01em; }
.brand small { display: block; margin-top: 2px; color: #9db1b8; font-size: 9px; letter-spacing: .14em; }
.rail-label { padding: 4px 10px 9px; color: #8299a1; font-size: 11px; }
.nav-links { display: grid; gap: 5px; }
.nav-link { min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 11px; color: #bdcbd0; text-decoration: none; border-radius: 8px; transition: background .15s ease, color .15s ease; }
.nav-link:hover { color: #fff; background: var(--navy-2); }
.nav-link.is-active { color: #fff; background: #24505a; box-shadow: inset 3px 0 #48b5aa; }
.nav-glyph { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid #57717a; border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.rail-bottom { margin-top: auto; }
.safety-note { display: flex; align-items: center; gap: 8px; margin: 0 3px 15px; padding: 10px; color: #bdd2d3; background: #1a3640; border-radius: 8px; font-size: 11px; }
.safety-dot { width: 7px; height: 7px; border-radius: 50%; background: #57b89b; box-shadow: 0 0 0 3px #2b514e; }
.logout-button { width: 100%; padding: 9px 10px; color: #bdcbd0; text-align: left; background: transparent; border: 1px solid #39515a; border-radius: 8px; cursor: pointer; }
.logout-button:hover { color: #fff; border-color: #769099; }
.main-area { min-height: 100vh; margin-left: 232px; padding: 38px clamp(20px, 4vw, 58px) 20px; }
.mobile-brand { display: none; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 0 25px; }
.page-heading h1 { margin: 0; color: var(--ink); font-size: clamp(25px, 3vw, 33px); line-height: 1.2; letter-spacing: -.035em; }
.page-heading p { max-width: 690px; margin: 8px 0 0; color: var(--ink-soft); }
.heading-aside { color: var(--muted); font-size: 12px; }
.notices { display: grid; gap: 8px; margin-bottom: 18px; }
.notice { padding: 11px 14px; border-radius: 8px; }
.notice-success { color: var(--green); background: var(--green-soft); }
.notice-error { color: var(--red); background: var(--red-soft); }
.notice-warning { color: var(--amber); background: var(--amber-soft); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 13px; }
.toolbar form, .filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.field, .select-field { min-height: 39px; padding: 8px 11px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.field::placeholder { color: #91a0a6; }
.field:focus, .select-field:focus { border-color: var(--teal); outline: 3px solid #d6eeec; }
.field-search { width: min(340px, 54vw); }
.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 13px; color: #fff; text-decoration: none; background: var(--teal); border: 1px solid var(--teal); border-radius: 7px; cursor: pointer; font-weight: 650; }
.button:hover { background: #10696d; border-color: #10696d; }
.button-secondary { color: var(--ink-soft); background: #fff; border-color: var(--line); }
.button-secondary:hover { color: var(--ink); background: #f7fafb; border-color: #b8c8cd; }
.button-danger { color: var(--red); background: #fff; border-color: #e9c6c8; }
.button-danger:hover { background: var(--red-soft); border-color: #dba4a7; }
.button-small { min-height: 31px; padding: 4px 9px; font-size: 12px; }
.panel { margin-bottom: 17px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 20px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 11px 15px; color: var(--muted); background: #f7f9fa; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 650; white-space: nowrap; }
td { padding: 13px 15px; border-bottom: 1px solid #edf1f2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.subtle { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.row-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.inline-form { display: inline; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; color: var(--ink-soft); background: #edf2f3; border-radius: 999px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.badge::before { width: 6px; height: 6px; content: ""; border-radius: 50%; background: #85969c; }
.badge-pending { color: var(--amber); background: var(--amber-soft); }
.badge-pending::before { background: #c08a2f; }
.badge-processing { color: #23647c; background: #e4f0f5; }
.badge-processing::before { background: #3685a1; }
.badge-success { color: var(--green); background: var(--green-soft); }
.badge-success::before { background: #398862; }
.badge-failed { color: var(--red); background: var(--red-soft); }
.badge-failed::before { background: #c05a61; }
.metric-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 18px; }
.metric { padding: 7px 11px; color: var(--ink-soft); background: #e7eef0; border-radius: 7px; font-size: 12px; }
.metric strong { margin-left: 4px; color: var(--ink); font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-field { display: grid; gap: 5px; min-width: 0; }
.form-field label { color: var(--ink-soft); font-size: 12px; font-weight: 650; }
.form-field .field, .form-field .select-field { width: 100%; }
.form-hint { color: var(--muted); font-size: 11px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.credential-state { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 12px; }
.credential-state::before { width: 7px; height: 7px; content: ""; border-radius: 50%; background: #398862; }
.credential-missing { color: var(--amber); }
.credential-missing::before { background: #c08a2f; }
.empty-state { padding: 45px 18px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink-soft); font-size: 15px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 15px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
.pagination-actions { display: flex; gap: 7px; }
.pagination a { padding: 5px 9px; color: var(--ink-soft); background: #fff; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; }
.pagination a:hover { border-color: var(--teal); color: var(--teal); }
.info-box { padding: 12px 14px; color: var(--ink-soft); background: #f0f6f6; border-left: 3px solid var(--teal); border-radius: 5px; font-size: 12px; }
.warning-box { padding: 12px 14px; color: #765116; background: var(--amber-soft); border-left: 3px solid #c08a2f; border-radius: 5px; }
.qr-frame { display: grid; place-items: center; margin: 18px 0 12px; padding: 14px; background: #f2f6f7; border: 1px solid var(--line); border-radius: 10px; }
.qr-frame img { width: 210px; max-width: 100%; height: auto; }
.setup-key { margin: 0 auto; max-width: 500px; padding: 10px; color: var(--ink); background: #f4f7f8; border-radius: 7px; text-align: center; word-break: break-all; }
.error-line { margin: 12px 0 0; padding: 10px 12px; color: var(--red); background: var(--red-soft); border-radius: 7px; }
.gate-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 8px; margin: 0 0 17px; padding: 0; list-style: none; }
.gate-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; color: var(--ink-soft); background: #f6f9f9; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; }
.gate-ready { color: var(--green); }
.gate-blocked { color: var(--red); }
.limit-editor { position: relative; margin-top: 7px; }
.limit-editor summary { color: var(--teal); cursor: pointer; font-size: 11px; font-weight: 650; }
.limit-editor form { display: grid; gap: 7px; width: min(260px, 100%); margin-top: 7px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 24px rgb(13 31 39 / 8%); }
.limit-editor .field { width: 100%; min-width: 0; }
.limit-editor .button { width: 100%; }
.result-text { max-width: 320px; overflow-wrap: anywhere; color: var(--ink-soft); font-size: 11px; }
.page-footer { display: flex; justify-content: space-between; gap: 12px; padding: 18px 2px 0; color: #85949a; font-size: 11px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: none; place-items: center; padding: 18px; background: rgb(14 30 37 / 55%); }
.modal-backdrop.is-open { display: grid; }
.modal { width: min(570px, 100%); max-height: 90vh; overflow: auto; padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 22px 70px rgb(13 31 39 / 24%); }
.modal-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.modal-title h2 { margin: 0; font-size: 19px; }
.icon-button { width: 34px; height: 34px; color: var(--ink-soft); background: #f2f6f7; border: 0; border-radius: 7px; cursor: pointer; }
.text-link { color: var(--teal); text-decoration: none; }
.text-link:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .rail { width: 205px; }
  .main-area { margin-left: 205px; padding-inline: 23px; }
  .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .rail { position: static; width: auto; padding: 11px 15px; }
  .rail .brand { display: none; }
  .rail-label, .rail-bottom { display: none; }
  .nav-links { display: flex; gap: 6px; overflow-x: auto; }
  .nav-link { min-height: 38px; flex: 0 0 auto; padding-inline: 9px; font-size: 12px; }
  .nav-glyph { width: 19px; height: 19px; }
  .main-area { margin-left: 0; padding: 18px 14px 16px; }
  .mobile-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
  .mobile-brand .brand-mark { width: 30px; height: 30px; font-size: 16px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 8px; margin-bottom: 20px; }
  .heading-aside { margin-top: -3px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar form { display: grid; grid-template-columns: 1fr auto; }
  .field-search { width: 100%; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .panel-head, .panel-body { padding: 15px; }
  .page-footer { flex-direction: column; gap: 3px; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .table-wrap table { min-width: 800px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
