:root {
  color-scheme: light;
  --ink: #172923;
  --ink-muted: #586b62;
  --forest: #142c24;
  --forest-active: #263f34;
  --pine: #286447;
  --lime: #d4f69b;
  --lime-hover: #c7ef83;
  --paper: #f5f6f1;
  --surface: #fff;
  --rule: #dbe2d9;
  --danger: #9a3332;
  --danger-bg: #fbeeed;
  --radius: 12px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 300px; margin: 0; }
h1, h2, p, dl, dd { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.muted { color: var(--ink-muted); }
.monospace { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; }

.connecting {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--ink-muted);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f1f8ee;
  font-size: 16px;
  font-weight: 750;
}

.brand-mark {
  position: relative;
  flex: 0 0 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--lime);
}

.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  top: 10px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--forest);
  border-radius: 2px;
  transform: rotate(-9deg);
}

.brand-mark::before { left: 7px; }
.brand-mark::after { left: 15px; top: 13px; background: var(--lime); }

.login-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: min(100% - 64px, 900px);
  min-height: 440px;
  margin: max(48px, calc((100vh - 440px) / 2)) auto 48px;
  border: 1px solid var(--rule);
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 40px;
  background: var(--forest);
  color: #f1f8ee;
}

.login-brand h1 {
  margin-top: auto;
  margin-bottom: 12px;
  color: var(--lime);
  font-size: clamp(40px, 5vw, 60px);
  line-height: 1.12;
  letter-spacing: -.06em;
}

.login-brand p { color: #c4d7c9; }
.login-panel { display: grid; align-items: center; padding: 52px; }
.login-form { display: flex; flex-direction: column; gap: 18px; }
.login-form h2 { font-size: 25px; margin-bottom: 8px; }

.admin-view {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 27px 18px;
  background: var(--forest);
  color: #edf7ef;
}

.sidebar .brand-lockup { margin: 0 8px 43px; }
.sidebar :focus-visible { outline-color: var(--lime); }
.section-label { margin: 0 13px 11px; color: #b1c8b8; font-size: 12px; font-weight: 700; }
.product-list { margin: 0; padding: 0; list-style: none; }
.product-list li { margin-bottom: 7px; }

.product-button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  background: transparent;
  color: #e7f0e9;
}

.product-button:hover { background: #1c382d; }
.product-button[aria-current="true"] {
  border-color: #416051;
  background: var(--forest-active);
  color: #f6fff4;
}

.product-button span:last-child { min-width: 0; overflow-wrap: anywhere; }
.product-badge {
  display: grid;
  min-width: 30px;
  height: 26px;
  place-items: center;
  border-radius: 5px;
  padding-inline: 5px;
  background: #314d40;
  color: #e1efdf;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .035em;
}

.product-button[aria-current="true"] .product-badge { background: var(--lime); color: var(--forest); }
.main-area { min-width: 0; }

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 35px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-muted);
  font-weight: 700;
}

.workspace { width: min(100%, 1400px); margin-inline: auto; padding: 30px 35px 48px; }
.product-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 27px;
}

.product-header h1 { margin-top: 4px; font-size: clamp(30px, 3vw, 42px); line-height: 1.14; overflow-wrap: anywhere; }
.product-prefix { color: var(--pine); font-weight: 750; font-size: 12px; letter-spacing: .06em; }

.panel {
  min-width: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.placeholder { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 24px; }
.records { overflow: hidden; }
.records-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 19px 22px 0;
}

.records-header h2 { font-size: 19px; }
.filters {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(108px, 170px) auto;
  align-items: end;
  gap: 10px;
  padding: 17px 22px 20px;
}

.field { display: grid; gap: 6px; min-width: 0; font-size: 13px; font-weight: 700; }
.field input, .field textarea, .field select, #issued-serials {
  min-height: 41px;
  width: 100%;
  min-width: 0;
  border: 1px solid #cdd8d0;
  border-radius: 7px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
}

.field input::placeholder { color: #64766c; }
.field textarea, #issued-serials { resize: vertical; }

.button {
  display: inline-flex;
  min-height: 41px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  white-space: nowrap;
  font-weight: 700;
  line-height: 1.3;
}

.button.primary { border-color: #bfdc9a; background: var(--lime); color: #163125; }
.button.primary:hover:not(:disabled) { background: var(--lime-hover); }
.button.secondary { border-color: #cdd8d0; background: var(--surface); color: var(--ink); }
.button.secondary:hover:not(:disabled), .button.quiet:hover:not(:disabled) { background: #edf2ec; }
.button.quiet { background: transparent; color: var(--pine); }
.button.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.button.danger:hover:not(:disabled) { background: #792827; }
.button:disabled { opacity: .5; }
.button.add-product { margin-top: 6px; width: 100%; justify-content: flex-start; background: transparent; color: #d7ebdc; }
.button.add-product:hover { background: #1c382d; }
.button.add-product span { font-size: 16px; }
.button-group { display: flex; align-items: center; gap: 8px; }

.notice {
  padding: 10px 13px;
  border: 1px solid #d1e3c9;
  border-radius: 8px;
  background: #edf6e9;
  color: #224a35;
  overflow-wrap: anywhere;
}

#workspace-message { margin-bottom: 18px; }
.notice[data-tone="danger"] { border-color: #e8c6c4; background: var(--danger-bg); color: #832e2c; }
.form-message { min-height: 1.4em; color: var(--ink-muted); overflow-wrap: anywhere; font-size: 13px; }
.form-message[data-tone="danger"], .records-message[data-tone="danger"] { color: var(--danger); }
.records-message { padding: 23px; border-top: 1px solid var(--rule); color: var(--ink-muted); }

.license-table { width: 100%; border-collapse: collapse; text-align: left; }
.license-table th, .license-table td { padding: 12px 12px; border-top: 1px solid var(--rule); vertical-align: middle; }
.license-table th { background: #eef2eb; color: #485e53; font-size: 12px; font-weight: 750; white-space: nowrap; }
.license-table th:first-child, .license-table td:first-child { padding-left: 22px; }
.license-table th:last-child, .license-table td:last-child { padding-right: 22px; }
.license-table td { font-size: 13px; }
.license-table tbody tr:hover { background: #f9fbf7; }
.license-table .suffix { font-size: 14px; font-weight: 750; letter-spacing: .06em; }
.license-table .mobile-label { display: none; }
.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--pine);
  font-weight: 700;
}

.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-button[data-action="revoke"] { color: var(--danger); }

.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 20px;
  background: #edf1ed;
  color: #4b5e54;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.state-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.state-pill[data-state="bound"] { background: #e3f2de; color: #205a37; }
.state-pill[data-state="revoked"] { background: var(--danger-bg); color: var(--danger); }
.row-placeholder { color: var(--ink-muted); }

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-size: 13px;
}

.pagination .button { min-height: 36px; }
.dialog {
  width: min(500px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  border: 1px solid var(--rule);
  border-radius: 17px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 20px 70px #13291f33;
}

.dialog::backdrop { background: #10291e77; }
.dialog-content { display: grid; gap: 14px; padding: 23px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-header h2 { font-size: 22px; }
.button.close-button { align-self: flex-start; width: 34px; min-height: 34px; padding: 0; background: transparent; color: var(--ink-muted); font-size: 25px; }
.button.close-button:hover:not(:disabled) { background: #edf2ec; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.dialog .form-message:empty { display: none; }

#issued-serials {
  background: #f7f9f5;
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
}

.device-details { display: grid; gap: 12px; }
.device-details dt { color: var(--ink-muted); font-size: 12px; font-weight: 700; }
.device-details dd { overflow-wrap: anywhere; }

@media (max-width: 1075px) {
  .admin-view { grid-template-columns: 190px minmax(0, 1fr); }
  .topbar, .workspace { padding-inline: 24px; }
}

@media (max-width: 760px) {
  .login-view { width: min(100% - 28px, 450px); min-height: 0; grid-template-columns: 1fr; margin-block: 28px; }
  .login-brand, .login-panel { padding: 28px; }
  .login-brand h1 { margin-top: 25px; }
  .admin-view { grid-template-columns: 1fr; }
  .sidebar { padding: 15px 17px 12px; }
  .sidebar .brand-lockup { margin: 0 0 12px; }
  .product-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
  .section-label { margin: 0 3px 0 0; }
  .product-list { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-width: 0; }
  .product-list li { margin: 0; max-width: 175px; }
  .product-button { min-height: 36px; padding: 4px 8px; gap: 7px; }
  .button.add-product { width: auto; margin: 0; min-height: 36px; padding: 5px 8px; }
  .topbar { min-height: 54px; }
  .topbar, .workspace { padding-inline: 17px; }
  .workspace { padding-top: 23px; }
  .records-header { padding-inline: 15px; }
  .filters { padding-inline: 15px; }
  .license-table thead { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  .license-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; padding: 13px 15px; border-top: 1px solid var(--rule); }
  .license-table tbody td { border: 0; padding: 0; min-width: 0; }
  .license-table tbody td:first-child, .license-table tbody td:last-child { padding-inline: 0; }
  .license-table .mobile-label { display: block; margin-bottom: 3px; color: var(--ink-muted); font-size: 11px; font-weight: 700; }
  .pagination { padding-inline: 15px; }
}

@media (max-width: 450px) {
  .filters { grid-template-columns: 1fr auto; }
  .search-field { grid-column: 1 / -1; }
  .dialog-content { padding: 17px; }
}
