html { font-family: ui-sans-serif, system-ui, "PingFang SC", "Microsoft YaHei", sans-serif; }
body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgb(6 13 27) 0%, rgb(2 6 23) 48%, rgb(3 8 22) 100%);
}
body.theme-dark {
  color: #e2e8f0;
  --card-radius: 10px;
  --card-border: rgb(30 41 59 / 0.92);
  --card-bg: linear-gradient(180deg, rgb(15 23 42 / 0.82), rgb(2 6 23 / 0.52));
  --card-shadow: 0 14px 34px rgb(0 0 0 / 0.2);
  --card-hover-border: rgb(71 85 105);
  --card-hover-bg: linear-gradient(180deg, rgb(15 23 42 / 0.96), rgb(15 23 42 / 0.66));
  --card-hover-shadow: 0 18px 42px rgb(0 0 0 / 0.26);
  --card-muted-bg: rgb(15 23 42 / 0.48);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgb(34 197 94 / 0.04), transparent 24%, rgb(14 165 233 / 0.05) 62%, rgb(245 158 11 / 0.035)),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 0.018) 0 1px, transparent 1px 34px);
}
button { -webkit-tap-highlight-color: transparent; }
button svg { pointer-events: none; }

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.animate-pulse { animation: pulse-soft 2s ease-in-out infinite; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

table { border-collapse: collapse; }
table th, table td { vertical-align: middle; }
tbody tr td { padding-top: 0.45rem; padding-bottom: 0.45rem; }

select {
  background-image: linear-gradient(45deg, transparent 50%, #94a3b8 50%),
                    linear-gradient(135deg, #94a3b8 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 2px),
                       calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 24px;
}

input::placeholder, textarea::placeholder { color: #64748b; }
canvas { max-height: 220px !important; }

.app-shell {
  position: relative;
  min-height: 100vh;
}
.app-header {
  border-bottom: 1px solid rgb(30 41 59 / 0.9);
  background: rgb(6 13 27 / 0.88);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 36px rgb(0 0 0 / 0.24);
}
.app-header-inner,
.app-main {
  width: min(1500px, calc(100vw - 2.5rem));
  margin-inline: auto;
}
.app-header-inner {
  min-height: 4.3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.72rem;
}
.app-main {
  padding-block: 1.15rem 1.5rem;
}
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 12rem;
}
.brand-lockup h1 {
  margin: 0;
  color: rgb(248 250 252);
  font-size: 1.08rem;
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: 0;
}
.brand-lockup span {
  display: block;
  margin-top: 0.18rem;
  color: rgb(100 116 139);
  font: 0.7rem/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid rgb(51 65 85);
  border-radius: 8px;
  background: linear-gradient(180deg, rgb(15 23 42), rgb(2 6 23));
  color: rgb(148 163 184);
}
.brand-mark::after {
  content: "";
  position: absolute;
  right: -0.18rem;
  top: -0.18rem;
  width: 0.58rem;
  height: 0.58rem;
  border: 2px solid rgb(6 13 27);
  border-radius: 999px;
  background: rgb(100 116 139);
}
.brand-mark.is-live {
  border-color: rgb(16 185 129 / 0.45);
  color: rgb(110 231 183);
}
.brand-mark.is-live::after {
  background: rgb(52 211 153);
  box-shadow: 0 0 0 3px rgb(16 185 129 / 0.14);
}
.brand-mark.is-down {
  border-color: rgb(244 63 94 / 0.45);
  color: rgb(251 113 133);
}
.brand-mark.is-down::after { background: rgb(244 63 94); }
.brand-mark svg {
  width: 1.05rem;
  height: 1.05rem;
}
.app-nav {
  display: flex;
  gap: 0.28rem;
  overflow-x: auto;
  border: 1px solid rgb(30 41 59 / 0.82);
  border-radius: 9px;
  background: rgb(2 6 23 / 0.48);
  padding: 0.22rem;
}
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.usage-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2rem;
  border: 1px solid rgb(30 41 59);
  border-radius: 999px;
  background: rgb(2 6 23 / 0.44);
  padding: 0 0.72rem;
  color: rgb(148 163 184);
  font-size: 0.75rem;
  white-space: nowrap;
}
.usage-chip b {
  color: rgb(226 232 240);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 650;
}
.usage-chip em {
  color: rgb(100 116 139);
  font: normal 0.68rem/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

body.app-mounted #frontend-fallback { display: none; }
.frontend-fallback {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: #020617;
  color: #e2e8f0;
}
.frontend-fallback-card {
  width: min(420px, 92vw);
  border: 1px solid #1e293b;
  border-radius: 10px;
  background: #0f172a;
  padding: 1.25rem;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.35);
}
.frontend-fallback-title {
  font-size: 1rem;
  font-weight: 700;
}
.frontend-fallback-body {
  margin-top: 0.5rem;
  color: #94a3b8;
  font-size: 0.875rem;
  line-height: 1.45;
}

.panel,
.stat-card {
  background: linear-gradient(180deg, rgb(15 23 42 / 0.78), rgb(15 23 42 / 0.56));
  border: 1px solid rgb(30 41 59 / 0.92);
  border-radius: 8px;
  padding: 0.9rem;
  box-shadow: 0 14px 34px rgb(0 0 0 / 0.2);
}
.panel {
  transition: border-color 140ms ease, background-color 140ms ease;
}
.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 5.15rem;
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: rgb(71 85 105);
}
.stat-card.tone-healthy::before { background: rgb(52 211 153); }
.stat-card.tone-danger::before { background: rgb(244 63 94); }
.stat-card.tone-warn::before { background: rgb(245 158 11); }
.stat-card.tone-muted::before { background: rgb(100 116 139); }
.stat-card.tone-info::before { background: rgb(20 184 166); }
.stat-card.tone-sky::before { background: rgb(56 189 248); }
.stat-card-action {
  display: block;
  width: 100%;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}
.stat-card-action:hover {
  background: linear-gradient(180deg, rgb(15 23 42 / 0.96), rgb(15 23 42 / 0.72));
  transform: translateY(-1px);
}
.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: rgb(148 163 184);
  font-size: 0.72rem;
}
.stat-card-head i,
.stat-card-head svg {
  width: 1rem;
  height: 1rem;
  color: rgb(100 116 139);
  flex: 0 0 auto;
}
.stat-card-value {
  margin-top: 0.42rem;
  font-size: 1.55rem;
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: 0;
}

.nav-tab,
.toolbar-btn,
.icon-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
}
.nav-tab {
  min-height: 2rem;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0.35rem 0.62rem;
  color: rgb(148 163 184);
  white-space: nowrap;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease;
}
.nav-tab:hover {
  color: rgb(226 232 240);
  background: rgb(30 41 59 / 0.66);
}
.nav-tab.active {
  color: rgb(240 249 255);
  border-color: rgb(45 212 191 / 0.35);
  background: linear-gradient(180deg, rgb(8 47 73 / 0.74), rgb(6 78 59 / 0.52));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
}
.nav-tab i,
.nav-tab svg,
.toolbar-btn i,
.toolbar-btn svg,
.icon-label i,
.icon-label svg {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
}
.toolbar-btn {
  border: 1px solid rgb(51 65 85 / 0.72);
  min-height: 2rem;
  border-radius: 7px;
  padding: 0.42rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1rem;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
}
.mini-btn.icon-label {
  gap: 0.25rem;
}
.mini-btn.icon-label i,
.mini-btn.icon-label svg {
  width: 0.78rem;
  height: 0.78rem;
}

.control {
  border-radius: 6px;
  border: 1px solid rgb(51 65 85);
  background: rgb(2 6 23 / 0.68);
  color: rgb(226 232 240);
  font-size: 0.875rem;
  line-height: 1.25rem;
  padding: 0.45rem 0.7rem;
  outline: none;
}
.control:focus {
  border-color: rgb(45 212 191 / 0.66);
  box-shadow: 0 0 0 3px rgb(20 184 166 / 0.1);
}

.search-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: 15rem;
  max-width: 100%;
  min-height: 2.14rem;
  border: 1px solid rgb(51 65 85);
  border-radius: 7px;
  background: rgb(2 6 23 / 0.68);
  padding: 0 0.65rem;
  color: rgb(100 116 139);
}
.search-control:focus-within {
  border-color: rgb(45 212 191 / 0.66);
  box-shadow: 0 0 0 3px rgb(20 184 166 / 0.1);
}
.search-control svg,
.search-control i {
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
}
.search-control input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: rgb(226 232 240);
  font-size: 0.875rem;
}

.btn-primary,
.btn-secondary,
.mini-btn {
  border-radius: 6px;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn-primary,
.btn-secondary {
  min-height: 1.92rem;
}
.btn-primary {
  border: 1px solid rgb(16 185 129 / 0.44);
  background: linear-gradient(180deg, rgb(5 150 105), rgb(4 120 87));
  color: white;
  font-size: 0.75rem;
  line-height: 1rem;
  padding: 0.45rem 0.8rem;
}
.btn-primary:hover { background: linear-gradient(180deg, rgb(16 185 129), rgb(4 120 87)); }
.btn-secondary {
  background: rgb(15 23 42 / 0.82);
  border: 1px solid rgb(51 65 85);
  color: rgb(226 232 240);
  font-size: 0.75rem;
  line-height: 1rem;
  padding: 0.45rem 0.8rem;
}
.btn-secondary:hover {
  border-color: rgb(71 85 105);
  background: rgb(30 41 59);
}
.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgb(30 41 59);
  color: rgb(203 213 225);
  font-size: 0.68rem;
  line-height: 1rem;
  padding: 0.16rem 0.42rem;
}
.mini-btn:hover { background: rgb(51 65 85); }
.mini-btn.danger:hover { background: rgb(127 29 29); }
.mini-btn:disabled { opacity: 0.55; cursor: wait; }

.density-toggle {
  display: inline-flex;
  border: 1px solid rgb(51 65 85);
  border-radius: 7px;
  overflow: hidden;
  background: rgb(2 6 23 / 0.62);
}
.density-toggle button {
  font-size: 0.75rem;
  padding: 0.42rem 0.7rem;
  color: rgb(148 163 184);
}
.density-toggle button.active {
  color: rgb(240 253 250);
  background: rgb(15 118 110);
}

.keys-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  border: 1px solid rgb(30 41 59);
  border-radius: 8px;
  background: linear-gradient(180deg, rgb(15 23 42 / 0.72), rgb(2 6 23 / 0.34));
  padding: 0.72rem;
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.16);
}
.key-count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.82rem;
  border: 1px solid rgb(51 65 85);
  border-radius: 999px;
  padding: 0 0.65rem;
  color: rgb(148 163 184);
  background: rgb(15 23 42 / 0.72);
  font: 0.72rem/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
}

.key-usage-overview {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.95rem;
  align-items: center;
  border: 1px solid rgb(30 41 59 / 0.95);
  border-radius: 8px;
  background: linear-gradient(180deg, rgb(15 23 42 / 0.76), rgb(2 6 23 / 0.42));
  padding: 0.95rem;
  box-shadow: 0 14px 34px rgb(0 0 0 / 0.18);
}
.usage-donut {
  width: 5.8rem;
  height: 5.8rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgb(51 65 85 / 0.8), 0 14px 34px rgb(0 0 0 / 0.18);
}
.usage-donut > div {
  width: 4.15rem;
  height: 4.15rem;
  border-radius: inherit;
  display: grid;
  place-items: center;
  align-content: center;
  background: rgb(2 6 23);
}
.usage-donut span {
  font: 700 0.95rem/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: rgb(226 232 240);
}
.usage-donut small {
  margin-top: 0.22rem;
  color: rgb(148 163 184);
  font-size: 0.66rem;
}
.usage-overview-main {
  min-width: 0;
}
.total-usage-bar {
  height: 0.82rem;
  margin-top: 0.75rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(15 23 42);
  border: 1px solid rgb(51 65 85 / 0.56);
}
.total-usage-bar > div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgb(16 185 129), rgb(14 165 233), rgb(245 158 11));
  box-shadow: 0 0 18px rgb(45 212 191 / 0.18);
  transition: width 180ms ease;
}
.usage-mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.65rem;
  color: rgb(148 163 184);
  font-size: 0.75rem;
}
.usage-mini-stats b {
  color: rgb(226 232 240);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.usage-status-tags {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}
.usage-status-tags button {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  border: 1px solid rgb(30 41 59);
  border-radius: 999px;
  background: rgb(2 6 23 / 0.42);
  color: rgb(203 213 225);
  padding: 0.32rem 0.58rem;
  white-space: nowrap;
  font-size: 0.72rem;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}
.usage-status-tags button:hover {
  border-color: rgb(71 85 105);
  background: rgb(30 41 59 / 0.62);
}
.usage-status-tags button i {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 999px;
  background: rgb(100 116 139);
  flex: 0 0 auto;
}
.usage-status-tags button b {
  color: rgb(148 163 184);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
}
.usage-status-tags button.active {
  border-color: rgb(45 212 191 / 0.66);
  background: rgb(8 47 73 / 0.62);
}
.usage-status-tags button.active b { color: rgb(125 211 252); }
.status-dot-ready { background: rgb(52 211 153) !important; }
.status-dot-near { background: rgb(251 191 36) !important; }
.status-dot-exhausted { background: rgb(71 85 105) !important; }
.status-dot-broken { background: rgb(244 63 94) !important; }
.status-dot-disabled { background: rgb(217 70 239) !important; }

.key-heatmap-panel {
  border: 1px solid rgb(30 41 59 / 0.95);
  border-radius: 8px;
  background: linear-gradient(180deg, rgb(15 23 42 / 0.74), rgb(2 6 23 / 0.38));
  padding: 0.92rem;
  box-shadow: 0 14px 34px rgb(0 0 0 / 0.18);
}
.heatmap-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-left: auto;
  color: rgb(148 163 184);
  font-size: 0.72rem;
}
.heatmap-summary span {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  border: 1px solid rgb(30 41 59);
  border-radius: 999px;
  padding: 0.22rem 0.5rem;
  background: rgb(2 6 23 / 0.5);
}
.heatmap-summary b {
  color: rgb(226 232 240);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.key-heatmap-scroll {
  margin-top: 0.8rem;
  overflow: visible;
  padding-bottom: 0.15rem;
}
.key-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(0.72rem, 0.72rem));
  grid-auto-rows: 0.72rem;
  gap: 0.2rem;
  align-items: center;
  width: 100%;
}
.heat-cell {
  width: 0.72rem;
  height: 0.72rem;
  border: 1px solid rgb(15 23 42);
  border-radius: 3px;
  background: rgb(30 41 59);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.12);
  transition: transform 80ms ease, outline-color 80ms ease, filter 80ms ease;
}
button.heat-cell {
  cursor: pointer;
}
button.heat-cell:hover {
  outline: 1px solid rgb(226 232 240 / 0.8);
  outline-offset: 1px;
  transform: scale(1.18);
  filter: saturate(1.12) brightness(1.08);
}
.heat-rem-0 { background: rgb(127 29 29); }
.heat-rem-1 { background: rgb(185 28 28); }
.heat-rem-2 { background: rgb(220 38 38); }
.heat-rem-3 { background: rgb(234 88 12); }
.heat-rem-4 { background: rgb(245 158 11); }
.heat-rem-5 { background: rgb(202 138 4); }
.heat-rem-6 { background: rgb(132 204 22); }
.heat-rem-7 { background: rgb(34 197 94); }
.heat-rem-8 { background: rgb(16 185 129); }
.heat-rem-9 { background: rgb(20 184 166); }
.heat-status-half {
  box-shadow: inset 0 0 0 1px rgb(251 191 36), 0 0 0 1px rgb(251 191 36 / 0.35);
}
.heat-status-open {
  box-shadow: inset 0 0 0 1px rgb(244 63 94), 0 0 0 1px rgb(244 63 94 / 0.45);
}
.heat-status-exhausted {
  filter: saturate(0.55) brightness(0.78);
}
.heat-status-disabled {
  background: rgb(147 51 234);
  border-color: rgb(192 132 252 / 0.75);
}
.heatmap-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-top: 0.7rem;
  color: rgb(148 163 184);
  font-size: 0.72rem;
}
.heatmap-legend .heat-cell {
  display: inline-block;
  flex: 0 0 auto;
}
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin-left: 0.25rem;
}
.empty-note {
  border: 1px dashed rgb(51 65 85);
  border-radius: 8px;
  color: rgb(148 163 184);
  background: rgb(15 23 42 / 0.36);
  padding: 0.8rem;
  font-size: 0.78rem;
  text-align: center;
}

.range-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  border: 1px solid rgb(30 41 59);
  border-radius: 8px;
  background: rgb(15 23 42 / 0.5);
  padding: 0.4rem 0.55rem;
  color: rgb(148 163 184);
  font-size: 0.82rem;
}
.range-btn {
  min-width: 2.2rem;
  border-radius: 6px;
  padding: 0.28rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1rem;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
  color: rgb(226 232 240);
  font-size: 0.86rem;
  font-weight: 650;
}
.panel-title svg,
.panel-title i {
  width: 0.95rem;
  height: 0.95rem;
  color: rgb(94 234 212);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border: 1px solid rgb(30 41 59);
  border-radius: 8px;
  background: linear-gradient(180deg, rgb(15 23 42 / 0.68), rgb(2 6 23 / 0.32));
  padding: 0.82rem 0.9rem;
}
.section-heading h2 {
  margin: 0;
  color: rgb(248 250 252);
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 720;
  letter-spacing: 0;
}
.section-heading p {
  margin: 0.18rem 0 0;
  color: rgb(100 116 139);
  font-size: 0.76rem;
  line-height: 1.25;
}
.section-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  border: 1px solid rgb(20 184 166 / 0.28);
  border-radius: 999px;
  background: rgb(6 78 59 / 0.22);
  padding: 0.36rem 0.7rem;
}
.section-metric span {
  color: rgb(148 163 184);
  font-size: 0.72rem;
}
.section-metric b {
  color: rgb(110 231 183);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.key-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
}
.key-workspace.has-drawer {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
}
.key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 0.48rem;
}
.key-tile {
  position: relative;
  overflow: hidden;
  min-height: 78px;
  border: 1px solid rgb(30 41 59 / 0.95);
  border-radius: 8px;
  background: linear-gradient(180deg, rgb(15 23 42 / 0.78), rgb(15 23 42 / 0.5));
  padding: 0.45rem;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}
.key-tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: rgb(71 85 105);
}
.key-tile.state-healthy::before { background: rgb(52 211 153); }
.key-tile.state-half_open::before { background: rgb(251 191 36); }
.key-tile.state-open::before { background: rgb(244 63 94); }
.key-tile.state-exhausted::before { background: rgb(100 116 139); }
.key-tile.state-disabled::before { background: rgb(217 70 239); }
.key-tile:hover {
  border-color: rgb(71 85 105);
  background: linear-gradient(180deg, rgb(15 23 42 / 0.95), rgb(15 23 42 / 0.66));
  transform: translateY(-1px);
}
.key-tile.is-selected {
  border-color: rgb(56 189 248 / 0.8);
  box-shadow: 0 0 0 1px rgb(56 189 248 / 0.2);
}
.key-tile.state-exhausted,
.key-tile.state-disabled {
  background: rgb(15 23 42 / 0.42);
}
.key-tile.state-exhausted .key-progress,
.key-tile.state-disabled .key-progress {
  opacity: 0.55;
}
.key-tile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
}
.key-status-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: rgb(100 116 139);
  flex: 0 0 auto;
}
.dot-healthy { background: rgb(52 211 153); }
.dot-open { background: rgb(251 113 133); }
.dot-half_open { background: rgb(251 191 36); }
.dot-exhausted { background: rgb(100 116 139); }
.dot-disabled { background: rgb(217 70 239); }
.icon-btn {
  display: inline-grid;
  place-items: center;
  min-width: 1.32rem;
  height: 1.32rem;
  border-radius: 6px;
  border: 1px solid rgb(51 65 85 / 0.72);
  background: rgb(15 23 42 / 0.72);
  color: rgb(203 213 225);
  line-height: 1;
}
.icon-btn:hover { background: rgb(51 65 85); }
.icon-btn svg,
.icon-btn i {
  width: 0.82rem;
  height: 0.82rem;
}
.key-menu {
  position: absolute;
  right: 0;
  top: 1.9rem;
  z-index: 15;
  width: 9.5rem;
  border: 1px solid rgb(51 65 85);
  border-radius: 8px;
  background: rgb(15 23 42 / 0.98);
  box-shadow: 0 18px 42px rgb(0 0 0 / 0.45);
  padding: 0.35rem;
}
.key-menu button {
  display: block;
  width: 100%;
  border-radius: 6px;
  color: rgb(203 213 225);
  font-size: 0.75rem;
  text-align: left;
  padding: 0.42rem 0.5rem;
}
.key-menu button:hover { background: rgb(30 41 59); }
.key-metric-row,
.key-compact-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.key-metric-row {
  margin-top: 0.36rem;
  font-size: 0.66rem;
}
.key-compact-meta {
  margin-top: 0.3rem;
  color: rgb(148 163 184);
  font-size: 0.62rem;
}
.key-compact-meta span {
  min-width: 0;
  white-space: nowrap;
}
.key-compact-meta b {
  color: rgb(226 232 240);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.key-progress {
  height: 0.28rem;
  margin-top: 0.28rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgb(15 23 42);
  border: 1px solid rgb(51 65 85 / 0.46);
}
.key-progress > div {
  height: 100%;
  transition: width 160ms ease;
}
.key-detail-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.65rem;
  color: rgb(148 163 184);
  font-size: 0.68rem;
}
.key-detail-meta span {
  display: block;
  margin-top: 0.1rem;
  color: rgb(226 232 240);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.key-tile.density-compact .key-detail-meta { display: none; }
.key-tile.density-detail { min-height: 118px; }
.key-grid-empty {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .app-header-inner,
  .app-main {
    width: min(100vw - 1rem, 1500px);
  }
  .app-header-inner {
    align-items: flex-start;
    gap: 0.65rem;
  }
  .brand-lockup,
  .app-nav,
  .header-actions {
    width: 100%;
  }
  .header-actions {
    justify-content: flex-start;
  }
  .usage-chip {
    width: 100%;
    justify-content: space-between;
  }
  .section-heading {
    padding: 0.75rem;
  }
  .search-control {
    flex: 1 1 100%;
    width: 100%;
  }
  .range-bar {
    display: flex;
    flex-wrap: wrap;
  }
  .keys-toolbar > div {
    width: 100%;
  }
  .keys-toolbar .control {
    flex: 1 1 9rem;
    min-width: 0;
  }
  .key-usage-overview {
    grid-template-columns: 1fr;
  }
  .usage-mini-stats {
    gap: 0.45rem 0.65rem;
  }
  .usage-donut {
    width: 4.8rem;
    height: 4.8rem;
  }
  .usage-donut > div {
    width: 3.45rem;
    height: 3.45rem;
  }
  .heatmap-summary {
    width: 100%;
    margin-left: 0;
  }
  .key-grid {
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  }
}

.key-drawer {
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow: auto;
  border: 1px solid rgb(30 41 59);
  border-radius: 10px;
  background: linear-gradient(180deg, rgb(15 23 42 / 0.98), rgb(2 6 23 / 0.92));
  padding: 1rem;
  box-shadow: 0 18px 44px rgb(0 0 0 / 0.28);
}
.drawer-stats {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.9rem;
}
.drawer-stats > div {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: baseline;
  border-bottom: 1px solid rgb(30 41 59 / 0.75);
  padding-bottom: 0.5rem;
  color: rgb(148 163 184);
  font-size: 0.75rem;
}
.drawer-stats b {
  color: rgb(226 232 240);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
}

.access-note {
  border: 1px solid rgb(14 165 233 / 0.32);
  border-radius: 8px;
  background: linear-gradient(180deg, rgb(8 47 73 / 0.34), rgb(2 6 23 / 0.34));
  color: rgb(186 230 253);
  padding: 0.82rem 0.95rem;
  font-size: 0.84rem;
  line-height: 1.45;
}
.client-card {
  position: relative;
  overflow: hidden;
}
.client-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: rgb(52 211 153);
}
.admin-client-card::before {
  background: rgb(56 189 248);
}
.client-card:hover {
  border-color: rgb(71 85 105);
  background: linear-gradient(180deg, rgb(15 23 42 / 0.92), rgb(15 23 42 / 0.62));
}

@media (max-width: 1100px) {
  .app-header-inner {
    flex-wrap: wrap;
  }
  .app-nav {
    order: 3;
    width: 100%;
  }
  .key-workspace.has-drawer { grid-template-columns: 1fr; }
  .key-drawer { position: static; max-height: none; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(2 6 23 / 0.82);
  backdrop-filter: blur(8px);
  padding: 1rem;
}
.modal {
  max-height: 92vh;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid rgb(30 41 59);
  background: rgb(15 23 42);
  box-shadow: 0 25px 60px rgb(0 0 0 / 0.45);
  padding: 1.5rem;
}

/* Light operations theme */
body.theme-light {
  color: #0f172a;
  --card-radius: 10px;
  --card-border: rgb(203 213 225 / 0.92);
  --card-bg: rgb(255 255 255 / 0.9);
  --card-shadow: 0 14px 34px rgb(15 23 42 / 0.08);
  --card-hover-border: rgb(148 163 184 / 0.82);
  --card-hover-bg: #ffffff;
  --card-hover-shadow: 0 16px 38px rgb(15 23 42 / 0.1);
  --card-muted-bg: rgb(248 250 252 / 0.9);
  background:
    linear-gradient(180deg, #f8fafc 0%, #eef3f8 52%, #f7f9fc 100%);
}
body.theme-light::before {
  background:
    linear-gradient(90deg, rgb(20 184 166 / 0.08), transparent 28%, rgb(37 99 235 / 0.06) 64%, rgb(245 158 11 / 0.06)),
    repeating-linear-gradient(0deg, rgb(15 23 42 / 0.035) 0 1px, transparent 1px 34px);
}
.theme-light .app-header {
  border-bottom-color: rgb(203 213 225 / 0.9);
  background: rgb(255 255 255 / 0.86);
  box-shadow: 0 10px 28px rgb(15 23 42 / 0.08);
}
.theme-light .brand-lockup h1 {
  color: #0f172a;
}
.theme-light .brand-lockup span {
  color: #64748b;
}
.theme-light .brand-mark {
  border-color: rgb(203 213 225);
  background: linear-gradient(180deg, #ffffff, #f1f5f9);
  color: #475569;
}
.theme-light .brand-mark::after {
  border-color: #ffffff;
}
.theme-light .brand-mark.is-live {
  border-color: rgb(13 148 136 / 0.4);
  color: #0f766e;
}
.theme-light .brand-mark.is-live::after {
  background: #10b981;
  box-shadow: 0 0 0 4px rgb(16 185 129 / 0.14);
}
.theme-light .app-nav {
  border-color: rgb(203 213 225 / 0.9);
  background: rgb(241 245 249 / 0.82);
}
.theme-light .nav-tab {
  color: #64748b;
}
.theme-light .nav-tab:hover {
  color: #0f172a;
  background: #ffffff;
}
.theme-light .nav-tab.active {
  color: #0f766e;
  border-color: rgb(13 148 136 / 0.28);
  background: #ffffff;
  box-shadow: 0 8px 22px rgb(15 23 42 / 0.08);
}
.theme-light .header-actions .toolbar-btn {
  border-color: rgb(203 213 225);
  box-shadow: 0 8px 20px rgb(15 23 42 / 0.08);
}
.theme-light .toolbar-btn.bg-slate-800,
.theme-light .toolbar-btn.hover\:bg-slate-700:hover {
  background: #ffffff !important;
  color: #334155 !important;
}
.theme-light .usage-chip {
  border-color: rgb(203 213 225);
  background: #ffffff;
  color: #64748b;
  box-shadow: 0 8px 20px rgb(15 23 42 / 0.06);
}
.theme-light .usage-chip b {
  color: #0f172a;
}
.theme-light .usage-chip em {
  color: #94a3b8;
}
.theme-light .panel,
.theme-light .stat-card,
.theme-light .key-usage-overview,
.theme-light .key-heatmap-panel,
.theme-light .keys-toolbar,
.theme-light .section-heading,
.theme-light .key-drawer,
.theme-light .modal {
  border-color: rgb(203 213 225 / 0.9);
  background: rgb(255 255 255 / 0.9);
  box-shadow: 0 14px 34px rgb(15 23 42 / 0.08);
}
.theme-light .stat-card-action:hover,
.theme-light .key-tile:hover,
.theme-light .client-card:hover {
  background: #ffffff;
}
.theme-light .stat-card-head,
.theme-light .section-heading p,
.theme-light .usage-mini-stats,
.theme-light .heatmap-summary,
.theme-light .heatmap-legend,
.theme-light .key-compact-meta,
.theme-light .key-detail-meta,
.theme-light .drawer-stats > div {
  color: #64748b;
}
.theme-light .stat-card-head svg,
.theme-light .stat-card-head i {
  color: #94a3b8;
}
.theme-light .stat-card-value,
.theme-light .panel-title,
.theme-light .section-heading h2,
.theme-light .drawer-stats b,
.theme-light .key-compact-meta b,
.theme-light .key-detail-meta span {
  color: #0f172a;
}
.theme-light .usage-donut {
  box-shadow: inset 0 0 0 1px rgb(203 213 225), 0 12px 26px rgb(15 23 42 / 0.08);
}
.theme-light .usage-donut > div {
  background: #ffffff;
}
.theme-light .total-usage-bar,
.theme-light .key-progress,
.theme-light .mt-3.h-2.bg-slate-800 {
  border-color: rgb(203 213 225 / 0.76);
  background: #e2e8f0 !important;
}
.theme-light .usage-status-tags button,
.theme-light .heatmap-summary span,
.theme-light .section-metric,
.theme-light .range-bar,
.theme-light .key-count-pill {
  border-color: rgb(203 213 225 / 0.92);
  background: #ffffff;
  color: #475569;
}
.theme-light .usage-status-tags button:hover,
.theme-light .usage-status-tags button.active {
  border-color: rgb(13 148 136 / 0.35);
  background: #f0fdfa;
}
.theme-light .usage-status-tags button b,
.theme-light .heatmap-summary b,
.theme-light .section-metric b {
  color: #0f766e;
}
.theme-light .control,
.theme-light .search-control,
.theme-light .density-toggle {
  border-color: rgb(203 213 225);
  background: #ffffff;
  color: #0f172a;
}
.theme-light .search-control input {
  color: #0f172a;
}
.theme-light .control:focus,
.theme-light .search-control:focus-within {
  border-color: rgb(13 148 136 / 0.55);
  box-shadow: 0 0 0 3px rgb(20 184 166 / 0.12);
}
.theme-light .btn-secondary,
.theme-light .mini-btn,
.theme-light .icon-btn {
  border-color: rgb(203 213 225);
  background: #ffffff;
  color: #334155;
}
.theme-light .btn-secondary:hover,
.theme-light .mini-btn:hover,
.theme-light .icon-btn:hover {
  border-color: rgb(148 163 184);
  background: #f8fafc;
}
.theme-light .density-toggle button {
  color: #64748b;
}
.theme-light .density-toggle button.active {
  color: #ffffff;
  background: #0f766e;
}
.theme-light .key-tile {
  border-color: rgb(203 213 225 / 0.95);
  background: rgb(255 255 255 / 0.86);
  box-shadow: 0 8px 22px rgb(15 23 42 / 0.06);
}
.theme-light .key-tile.state-exhausted,
.theme-light .key-tile.state-disabled {
  background: rgb(248 250 252 / 0.8);
}
.theme-light .key-tile.is-selected {
  border-color: rgb(14 165 233 / 0.72);
  box-shadow: 0 0 0 1px rgb(14 165 233 / 0.22), 0 12px 26px rgb(14 165 233 / 0.12);
}
.theme-light .key-menu {
  border-color: rgb(203 213 225);
  background: #ffffff;
  box-shadow: 0 18px 42px rgb(15 23 42 / 0.16);
}
.theme-light .key-menu button {
  color: #334155;
}
.theme-light .key-menu button:hover {
  background: #f1f5f9;
}
.theme-light .drawer-stats > div {
  border-bottom-color: rgb(226 232 240);
}
.theme-light .access-note {
  border-color: rgb(14 165 233 / 0.24);
  background: #eff6ff;
  color: #1e3a8a;
}
.theme-light .empty-note {
  border-color: rgb(203 213 225);
  background: #f8fafc;
  color: #64748b;
}
.theme-light .heat-cell {
  border-color: rgb(255 255 255 / 0.78);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.42), 0 0 0 1px rgb(15 23 42 / 0.08);
}
.theme-light button.heat-cell:hover {
  outline-color: rgb(15 23 42 / 0.72);
  filter: saturate(1.08) brightness(1.03);
}
.theme-light .heat-rem-0 { background: #fecaca; }
.theme-light .heat-rem-1 { background: #fda4af; }
.theme-light .heat-rem-2 { background: #fb7185; }
.theme-light .heat-rem-3 { background: #fdba74; }
.theme-light .heat-rem-4 { background: #fde68a; }
.theme-light .heat-rem-5 { background: #bae6fd; }
.theme-light .heat-rem-6 { background: #7dd3fc; }
.theme-light .heat-rem-7 { background: #38bdf8; }
.theme-light .heat-rem-8 { background: #2dd4bf; }
.theme-light .heat-rem-9 { background: #0d9488; }
.theme-light .heat-status-half {
  box-shadow: inset 0 0 0 1px #d97706, 0 0 0 1px rgb(217 119 6 / 0.28);
}
.theme-light .heat-status-open {
  box-shadow: inset 0 0 0 1px #be123c, 0 0 0 1px rgb(190 18 60 / 0.32);
}
.theme-light .heat-status-exhausted {
  filter: saturate(0.78) brightness(0.96);
}
.theme-light .heat-status-disabled {
  background: #c084fc;
  border-color: rgb(126 34 206 / 0.38);
}
.theme-light .modal-backdrop {
  background: rgb(15 23 42 / 0.28);
}
.theme-light .frontend-fallback {
  background: #f8fafc;
  color: #0f172a;
}
.theme-light .frontend-fallback-card {
  border-color: #cbd5e1;
  background: #ffffff;
  box-shadow: 0 20px 60px rgb(15 23 42 / 0.12);
}
.theme-light table thead {
  background: #f1f5f9 !important;
  color: #475569 !important;
}
.theme-light tbody tr {
  border-color: #e2e8f0;
}
.theme-light .rounded-lg.border.bg-slate-900\/60 {
  background: #ffffff !important;
}
.theme-light .bg-slate-950\/40,
.theme-light .bg-slate-950\/50 {
  background: #f8fafc !important;
}
.theme-light .bg-slate-900,
.theme-light .bg-slate-900\/60 {
  background: #f1f5f9 !important;
}
.theme-light .border-slate-800,
.theme-light .border-slate-800\/60 {
  border-color: #e2e8f0 !important;
}
.theme-light .text-slate-100,
.theme-light .text-slate-200,
.theme-light .text-slate-300 {
  color: #0f172a !important;
}
.theme-light .text-slate-400,
.theme-light .text-slate-500,
.theme-light .text-slate-600 {
  color: #64748b !important;
}
.theme-light .text-emerald-400 {
  color: #059669 !important;
}
.theme-light .text-sky-400 {
  color: #2563eb !important;
}
.theme-light .text-amber-400 {
  color: #d97706 !important;
}
.theme-light .text-rose-400,
.theme-light .text-rose-300,
.theme-light .text-rose-300\/80 {
  color: #e11d48 !important;
}
.theme-light .bg-rose-900\/40,
.theme-light .bg-rose-950\/20,
.theme-light .bg-rose-950\/30,
.theme-light .bg-rose-950\/40 {
  background: #fff1f2 !important;
}
.theme-light .border-rose-700\/50,
.theme-light .border-rose-900\/60 {
  border-color: #fecdd3 !important;
}
.theme-light footer {
  color: #94a3b8;
}

.theme-toggle-btn {
  background: rgb(15 23 42 / 0.82);
  color: rgb(226 232 240);
}
.theme-light .theme-toggle-btn {
  background: #ffffff !important;
  color: #334155 !important;
}

/* Unified card surface: modules keep their layout, but share one shell style. */
.panel,
.stat-card,
.key-usage-overview,
.key-heatmap-panel,
.keys-toolbar,
.section-heading,
.key-tile,
.key-drawer,
.access-note,
.modal,
.frontend-fallback-card,
.ops-card {
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}

.stat-card-action:hover,
.key-tile:hover,
.client-card:hover,
.ops-card:hover {
  border-color: var(--card-hover-border);
  background: var(--card-hover-bg);
  box-shadow: var(--card-hover-shadow);
}

.key-tile.state-exhausted,
.key-tile.state-disabled {
  background: var(--card-muted-bg);
}

.access-note {
  color: rgb(186 230 253);
}
.theme-light .access-note {
  color: #1e3a8a;
}
