:root {
  color: #18221d;
  background: #f4f6f4;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --border: #e2e8e3;
  --muted: #68736c;
  --primary: #286849;
  --primary-dark: #1f523a;
  --danger: #b23b3b;
  --shadow: 0 18px 55px rgba(33, 50, 40, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f6f4; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, #e8f1eb 0, #f4f6f4 42%); }
.login-card { width: min(420px, 100%); padding: 42px; border: 1px solid var(--border); border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; color: white; background: var(--primary); font-weight: 800; letter-spacing: -.04em; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 13px; flex: 0 0 auto; }
.eyebrow { margin: 22px 0 7px; color: var(--primary); font-size: 12px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(25px, 4vw, 32px); letter-spacing: -.035em; }
h2 { margin-bottom: 5px; font-size: 19px; letter-spacing: -.02em; }
h3 { margin-bottom: 12px; font-size: 15px; }
.muted, .panel-head p { color: var(--muted); }
.stack-lg { display: grid; gap: 18px; margin-top: 28px; }
label { display: grid; gap: 7px; color: #39433d; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #d8dfda; border-radius: 11px; padding: 11px 13px; color: #18221d; background: white; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #71a68a; box-shadow: 0 0 0 3px rgba(40,104,73,.1); }
textarea { resize: vertical; }
.form-error { min-height: 18px; margin: -6px 0 -4px; color: var(--danger); font-size: 13px; }

.button { min-height: 39px; border: 1px solid transparent; border-radius: 10px; padding: 9px 15px; font-weight: 700; font-size: 13px; transition: background .15s, border-color .15s, transform .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button.primary { color: white; background: var(--primary); }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { color: var(--primary); border-color: #c9d9cf; background: #f2f7f4; }
.button.ghost { color: #4f5c54; border-color: var(--border); background: white; }
.button.danger { color: white; background: var(--danger); }
.button.full { width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 25px 18px; border-right: 1px solid var(--border); background: #fbfcfb; }
.brand-row { display: flex; align-items: center; gap: 11px; padding: 0 8px 28px; }
.brand-row strong, .brand-row small { display: block; }
.brand-row strong { font-size: 14px; }
.brand-row small { margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .06em; }
nav { display: grid; gap: 7px; }
.nav-item { display: grid; gap: 2px; width: 100%; border: 0; border-radius: 12px; padding: 11px 13px; text-align: left; color: #59645d; background: transparent; }
.nav-item span { font-weight: 750; }
.nav-item small { color: #8a938d; }
.nav-item:hover { background: #f0f4f1; }
.nav-item.active { color: var(--primary); background: #eaf2ed; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px; color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #36a269; box-shadow: 0 0 0 4px #e5f3eb; }

.workspace { min-width: 0; }
.topbar { height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 38px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.82); backdrop-filter: blur(12px); }
.topbar .eyebrow { margin: 0 0 4px; }
.topbar h1 { margin: 0; font-size: 23px; }
.account { display: flex; align-items: center; gap: 16px; text-align: right; }
.account strong, .account small { display: block; }
.account small { margin-top: 3px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.page { padding: 30px 38px 50px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.summary-card { padding: 20px 22px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 30px rgba(33,50,40,.035); }
.summary-card span, .summary-card small { display: block; color: var(--muted); font-size: 12px; }
.summary-card strong { display: block; margin: 11px 0 2px; font-size: 28px; letter-spacing: -.04em; }
.summary-card.accent { color: white; border-color: var(--primary); background: var(--primary); }
.summary-card.accent span, .summary-card.accent small { color: #d9ece1; }
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); box-shadow: 0 10px 34px rgba(33,50,40,.04); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px 18px; }
.panel-head p { margin: 0; font-size: 12px; }
.filter-row { display: flex; align-items: end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-soft); }
.filter-row label { min-width: 150px; }
.filter-row label span { font-size: 11px; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 18px; color: var(--muted); background: #fbfcfb; font-size: 11px; text-align: left; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 15px 18px; border-top: 1px solid #edf0ed; vertical-align: middle; }
tbody tr:hover { background: #fafcfa; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.bound { color: #26704c; background: #e7f4ec; }
.badge.disabled, .badge.unbound { color: #9b4545; background: #faecec; }
.link-button { border: 0; padding: 5px; color: var(--primary); background: none; font-weight: 750; }
.empty { padding: 45px; color: var(--muted); text-align: center; }
.panel-foot { padding: 14px 24px; text-align: center; }

dialog { width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 36px); overflow: auto; border: 1px solid var(--border); border-radius: 19px; padding: 0; color: inherit; background: white; box-shadow: 0 28px 90px rgba(20,34,26,.22); }
dialog::backdrop { background: rgba(22,32,26,.42); backdrop-filter: blur(3px); }
dialog.compact { width: min(480px, calc(100vw - 28px)); }
dialog.wide { width: min(920px, calc(100vw - 28px)); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: start; padding: 22px 24px 17px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.96); }
.modal-head .eyebrow { margin: 0 0 5px; }
.modal-head h2 { margin: 0; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: white; font-size: 21px; line-height: 1; }
.modal-body { padding: 22px 24px; }
.modal-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 9px; padding: 15px 24px; border-top: 1px solid var(--border); background: rgba(255,255,255,.96); }
.notice { margin: 0; padding: 12px 14px; border-radius: 10px; color: #715a25; background: #fff8e8; font-size: 12px; }
.code-list { display: grid; gap: 8px; }
.code-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.code-row code { overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; margin-bottom: 22px; }
.detail-field { padding: 13px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.detail-field span, .detail-field strong { display: block; }
.detail-field span { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.detail-field strong { font-size: 13px; overflow-wrap: anywhere; }
.section-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 24px 0 10px; }
.section-row h3 { margin: 0; }
.mini-list { display: grid; gap: 9px; }
.mini-card { padding: 13px 14px; border: 1px solid var(--border); border-radius: 11px; }
.mini-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.mini-card p { margin: 3px 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.metadata { white-space: pre-wrap; word-break: break-word; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 20; display: grid; gap: 8px; }
.toast { max-width: 380px; padding: 12px 15px; border: 1px solid var(--border); border-radius: 11px; color: #263029; background: white; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { color: #8b3434; border-color: #edcaca; background: #fff8f8; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 13px 18px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand-row { padding: 0 0 12px; }
  nav { display: flex; }
  .nav-item { width: auto; }
  .sidebar-foot { display: none; }
  .topbar { height: auto; padding: 18px 20px; }
  .page { padding: 20px; }
  .summary-grid { grid-template-columns: 1fr; }
  .filter-row { align-items: stretch; flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .login-card { padding: 28px 22px; }
  .topbar { align-items: flex-start; }
  .account > div { display: none; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal-actions { flex-wrap: wrap; }
}
