:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #17213d;
  background: #eef4fb;
  font-synthesis: none;
  --navy: #101632;
  --brand: #1d9fd7;
  --brand-strong: #1769b3;
  --accent: #f052a5;
  --surface: #ffffff;
  --line: #dbe5ef;
  --muted: #718096;
  --danger: #d9365f;
  --success: #11875d;
  --warning: #c77100;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #eef4fb; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e9f8ff 0%, #eef4fb 42%, #e8eef7 100%); }
.login-card { width: min(420px, 100%); display: grid; gap: 17px; padding: 34px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 24px 70px rgb(18 52 92 / 14%); }
.login-brand { display: flex; align-items: center; gap: 10px; color: #17213d; font-size: 17px; font-weight: 750; }
.login-card h1 { font-size: 26px; }
.login-card .eyebrow { margin: 5px 0 -10px; }
.login-help { margin: -7px 0 2px; color: var(--muted); font-size: 14px; }
.login-card .inline-message { margin: 0; }
.login-card .button { width: 100%; margin-top: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 30px 16px 22px; color: white; background: linear-gradient(180deg, #101632 0%, #071f3e 100%); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 30px; font-size: 19px; font-weight: 750; letter-spacing: 0.02em; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 5px rgb(29 159 215 / 14%); }
.nav { display: grid; gap: 9px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid transparent; border-radius: 10px; color: #cbd8ec; background: transparent; text-align: left; font-weight: 650; }
.nav-item:hover { background: rgb(255 255 255 / 7%); color: white; }
.nav-item.is-active { color: white; background: #1769b3; border-color: rgb(255 255 255 / 10%); box-shadow: 0 8px 22px rgb(0 0 0 / 18%); }
.nav-mark { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 7px; background: rgb(255 255 255 / 12%); font-size: 13px; }
.sidebar-note { margin: auto 12px 0; color: #8194b0; font-size: 12px; }

.main { min-width: 0; padding: 0 30px; }
.topbar { min-height: 102px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid #d9e4ef; }
.eyebrow { margin: 0 0 6px; color: var(--brand-strong); font-size: 11px; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
h1 { margin: 0; color: #11182e; font-size: 28px; letter-spacing: -0.02em; }
.topbar-meta { display: flex; align-items: center; gap: 14px; }
.environment { padding: 6px 11px; border: 1px solid #f7afd1; border-radius: 999px; color: #c32972; background: #fff7fb; font-size: 12px; }
.administrator { font-size: 14px; color: #34405d; }
.logout-button { padding: 4px 0; border: 0; color: var(--brand-strong); background: transparent; font-size: 13px; font-weight: 700; }
.logout-button:hover { text-decoration: underline; }
.view { padding: 26px 0 0; }

.panel { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 28px rgb(40 73 115 / 7%); }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 20px; border-bottom: 1px solid var(--line); }
.toolbar label { flex: 0 0 auto; }
.search-field { flex-basis: 300px !important; }
input, select { width: 100%; min-height: 42px; padding: 0 13px; border: 1px solid #cfdbe8; border-radius: 9px; outline: none; color: #1d2945; background: white; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(29 159 215 / 13%); }
select { width: auto; min-width: 128px; }
.toolbar-actions { display: flex; gap: 10px; margin-left: auto; }
.button { min-height: 42px; padding: 0 17px; border-radius: 9px; border: 1px solid transparent; font-weight: 700; }
.button-primary { color: white; background: var(--brand-strong); border-color: var(--brand-strong); }
.button-primary:hover { background: #105a9b; }
.button-secondary { color: var(--brand-strong); background: white; border-color: #86bbe1; }
.button-secondary:hover { background: #f3faff; }
.button-danger { color: white; background: var(--danger); border-color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1040px; }
th, td { padding: 16px 18px; border-bottom: 1px solid #e5edf5; text-align: left; white-space: nowrap; font-size: 13px; }
th { color: #53617b; background: #f9fbfd; font-weight: 700; }
td { color: #26334f; }
tbody tr:hover { background: #fbfdff; }
.code-text { font-family: "Cascadia Code", Consolas, monospace; color: #17213d; }
.device-text { font-family: "Cascadia Code", Consolas, monospace; color: #4f607b; }
.status { display: inline-flex; align-items: center; min-height: 27px; padding: 0 9px; border-radius: 7px; font-size: 12px; font-weight: 700; }
.status-bound, .status-configured { color: var(--success); background: #ecfaf4; border: 1px solid #bde8d3; }
.status-unbound, .status-missing { color: var(--warning); background: #fff7e9; border: 1px solid #f4d69e; }
.status-disabled { color: #69758a; background: #f1f3f6; border: 1px solid #d9dee7; }
.actions-column { width: 210px; }
.row-actions { display: flex; align-items: center; gap: 11px; }
.link-button { padding: 2px 0; border: 0; color: var(--brand-strong); background: transparent; font-weight: 650; }
.link-button:hover { text-decoration: underline; }
.link-button.is-danger { color: var(--danger); }
.table-state { height: 190px; color: var(--muted); text-align: center; }
.pagination { display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 0 20px; color: var(--muted); font-size: 13px; }
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.icon-button, .page-number { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #d3deea; border-radius: 8px; background: white; color: var(--brand-strong); }
.page-number { color: white; background: var(--brand-strong); border-color: var(--brand-strong); }
.pagination select { min-height: 36px; min-width: 100px; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0 0 6px; font-size: 22px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.secret-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.secret-card { padding: 21px; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: 0 8px 24px rgb(40 73 115 / 6%); }
.secret-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.secret-card h3 { margin: 0; font-size: 18px; }
.secret-meta { display: grid; gap: 10px; margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.secret-meta-row { display: flex; justify-content: space-between; gap: 16px; }
.secret-meta-row strong { color: #31405d; font-weight: 650; }
.secret-card .button { width: 100%; }
.security-note { display: flex; gap: 16px; margin-top: 18px; padding: 16px 18px; border: 1px solid #cce2f2; border-radius: 11px; color: #425675; background: #f5fbff; font-size: 13px; }
.security-note strong { color: var(--brand-strong); }
.inline-message { margin: 16px 20px 0; padding: 12px 14px; border-radius: 9px; font-size: 13px; }
.inline-message.is-error { color: #9b2448; background: #fff1f5; border: 1px solid #f3c0d0; }
.footer { padding: 22px 0 26px; color: #7b879c; text-align: center; font-size: 12px; }

.modal { width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 14px; background: transparent; box-shadow: 0 25px 80px rgb(8 23 48 / 30%); }
.modal::backdrop { background: rgb(9 20 43 / 48%); backdrop-filter: blur(2px); }
.modal-card { background: white; border-radius: 14px; overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 19px; }
.modal-close { border: 0; background: transparent; color: #7c879b; font-size: 26px; line-height: 1; }
.modal-body { display: grid; gap: 15px; padding: 21px; color: #43516b; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 21px 20px; }
.form-field { display: grid; gap: 7px; }
.form-field span { color: #3b4863; font-size: 13px; font-weight: 650; }
.one-time-code { display: block; padding: 14px; overflow-wrap: anywhere; border: 1px dashed #86bbe1; border-radius: 9px; color: #0e527f; background: #f3faff; font-family: "Cascadia Code", Consolas, monospace; font-size: 15px; }
.warning-copy { margin: 0; color: #a54800; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 360px; padding: 13px 16px; border-radius: 10px; color: white; background: #17213d; box-shadow: 0 14px 36px rgb(17 24 46 / 28%); font-size: 13px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding-inline: 0; font-size: 0; }
  .nav-item { justify-content: center; padding-inline: 8px; font-size: 0; }
  .nav-mark { font-size: 13px; }
  .sidebar-note { display: none; }
  .toolbar { flex-wrap: wrap; }
  .toolbar-actions { width: 100%; justify-content: flex-end; }
  .secret-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; }
  .brand { display: none; }
  .nav { width: 100%; grid-template-columns: 1fr 1fr; }
  .nav-item { font-size: 13px; }
  .main { padding: 0 14px; }
  .topbar { min-height: 84px; }
  .eyebrow, .administrator { display: none; }
  h1 { font-size: 23px; }
  .toolbar label, .search-field { flex: 1 1 100% !important; }
  .toolbar select { width: 100%; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .pagination { align-items: flex-start; gap: 12px; flex-direction: column; padding-block: 16px; }
  .security-note { flex-direction: column; gap: 6px; }
}
