:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #071015;
  color: #f5fbff;
  --bg: #071015;
  --panel: #0d1a20;
  --panel-strong: #101f27;
  --line: #29414b;
  --text: #f5fbff;
  --muted: #a9bbc4;
  --soft: #d8e8ee;
  --green: #4ee6aa;
  --green-dark: #123c31;
  --blue: #7db7ff;
  --amber: #ffcc66;
  --red: #ff7d7d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #071015 0%, #0a141a 52%, #081116 100%),
    #071015;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  padding: 0 18px;
  color: #04110d;
  font-weight: 800;
  background: var(--green);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  filter: brightness(1.04);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  color: var(--text);
  background: #192c34;
  border: 1px solid #3e5f6a;
}

button.danger {
  color: #190707;
  background: var(--red);
}

input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--text);
  background: #09161c;
  border: 1px solid #38545f;
  border-radius: 8px;
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(125, 183, 255, 0.14);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 36px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
}

p {
  color: var(--muted);
}

label {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 700;
}

.shell {
  width: min(1220px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar,
.panel,
.system-details {
  border: 1px solid rgba(125, 183, 255, 0.18);
  background: rgba(13, 26, 32, 0.94);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.26);
  border-radius: 8px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 26px;
  align-items: end;
  padding: 28px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--green);
  font-weight: 800;
}

.auth-panel {
  display: grid;
  gap: 10px;
}

.auth-state {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 11px 12px;
  background: #09161c;
  border: 1px solid #38545f;
  border-radius: 8px;
}

.auth-state strong {
  display: block;
  color: var(--text);
  line-height: 1.2;
}

.auth-state small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.auth-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 125, 125, 0.12);
}

.auth-state.logged-in {
  border-color: rgba(78, 230, 170, 0.48);
}

.auth-state.logged-in .auth-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(78, 230, 170, 0.14);
}

.auth-state.checking .auth-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(255, 204, 102, 0.14);
}

.row {
  display: flex;
  gap: 10px;
}

.wide {
  width: 100%;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric {
  min-height: 118px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  color: var(--text);
  font-size: 36px;
  line-height: 1;
}

.metric small {
  min-height: 32px;
  color: #8ca4af;
  line-height: 1.28;
}

.metric-live {
  border-color: rgba(78, 230, 170, 0.48);
}

.metric-live strong {
  color: var(--green);
}

.metric-warning strong {
  color: var(--amber);
}

.metric-danger strong {
  color: var(--red);
}

.panel {
  margin-top: 16px;
  padding: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.panel-head.compact {
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 120px 120px auto;
  gap: 14px;
  align-items: end;
}

.created-code {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 16px;
  color: #04110d;
  background: var(--green);
  border-radius: 8px;
}

.created-code[hidden] {
  display: none;
}

.created-code div {
  display: grid;
  gap: 4px;
}

.created-code span,
.created-code small {
  color: rgba(4, 17, 13, 0.76);
  font-weight: 700;
}

.created-code strong {
  font-size: 23px;
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.4fr);
  gap: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  min-height: 36px;
  padding: 0 14px;
  color: var(--soft);
  background: #111f26;
  border: 1px solid #314b55;
}

.tab.active {
  color: #04110d;
  background: var(--blue);
  border-color: var(--blue);
}

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

.item {
  display: grid;
  gap: 12px;
  padding: 15px;
  background: #0b171d;
  border: 1px solid #29414b;
  border-radius: 8px;
}

.item-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
}

.item-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.item-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-title small {
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.fact {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  background: #101f27;
  border: 1px solid #253d47;
  border-radius: 8px;
}

.fact span {
  color: #8ca4af;
  font-size: 12px;
  font-weight: 800;
}

.fact strong {
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.pill {
  min-width: 88px;
  padding: 7px 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.pill.online {
  color: #04110d;
  background: var(--green);
}

.pill.enabled {
  color: #071015;
  background: var(--blue);
}

.pill.offline {
  color: var(--soft);
  background: #192c34;
  border: 1px solid #3e5f6a;
}

.pill.disabled,
.pill.expired {
  color: #190707;
  background: var(--red);
}

.tech {
  color: var(--muted);
  font-size: 12px;
}

.tech summary {
  width: fit-content;
  cursor: pointer;
  color: var(--blue);
  font-weight: 800;
}

.tech-grid {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.empty {
  padding: 18px;
  color: var(--muted);
  background: #0b171d;
  border: 1px dashed #3b5661;
  border-radius: 8px;
}

.system-details {
  margin-top: 16px;
  padding: 16px 18px;
}

.system-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.system-grid {
  display: grid;
  grid-template-columns: 160px 190px 1fr;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}

.system-grid div {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: #0b171d;
  border: 1px solid #253d47;
  border-radius: 8px;
}

.system-grid strong {
  color: var(--text);
}

.status {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--amber);
}

.confirm {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 1px solid #49636d;
  border-radius: 8px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.5);
}

.confirm::backdrop {
  background: rgba(2, 7, 10, 0.72);
}

.confirm form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1050px) {
  .topbar,
  .workspace,
  .form-grid,
  .system-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 24px, 1220px);
    padding-top: 14px;
  }

  h1 {
    font-size: 30px;
  }

  .summary-grid,
  .facts,
  .item-head {
    grid-template-columns: 1fr;
  }

  .row,
  .dialog-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .created-code {
    grid-template-columns: 1fr;
  }
}
