:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0e1a2b;
  --surface-2: #132238;
  --surface-3: #182a43;
  --line: #263a55;
  --text: #edf5ff;
  --muted: #91a5bd;
  --primary: #2bb6a8;
  --primary-strong: #1f9489;
  --danger: #ff6b73;
  --warning: #f6c55c;
  --ok: #52d273;
  --shadow: 0 22px 60px rgba(0,0,0,.32);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(43,182,168,.12), transparent 30rem),
    var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.full { width: 100%; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  padding: 34px;
  background: linear-gradient(180deg, rgba(19,34,56,.98), rgba(14,26,43,.98));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 30px 0 8px; font-size: 28px; }
.login-card p { margin: 0 0 24px; line-height: 1.6; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #38c8b8, #197e76);
  font-weight: 800; letter-spacing: .04em; color: #041310;
  box-shadow: 0 10px 30px rgba(43,182,168,.22);
}
.brand strong, .brand span { display: block; }
.brand span { color: var(--muted); font-size: 13px; margin-top: 2px; }

label { display: grid; gap: 8px; margin-bottom: 16px; color: #c9d6e6; font-size: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #091625;
  color: var(--text);
  border-radius: 11px;
  padding: 12px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,182,168,.13);
}
textarea { min-height: 90px; resize: vertical; }

.primary, .secondary, .ghost, .danger-btn {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
  color: var(--text);
  font-weight: 650;
}
.primary { background: var(--primary); color: #031412; }
.primary:hover { background: #36c7b8; }
.secondary { background: var(--surface-3); border-color: var(--line); }
.secondary:hover, .ghost:hover { border-color: #3a5679; background: #172942; }
.ghost { background: transparent; border-color: var(--line); }
.danger-btn { background: rgba(255,107,115,.12); border-color: rgba(255,107,115,.38); color: #ff9ca1; }
.form-error { min-height: 20px; margin-top: 12px; color: #ff9ca1; font-size: 14px; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 20px;
  background: rgba(7,17,31,.94);
  border-right: 1px solid var(--line);
}
.sidebar nav { margin-top: 34px; }
.nav-item {
  width: 100%;
  text-align: left;
  background: rgba(43,182,168,.1);
  color: #cffff8;
  border: 1px solid rgba(43,182,168,.22);
  border-radius: 10px;
  padding: 11px 12px;
}
.sidebar-foot { margin-top: auto; }
.secure-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.main { min-width: 0; padding: 34px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.topbar h1 { margin: 4px 0 0; font-size: clamp(27px, 3vw, 38px); }
.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--primary);
  font-weight: 800;
}
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; margin: 8px 0 5px; font-size: 31px; }

.panel {
  background: rgba(14,26,43,.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 16px 50px rgba(0,0,0,.14);
  overflow: hidden;
}
.panel-head {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0 0 4px; font-size: 19px; }
.panel-head p { margin: 0; font-size: 13px; }
.search-wrap { width: min(360px, 100%); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid rgba(38,58,85,.7); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
td { font-size: 14px; vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,.018); }
.actions-col { width: 240px; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.small-btn {
  background: #12243a;
  border: 1px solid var(--line);
  color: #d8e8fa;
  padding: 7px 9px;
  border-radius: 8px;
}
.small-btn:hover { border-color: #456485; }
.customer-name { font-weight: 700; }
.customer-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
}
.badge.active { color: #90f3a7; background: rgba(82,210,115,.09); border-color: rgba(82,210,115,.28); }
.badge.blocked, .badge.revoked { color: #ff9ca1; background: rgba(255,107,115,.08); border-color: rgba(255,107,115,.3); }
.badge.suspended, .badge.expired { color: #ffe29a; background: rgba(246,197,92,.08); border-color: rgba(246,197,92,.3); }

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

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(2,8,16,.72);
  backdrop-filter: blur(7px);
}
.modal {
  width: min(640px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-body { padding: 20px; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  font-size: 28px; line-height: 1;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.license-key-box {
  padding: 14px;
  border: 1px solid rgba(43,182,168,.35);
  border-radius: 12px;
  background: rgba(43,182,168,.07);
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 16px;
  margin: 14px 0;
}
.warning-box {
  border-left: 3px solid var(--warning);
  padding: 10px 12px;
  background: rgba(246,197,92,.07);
  color: #f8dfa7;
  line-height: 1.5;
  font-size: 13px;
}
.machine-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0a1727;
  margin-bottom: 10px;
}
.machine-id { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; font-size: 12px; color: #c4d5e8; }
.machine-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin: 8px 0 12px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 420px;
  background: #10243a;
  border: 1px solid #345273;
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 100;
}

@media (max-width: 1020px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; height: auto; position: static; flex-direction: row; align-items: center; gap: 18px; }
  .sidebar nav { margin: 0; }
  .sidebar-foot { margin: 0 0 0 auto; display: flex; align-items: center; gap: 12px; }
  .secure-note { display: none; }
}
@media (max-width: 680px) {
  .main { padding: 20px 14px; }
  .topbar, .panel-head { align-items: stretch; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .sidebar { padding: 14px; }
  .sidebar nav { display: none; }
  .brand span { display: none; }
}
