:root {
  --bg-1: #f4f1ea;
  --bg-2: #e8dfd0;
  --panel: #fffaf2;
  --panel-2: #fff;
  --ink: #1f2a30;
  --muted: #5d6b73;
  --line: #d3c7b5;
  --table-line: #ece2d3;
  --th-bg: #f4ecdf;
  --hero-text: #f5f6f7;
  --hero-subtext: #d7e1e8;
  --accent: #0e6b65;
  --accent-2: #d37d2f;
  --danger: #b33f40;
  --ok: #2e7d4c;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(31, 42, 48, 0.08);
}

body[data-theme="dark"] {
  --bg-1: #0f1b21;
  --bg-2: #1d2e38;
  --panel: #17252d;
  --panel-2: #1d2f38;
  --ink: #e9f0f4;
  --muted: #9eb0bb;
  --line: #2c4552;
  --table-line: #2c4552;
  --th-bg: #1f333d;
  --hero-text: #f8fbfd;
  --hero-subtext: #bdd0da;
  --accent: #2aa59d;
  --accent-2: #d59b3e;
  --danger: #d86c6d;
  --ok: #47a86a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  font: 15px/1.45 "Segoe UI", "Trebuchet MS", sans-serif;
}

.shell {
  width: min(1260px, 95vw);
  margin: 24px auto 40px;
}

.hero {
  background: linear-gradient(125deg, #1f2a30, #2f4a57);
  color: var(--hero-text);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hero h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.2px;
}

.hero p {
  margin: 8px 0 0;
  color: var(--hero-subtext);
}

.theme-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.field { margin-bottom: 12px; }

.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  background: var(--panel-2);
}

textarea { min-height: 74px; resize: vertical; }

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  color: white;
  background: var(--accent);
}

button.secondary { background: #607580; }
button.warn { background: var(--accent-2); }
button.danger { background: var(--danger); }
button:disabled { opacity: 0.65; cursor: not-allowed; }

.divider {
  margin: 14px 0;
  border: none;
  border-top: 1px solid var(--line);
}

.status {
  margin-top: 10px;
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 600;
  display: none;
}

.status.ok { display: block; color: #0f542d; background: #d9f3e2; }
.status.err { display: block; color: #6d1313; background: #f8dddd; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar.wrap {
  align-items: flex-start;
  flex-direction: column;
}

.toolbar .meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.search-input {
  width: 170px;
}

.state-select {
  width: 150px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

.table-wrap.license-scroll {
  max-height: 540px;
  overflow-y: auto;
  overflow-x: auto;
}

.table-wrap.transfer-scroll {
  max-height: 260px;
  overflow-y: auto;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--table-line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

th {
  background: var(--th-bg);
  font-size: 12px;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky;
  top: 0;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-col {
  width: 120px;
  min-width: 120px;
  white-space: nowrap;
}

.badge.live { background: #def6e8; color: #0b5d2f; }
.badge.revoked { background: #f7dfdf; color: #7c1e1f; }

.machines {
  margin-top: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel);
  font-size: 13px;
}

.machines ul { margin: 6px 0 0 18px; }

.license-key {
  font-family: "Consolas", "Lucida Console", monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.small {
  color: var(--muted);
  font-size: 12px;
}

.notes-edit {
  min-height: 60px;
}

.import-preview {
  margin-top: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel-2);
  display: none;
}

.import-preview.visible {
  display: block;
}

.import-conflict {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 8px;
  margin-bottom: 8px;
}

@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; }
  .shell { width: min(1260px, 98vw); }
  .hero h1 { font-size: 24px; }
  .hero-top { flex-direction: column; }
  .table-wrap.license-scroll { max-height: 360px; }
  .table-wrap.transfer-scroll { max-height: 220px; }
  .search-input, .state-select { width: 100%; }
}
