/* ==========================================================================
   Exterium V Free - licensing admin panel
   Dark theme matching the desktop client. No external fonts, no images, no
   frameworks: everything here is plain CSS that works offline.
   ========================================================================== */

:root {
  --bg: #0a0b0e;
  --surface: #111317;
  --surface-2: #171a1f;
  --surface-3: #20242c;
  --border: #22262e;
  --border-strong: #2e343e;

  --text: #e7eaf0;
  --text-dim: #a2aab8;
  --text-muted: #7c8492;

  --accent: #4c8dff;
  --accent-dim: #2b5cab;
  --accent-soft: rgba(76, 141, 255, 0.12);

  --ok: #3fb950;
  --warn: #d9a03a;
  --danger: #e5534b;
  --danger-soft: rgba(229, 83, 75, 0.12);

  --radius: 3px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
kbd,
pre,
.mono {
  font-family: var(--mono);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Brand
   -------------------------------------------------------------------------- */

.brand-mark {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --------------------------------------------------------------------------
   Sign in
   -------------------------------------------------------------------------- */

.login-view {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
}

.login-title {
  font-size: 15px;
}

.login-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.login-foot {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app-view {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 46px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title {
  font-weight: 600;
  white-space: nowrap;
}

.topbar-tag {
  color: var(--text-muted);
  font-size: 12px;
  border-left: 1px solid var(--border-strong);
  padding-left: 10px;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-meta {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--mono);
  white-space: nowrap;
}

.shell {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.sidebar {
  width: 168px;
  flex: 0 0 168px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  font: inherit;
  text-align: left;
  padding: 7px 10px;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 16px;
  outline: none;
}

/* --------------------------------------------------------------------------
   Panels, headings, toolbar
   -------------------------------------------------------------------------- */

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.view-title {
  font-size: 15px;
}

.view-sub {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.panel-body {
  padding: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.toolbar .spacer {
  flex: 1;
}

/* --------------------------------------------------------------------------
   Forms and controls
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="datetime-local"],
input[type="date"],
select,
textarea {
  appearance: none;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 9px;
  font: inherit;
  font-size: 12.5px;
  min-width: 0;
}

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

input::placeholder,
textarea::placeholder {
  color: #5d6472;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

select {
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(229, 83, 75, 0.35);
  border-radius: var(--radius);
  padding: 7px 9px;
}

.form-ok {
  margin: 0;
  color: var(--ok);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  appearance: none;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 11px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: #3c444f;
  background: #262b34;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06101f;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: #5f9aff;
  border-color: #5f9aff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-danger {
  background: transparent;
  border-color: rgba(229, 83, 75, 0.5);
  color: #ff8b84;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #1a0605;
  font-weight: 600;
}

.btn-danger-solid:hover:not(:disabled) {
  background: #ef6259;
  border-color: #ef6259;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11.5px;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 8px 11px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  max-width: 320px;
  overflow-wrap: anywhere;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr.is-clickable {
  cursor: pointer;
}

tbody tr.is-clickable:hover {
  background: var(--surface-2);
}

tbody tr.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

td.col-actions,
th.col-actions {
  text-align: right;
  white-space: nowrap;
  max-width: none;
}

.cell-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.cell-strong {
  color: var(--text);
  font-weight: 600;
}

.cell-note {
  color: var(--text-muted);
  font-size: 11.5px;
}

.nowrap {
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Badges and pills
   -------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-ok {
  color: #7ee08c;
  border-color: rgba(63, 185, 80, 0.45);
  background: rgba(63, 185, 80, 0.1);
}

.badge-warn {
  color: #ecc37a;
  border-color: rgba(217, 160, 58, 0.45);
  background: rgba(217, 160, 58, 0.1);
}

.badge-bad {
  color: #ff9a93;
  border-color: rgba(229, 83, 75, 0.45);
  background: var(--danger-soft);
}

.badge-accent {
  color: #9dc2ff;
  border-color: rgba(76, 141, 255, 0.45);
  background: var(--accent-soft);
}

.pill {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--mono);
}

/* --------------------------------------------------------------------------
   Definition grid (detail view)
   -------------------------------------------------------------------------- */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 18px;
}

.detail-item {
  min-width: 0;
}

.detail-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.detail-value {
  overflow-wrap: anywhere;
}

.detail-value.mono {
  font-family: var(--mono);
  font-size: 11.5px;
}

.detail-wide {
  grid-column: 1 / -1;
}

.pre-block {
  margin: 0;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   Empty / loading states
   -------------------------------------------------------------------------- */

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--text-muted);
}

.empty-title {
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 4px;
}

.empty-hint {
  font-size: 12px;
}

.loading {
  padding: 26px 16px;
  text-align: center;
  color: var(--text-muted);
}

.error-banner {
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid rgba(229, 83, 75, 0.4);
  background: var(--danger-soft);
  color: #ff9a93;
  border-radius: var(--radius);
  font-size: 12.5px;
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 2px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.pager-actions {
  display: flex;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   One-time key reveal - the most important interaction in the panel
   -------------------------------------------------------------------------- */

.reveal {
  border: 1px solid var(--accent);
  background: linear-gradient(180deg, rgba(76, 141, 255, 0.08), rgba(76, 141, 255, 0.02));
  border-radius: var(--radius);
  padding: 16px;
}

.reveal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.reveal-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.reveal-warning {
  margin: 0 0 14px;
  color: #ffce9a;
  font-size: 12.5px;
}

.key-box {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}

.key-value {
  flex: 1 1 260px;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: 0.06em;
  color: #cfe0ff;
  user-select: all;
  overflow-wrap: anywhere;
}

.reveal-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.copy-state {
  font-size: 11.5px;
  color: var(--ok);
  min-height: 15px;
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toast-host {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  overflow-wrap: anywhere;
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-ok {
  border-left-color: var(--ok);
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal-host {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(5, 6, 9, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

.modal-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.modal-body {
  padding: 14px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-message {
  margin: 0;
  color: var(--text-dim);
  font-size: 12.5px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.link-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.split-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

@media (max-width: 720px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav-item.is-active {
    box-shadow: inset 0 -2px 0 var(--accent);
  }
}
