:root {
  color-scheme: dark;
  --bg: #0b111a;
  --panel: #111b29;
  --panel-2: #162235;
  --line: #2b3b50;
  --text: #f5f8fc;
  --muted: #9db0c7;
  --blue: #2697ed;
  --green: #29ce8b;
  --red: #ff5c78;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--blue);
  font-size: 38px;
  font-weight: 900;
}
.brand-mark img {
  width: 30px;
  height: 40px;
  flex: 0 0 auto;
}
.brand-mark.small {
  font-size: 24px;
  min-width: 82px;
}
.brand-mark.small img {
  width: 22px;
  height: 30px;
}
h1, h2, p { margin: 0; }
.login-panel h1 { margin: 8px 0 24px; }

label > span, .eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}
input, select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: #0d1622;
}
input:focus, select:focus {
  border-color: var(--blue);
  outline: 2px solid rgb(38 151 237 / 18%);
}
input:disabled { opacity: .55; }
.primary, .secondary, .icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: white;
  font-weight: 700;
}
.primary { padding: 0 18px; background: var(--blue); }
.secondary { padding: 0 18px; background: var(--panel-2); border-color: var(--line); }
.icon-button {
  width: 42px;
  background: var(--panel-2);
  border-color: var(--line);
  font-size: 20px;
}
.icon-button.compact { min-height: 44px; border-radius: 0 4px 4px 0; }
.login-panel .primary { width: 100%; margin-top: 18px; }
.message { min-height: 20px; margin-top: 10px; color: var(--green); }
.message.error { color: var(--red); }

.app { width: min(1500px, 100%); margin: 0 auto; padding: 22px; }
.topbar, .toolbar, .editor-head, .editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar > div { display: flex; align-items: center; gap: 10px; }
.topbar p { margin-top: 3px; color: var(--muted); }
.toolbar {
  margin: 20px 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.search { flex: 1 1 420px; }
.search span { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.summary { color: var(--muted); white-space: nowrap; }
.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
}
.license-sidebar, .client-details {
  min-height: 660px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.client-details { min-width: 0; }
.client-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--line);
  background: #0d1622;
}
.client-tab {
  min-width: 140px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}
.client-tab:hover { color: var(--text); background: var(--panel-2); }
.client-tab.active {
  color: var(--text);
  border-color: var(--line);
  background: var(--panel);
}
.license-sidebar {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 660px;
  min-height: 0;
}
.license-list { padding: 8px; overflow-y: auto; }
.license-item {
  width: 100%;
  padding: 14px;
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  color: var(--text);
  background: transparent;
  text-align: left;
}
.license-item:hover, .license-item.active {
  border-color: var(--blue);
  background: var(--panel-2);
}
.license-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.license-item strong { overflow-wrap: anywhere; }
.license-item code, .license-item small { display: block; margin-top: 7px; color: var(--muted); }
.badge {
  padding: 3px 7px;
  color: var(--green);
  background: rgb(41 206 139 / 12%);
  font-size: 12px;
  font-weight: 700;
}
.badge.disabled { color: var(--red); background: rgb(255 92 120 / 12%); }
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #0d1622;
}
.page-size, .page-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-size span { margin: 0; }
.page-size select { width: 70px; height: 36px; }
.page-controls span {
  min-width: 52px;
  color: var(--muted);
  text-align: center;
}
.pagination .icon-button {
  width: 36px;
  min-height: 36px;
  height: 36px;
  border-radius: 4px;
}
.pagination button:disabled { cursor: default; opacity: .35; }

.editor { padding: 20px; }
.editor-head { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.revision { color: var(--muted); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.wide { grid-column: 1 / -1; }
.input-action { display: grid; grid-template-columns: 1fr 44px; }
.input-action input { border-radius: 4px 0 0 4px; }
fieldset {
  margin: 20px 0 0;
  padding: 15px;
  border: 1px solid var(--line);
}
legend { padding: 0 7px; font-weight: 700; }
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.feature-option, .switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
}
.feature-option input, .switch-row input { width: 18px; height: 18px; }
.feature-option span, .switch-row span { margin: 0; color: var(--text); font-size: 14px; }
.status-controls {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
}
.hardware { text-align: right; color: var(--muted); overflow-wrap: anywhere; }
.editor-actions { margin-top: 18px; }
.editor-actions .message { flex: 1 1 auto; margin: 0; }
.editor-actions button:disabled {
  cursor: default;
  opacity: .45;
}
.subscriptions {
  padding: 20px;
  background: var(--panel);
}
.subscriptions-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}
.section-note { margin-top: 5px; color: var(--muted); }
.subscription-filter { width: 220px; }
.subscription-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.subscription-stat {
  padding: 12px;
  border: 1px solid var(--line);
  background: #0d1622;
}
.subscription-stat span { display: block; color: var(--muted); font-size: 12px; }
.subscription-stat strong { display: block; margin-top: 5px; font-size: 22px; }
.subscription-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.subscription-editor, .subscription-table-wrap {
  border: 1px solid var(--line);
  background: #0d1622;
}
.subscription-editor { padding: 16px; }
.subscription-editor h3 { margin: 0; }
.selected-license {
  margin-top: 5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.subscription-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.renew-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.subscription-save { width: 100%; margin-top: 8px; }
.subscription-table-wrap { overflow-x: auto; }
.subscription-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.subscription-table th, .subscription-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.subscription-table th { color: var(--muted); font-size: 12px; }
.subscription-table tr:last-child td { border-bottom: 0; }
.status-badge {
  display: inline-block;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status-active { color: var(--green); background: rgb(41 206 139 / 12%); }
.status-expiring { color: #ffd05a; background: rgb(255 208 90 / 12%); }
.status-grace { color: #ff9d4d; background: rgb(255 157 77 / 12%); }
.status-expired, .status-disabled { color: var(--red); background: rgb(255 92 120 / 12%); }
.table-action {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: var(--panel-2);
}

@media (max-width: 900px) {
  .app { padding: 14px; }
  .workspace { grid-template-columns: 1fr; }
  .license-sidebar { height: 340px; }
  .client-details { min-height: 0; }
  .editor { min-height: 0; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subscription-layout { grid-template-columns: 1fr; }
  .subscription-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .topbar h1 { font-size: 22px; }
  .topbar p { display: none; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .toolbar .primary, .search { width: 100%; flex-basis: 100%; }
  .summary { order: 3; }
  .form-grid, .feature-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .editor { padding: 15px; }
  .status-controls { grid-template-columns: 1fr; gap: 5px; }
  .hardware { margin-top: 8px; text-align: left; }
  .editor-actions { align-items: stretch; flex-direction: column; }
  .editor-actions .primary, .editor-actions .secondary { width: 100%; }
  .pagination { flex-wrap: wrap; }
  .subscriptions-head { align-items: stretch; flex-direction: column; }
  .subscription-filter { width: 100%; }
  .subscription-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subscription-form-grid { grid-template-columns: 1fr; }
  .client-tab { min-width: 0; flex: 1 1 50%; }
}
.product-tabs {
  display: flex;
  gap: 8px;
  padding: 0 24px 16px;
}
.product-tab {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
}
.product-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

@media (max-width: 640px) {
  .product-tabs { padding-inline: 14px; }
  .product-tab { flex: 1; }
}
