:root {
  --bg: #0b0e13;
  --bg-elevated: #12161d;
  --bg-elevated-2: #171c25;
  --border: #232935;
  --text: #d7dde5;
  --text-dim: #838d9c;
  --text-faint: #566072;
  --accent: #5b8cff;
  --accent-dim: #2f4a8a;
  --danger: #e0645a;
  --danger-dim: #4a2b28;
  --success: #4caf82;
  --warn: #d3a24a;
  --mono: "SFMono-Regular", "Consolas", "Menlo", "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 320px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 28px;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.subtitle {
  color: var(--text-dim);
  font-size: 12px;
  margin: 0 0 24px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card input {
  text-align: center;
}

.alert {
  margin-top: 14px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--danger-dim);
  color: var(--danger);
  font-size: 13px;
}

/* ---------- Form controls ---------- */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--sans);
  width: 100%;
}

textarea {
  resize: vertical;
  font-family: var(--sans);
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

label > input, label > select, label > textarea {
  margin-top: 6px;
}

button {
  background: var(--accent);
  color: #0b0e13;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:active { filter: brightness(0.95); }

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: var(--danger);
  color: #1a0f0e;
}

button.small {
  padding: 5px 10px;
  font-size: 12px;
  margin-top: 8px;
}

/* ---------- Dashboard shell ---------- */
#dashboard-view header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}

.header-title h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.header-title .subtitle { margin: 2px 0 0; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#search-box { width: 240px; }

main {
  padding: 20px 28px 60px;
}

/* ---------- Table ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-elevated-2);
}

tbody tr:hover { background: var(--bg-elevated-2); }
tbody tr:last-child td { border-bottom: none; }

td.code, code {
  font-family: var(--mono);
  font-size: 12.5px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-active { background: #16332450; color: var(--success); }
.badge-trial { background: #3a2f1550; color: var(--warn); }
.badge-revoked { background: var(--danger-dim); color: var(--danger); }
.badge-expired { background: #2a2a2f; color: var(--text-faint); }

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

.row-actions button {
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 500;
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 40px;
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 9, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  width: 380px;
  max-height: 84vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

.modal.wide { width: 620px; }

.modal h2 {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 600;
}

.modal h3 {
  margin: 18px 0 10px;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

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

.code-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 8px;
}

.code-box code {
  flex: 1;
  font-size: 14px;
  letter-spacing: 0.03em;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 20px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.detail-meta strong { color: var(--text); font-weight: 500; }

.table-scroll {
  overflow-x: auto;
}

#detail-machines-table {
  min-width: 560px;
}

#detail-machines-table td, #detail-machines-table th {
  font-size: 12px;
  padding: 8px 10px;
}

#detail-machines-table td.mono { font-family: var(--mono); font-size: 11.5px; }
