:root {
  --bg-primary: #e0e5ec;
  --bg-secondary: #e0e5ec;
  --bg-title-bar: #e0e5ec;
  --text-primary: #2c3e50;
  --text-secondary: #6c757d;
  --shadow-dark: rgba(163, 177, 198, .6);
  --shadow-light: rgba(255, 255, 255, .82);
  --btn-bg: #e0e5ec;
  --btn-hover: #d8dde4;
  --brand-a: #667eea;
  --brand-b: #764ba2;
  --pink-a: #ffc0e0;
  --pink-b: #ff6b9d;
  --danger: #f5576c;
  --success: #4caf50;
  --warning: #ff9800;
  --line-soft: rgba(108, 117, 125, .14);
  --panel-gap: 14px;
  font-family: "Segoe UI", "Microsoft YaHei", Tahoma, Geneva, Verdana, sans-serif;
}

[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #1a1a1a;
  --bg-title-bar: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --shadow-dark: rgba(0, 0, 0, .82);
  --shadow-light: rgba(255, 255, 255, .06);
  --btn-bg: #1a1a1a;
  --btn-hover: #303030;
  --line-soft: rgba(255, 255, 255, .09);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text-primary);
  background: var(--bg-primary);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button,
select,
input[type="file"] {
  cursor: pointer;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.ops-app,
.login-shell {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  color: var(--text-primary);
  background: var(--bg-primary);
}

.ops-app {
  display: flex;
  flex-direction: column;
  padding: 16px 16px 0;
}

.login-shell {
  display: grid;
  place-items: center;
  padding: 24px;
}

.title-bar,
.login-card,
.panel,
.stat,
.nav-panel,
.workspace-head {
  background: var(--bg-secondary);
  box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
}

.title-bar {
  height: 68px;
  flex: 0 0 68px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  margin-bottom: var(--panel-gap);
  border-radius: 16px;
  background: var(--bg-title-bar);
}

.brand-lockup,
.title-actions,
.section-header,
.status-strip,
.inline-actions,
.device-title,
.workspace-actions,
.toggle-option,
.nav-user {
  display: flex;
  align-items: center;
}

.brand-lockup {
  min-width: 280px;
  gap: 14px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  border-radius: 15px;
  color: #fff;
  font-weight: 800;
  font-size: 24px;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}

.brand-lockup h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-lockup p,
.workspace-head p,
.login-copy span,
.nav-user span,
.nav button small,
.subtle,
.stat em,
.status-meta,
.device-meta,
.mini,
.nav-footer span,
.empty-state span {
  color: var(--text-secondary);
}

.brand-lockup p {
  margin: 6px 0 0;
  font-size: 12px;
}

.status-strip {
  min-width: 0;
  flex: 1;
  height: 42px;
  gap: 10px;
  padding: 0 16px;
  border-radius: 13px;
  color: var(--text-secondary);
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

.status-strip span:nth-child(2) {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status-mark {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  border-radius: 9px;
  color: var(--success);
  box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
}

.status-meta {
  margin-left: auto;
  font-size: 12px;
}

.title-actions {
  gap: 10px;
}

.control-btn,
.text-action-btn,
.neumo-btn,
.action-btn,
.toggle-option,
.nav button,
.inline-actions button,
.license-key-box button {
  color: var(--text-primary);
  background: var(--btn-bg);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, color .16s ease;
}

.control-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-secondary);
  box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

.control-btn:hover,
.text-action-btn:hover,
.neumo-btn:hover,
.action-btn:hover,
.toggle-option:hover,
.nav button:hover,
.inline-actions button:hover,
.license-key-box button:hover {
  transform: translateY(-1px);
  background: var(--btn-hover);
}

.control-btn:active,
.text-action-btn:active,
.neumo-btn:active,
.action-btn:active,
.toggle-option:active,
.toggle-option.pressed,
.nav button:active,
.inline-actions button:active,
.license-key-box button:active {
  transform: translateY(0);
  box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
}

.text-action-btn,
.neumo-btn,
.action-btn,
.toggle-option,
.inline-actions button,
.license-key-box button {
  min-height: 36px;
  border-radius: 12px;
  padding: 0 14px;
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}

.action-btn.primary,
.neumo-btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}

.action-btn.full {
  width: 100%;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: var(--panel-gap);
}

.nav-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--panel-gap);
  padding: 18px;
  margin-bottom: 16px;
  border-radius: 16px;
}

.nav-user {
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

.avatar-dot {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pink-a), var(--pink-b));
}

.nav-user strong,
.nav-user span {
  display: block;
}

.nav-user strong {
  font-size: 14px;
}

.nav-user span {
  margin-top: 2px;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav button {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  text-align: left;
  border-radius: 15px;
  box-shadow: 4px 4px 9px var(--shadow-dark), -4px -4px 9px var(--shadow-light);
}

.nav button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
}

.nav button.active small,
.nav button.active em {
  color: rgba(255, 255, 255, .78);
}

.nav-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, .08), inset -2px -2px 4px rgba(255, 255, 255, .25);
}

.ui-icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon .ui-icon,
.stat-icon .ui-icon {
  width: 19px;
  height: 19px;
}

.nav button strong,
.nav button small {
  display: block;
}

.nav button strong {
  font-size: 14px;
}

.nav button small {
  margin-top: 3px;
  font-size: 12px;
}

.nav button em {
  font-style: normal;
  font-size: 12px;
  color: var(--text-secondary);
}

.nav-footer {
  margin-top: auto;
  padding: 12px;
  border-radius: 14px;
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

.nav-footer span,
.nav-footer strong {
  display: block;
}

.nav-footer span {
  font-size: 12px;
}

.nav-footer strong {
  margin-top: 5px;
  font-size: 13px;
}

.workspace {
  min-width: 0;
  min-height: 0;
  overflow: visible;
  padding: 8px 8px 16px;
}

.workspace-scroll {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  margin: -18px;
  display: grid;
  align-content: start;
  gap: var(--panel-gap);
}

.workspace-scroll::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.workspace-head {
  min-height: 104px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  border-radius: 16px;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--brand-a);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.workspace-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.workspace-head p {
  margin: 8px 0 0;
}

.workspace-actions {
  justify-content: flex-end;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: var(--panel-gap);
}

.stat {
  min-height: 116px;
  position: relative;
  padding: 17px 18px;
  border-radius: 16px;
  overflow: hidden;
}

.stat-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
}

.stat .subtle {
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.stat em {
  display: block;
  margin-top: 9px;
  font-size: 12px;
  font-style: normal;
}

.panel {
  min-width: 0;
  padding: 18px;
  border-radius: 16px;
}

.section-header {
  min-height: 34px;
  gap: 9px;
  margin-bottom: 16px;
}

.section-header.split {
  justify-content: space-between;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 220px));
  gap: 12px;
  align-items: end;
}

.section-header .title {
  font-size: 16px;
  font-weight: 800;
}

.icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
}

.soft-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 12px;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  align-items: end;
}

.login-form {
  grid-template-columns: 1fr;
}

.form-row,
.toggle-option {
  min-width: 0;
}

.form-row {
  display: grid;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 13px;
}

.form-row.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 0;
  outline: 0;
  border-radius: 12px;
  padding: 9px 12px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--text-secondary) 78%, transparent);
}

input[type="file"] {
  padding: 8px 10px;
}

.toggle-option {
  min-height: 40px;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border-radius: 12px;
  color: var(--text-secondary);
  font-weight: 700;
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}

.toggle-option.pressed {
  color: var(--brand-a);
  background: color-mix(in srgb, var(--bg-secondary) 92%, var(--brand-a));
}

.toggle-option .ui-icon {
  width: 16px;
  height: 16px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  padding: 10px;
  margin: -10px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0 10px;
  font-size: 13px;
}

th {
  padding: 0 12px 2px;
  color: var(--text-secondary);
  font-weight: 700;
  text-align: left;
}

td {
  padding: 14px 12px;
  vertical-align: middle;
  background: color-mix(in srgb, var(--bg-secondary) 92%, white);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

[data-theme="dark"] td {
  background: color-mix(in srgb, var(--bg-secondary) 92%, white 4%);
}

td:first-child {
  border-left: 1px solid var(--line-soft);
  border-radius: 14px 0 0 14px;
}

td:last-child {
  border-right: 1px solid var(--line-soft);
  border-radius: 0 14px 14px 0;
}

.subtle {
  font-size: 12px;
}

.mono {
  font-family: Consolas, "SFMono-Regular", "Microsoft YaHei", monospace;
  word-break: break-all;
}

.release-diff {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.release-diff-tags,
.release-diff-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.release-diff-tags span,
.release-diff-files span {
  max-width: 260px;
  padding: 4px 7px;
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
  overflow-wrap: anywhere;
}

.mini {
  font-size: 11px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.pill.active,
.pill.published {
  color: var(--success);
}

.pill.suspended,
.pill.draft {
  color: var(--warning);
}

.pill.revoked,
.pill.disabled {
  color: var(--danger);
}

.pill.not_entitled,
.pill.expiry_missing {
  color: var(--text-secondary);
}

.pill.not_started,
.pill.usage_exhausted {
  color: var(--warning);
}

.pill.expired {
  color: var(--danger);
}

.notice {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--success);
  background: var(--bg-secondary);
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

.notice span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  border-radius: 8px;
  color: #fff;
  background: var(--success);
}

.notice.error {
  color: var(--danger);
}

.notice.error span {
  background: var(--danger);
}

.table-stack,
.device-list,
.settings-list,
.endpoint-list {
  display: grid;
  gap: 9px;
}

.table-stack {
  margin-top: 8px;
}

.inline-actions {
  gap: 7px;
  flex-wrap: wrap;
}

.inline-actions.vertical {
  align-items: stretch;
  flex-direction: column;
}

.inline-actions button,
.license-key-box button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 12px;
}

.license-key-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 280px;
  min-height: 38px;
  padding: 6px 8px;
  border-radius: 12px;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.license-key-box span {
  min-width: 0;
  word-break: break-all;
}

.license-key-box button {
  flex: 0 0 auto;
  border: none;
  cursor: pointer;
}

.license-key-box.legacy {
  display: grid;
  gap: 2px;
  color: var(--text-secondary);
}

.license-key-box.legacy small {
  font-size: 11px;
}

.feature-table {
  min-width: 1180px;
}

.feature-table input,
.feature-table select {
  min-height: 34px;
  border-radius: 10px;
  font-size: 12px;
}

.inline-actions button.danger,
.inline-actions button.danger-text,
button.danger,
button.danger-text {
  color: var(--danger);
}

.device-list {
  margin-top: 9px;
}

.device-card {
  padding: 11px;
  border-radius: 13px;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.device-title {
  gap: 8px;
  flex-wrap: wrap;
}

.device-meta {
  margin-top: 6px;
  font-size: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: var(--panel-gap);
}

.setting-item,
.endpoint-list span {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 13px;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.setting-item span {
  color: var(--text-secondary);
  font-size: 12px;
}

.endpoint-list span {
  color: var(--text-primary);
}

.empty-state {
  min-height: 92px;
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.login-card {
  width: min(480px, calc(100vw - 32px));
  display: grid;
  gap: 18px;
  padding: 28px;
  border-radius: 18px;
}

.login-card .brand-lockup {
  min-width: 0;
}

.login-copy {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 14px;
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

.login-copy strong {
  font-size: 18px;
  line-height: 1.35;
}

.fixed-device-note {
  min-height: 66px;
  justify-content: center;
  color: var(--text-secondary);
  box-shadow: inset 4px 4px 9px var(--shadow-dark), inset -4px -4px 9px var(--shadow-light);
}

.fixed-device-note strong {
  display: block;
  margin-top: 6px;
  color: var(--text-primary);
}

.license-feature-picker {
  display: grid;
  gap: 12px;
  width: 100%;
}

.license-feature-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--text-secondary);
}

.license-feature-picker-head strong {
  color: var(--text-primary);
}

.license-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(230px, 1fr));
  gap: 10px;
}

.license-feature-option {
  display: grid;
  gap: 10px;
  min-height: 104px;
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
}

.license-feature-main {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  cursor: pointer;
}

.license-feature-main input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: #7557d8;
}

.license-feature-main span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.license-feature-main strong,
.license-feature-main em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.license-feature-main em {
  color: var(--text-secondary);
  font-style: normal;
  font-size: 12px;
}

.license-feature-duration {
  display: grid;
  grid-template-columns: minmax(78px, .8fr) minmax(72px, .7fr) minmax(86px, .8fr);
  gap: 8px;
  align-items: center;
}

.license-feature-duration span {
  color: var(--text-secondary);
  font-size: 12px;
}

.license-feature-duration input,
.license-feature-duration select {
  min-height: 34px;
  border-radius: 10px;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .stats {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .license-feature-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .ops-app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 12px;
  }

  .title-bar {
    height: auto;
    min-height: 68px;
    flex-wrap: wrap;
    padding: 16px;
  }

  .brand-lockup {
    min-width: 0;
  }

  .status-strip {
    order: 3;
    flex: 1 0 100%;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .nav-panel {
    margin-bottom: 0;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 0 0 16px;
  }

  .workspace-scroll {
    height: auto;
    overflow: visible;
    padding: 0;
    margin: 0;
  }

  .workspace-head,
  .settings-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .section-header.split {
    display: grid;
    align-items: stretch;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 620px) {
  .brand-lockup h1 {
    font-size: 24px;
  }

  .title-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .stats,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .license-feature-grid {
    grid-template-columns: 1fr;
  }

  .license-feature-picker-head {
    display: grid;
  }
}
