:root {
  --bg: #0b1020;
  --panel: #121a30;
  --panel-2: #18233f;
  --line: rgba(255,255,255,.1);
  --text: #eef2ff;
  --muted: #9fb0d1;
  --primary: #38bdf8;
  --primary-2: #0ea5e9;
  --danger: #fb7185;
  --warning: #fbbf24;
  --success: #34d399;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56,189,248,.12), transparent 32%),
    radial-gradient(circle at top right, rgba(15,118,110,.16), transparent 28%),
    var(--bg);
  color: var(--text);
}
.shell { max-width: 1440px; margin: 0 auto; padding: 10px 16px 20px; }
.topbar, .panel-head, .search-row, .tabs, .topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar, .panel-head { justify-content: space-between; }
.eyebrow { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #7dd3fc; font-weight: 700; }
h1 { font-size: 18px !important; }
h2 { font-size: 15px !important; }
h1, h2, h3, p { margin: 0; }
.subtitle { display: none; }
.panel-head p, .login-card p, .detail-muted { color: var(--muted); }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0,1fr));
  gap: 8px;
  margin: 8px 0;
}
.stat-card, .panel, .login-card, .activity-item, .badge-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(2,6,23,.22);
}
.stat-card { padding: 10px 12px; display: grid; gap: 2px; }
.stat-card span { color: var(--muted); font-size: 11px; }
.stat-card strong { font-size: 20px; line-height: 1.2; }
.stat-toggle-card { cursor: pointer; user-select: none; }
.stats-grid.revenue-collapsed .stat-revenue { display: none; }
.stat-unpaid strong { color: #f59e0b; }
.stat-unpaid span { color: #d97706 !important; }
.panel { padding: 10px 14px; margin-top: 6px; }
.tabs { margin-top: 6px; }
.tab-btn, .btn, input, select, textarea {
  font: inherit;
  border-radius: 10px;
}
.tab-btn, .btn {
  border: 1px solid var(--line);
  padding: 6px 12px;
  color: var(--text);
  background: rgba(255,255,255,.04);
  cursor: pointer;
}
.tab-btn.active, .btn-primary {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  border-color: transparent;
  color: #00111f;
  font-weight: 700;
}
.btn-secondary { background: rgba(56,189,248,.14); border-color: rgba(56,189,248,.2); transition: all 0.2s; }
.btn-secondary:hover { background: rgba(56,189,248,.25); }
.btn-ghost { background: transparent; transition: all 0.2s; }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-danger { background: rgba(251,113,133,.12); border-color: rgba(251,113,133,.28); color: #fecdd3; transition: all 0.2s; }
.btn-danger:hover { background: rgba(251,113,133,.25); }
.btn-sm { padding: 6px 12px !important; font-size: 13px !important; border-radius: 999px !important; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
input, select, textarea {
  min-width: 0;
  padding: 11px 14px;
  background: rgba(7,12,25,.84);
  border: 1px solid var(--line);
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
}
option {
  background: var(--bg);
  color: var(--text);
}
textarea { width: 100%; min-height: 90px; resize: vertical; }
.table-wrap { overflow: auto; }
.license-toolbar { justify-content: flex-end; width: 100%; }
.license-toolbar label { color: var(--muted); font-size: 13px; }
.license-toolbar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  padding: 6px 0 4px;
}
.license-table-wrap {
  margin-bottom: 0;
  overflow: auto;
  /* height set dynamically by JS to fill viewport */
}
.license-table-wrap::-webkit-scrollbar { width: 8px; height: 12px; }
.license-table-wrap::-webkit-scrollbar-track { background: rgba(255,255,255,0.06); border-radius: 6px; }
.license-table-wrap::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #0ea5e9, #38bdf8);
  border-radius: 6px;
  border: 2px solid #0d1931;
  min-width: 40px;
}
.license-table-wrap::-webkit-scrollbar-thumb:hover { background: #38bdf8; }
.license-scrollbar-wrap { display: none; }
table { width: 100%; min-width: 980px; border-collapse: collapse; margin-top: 16px; }
th, td { padding: 13px 10px; border-bottom: 1px solid rgba(255,255,255,.06); text-align: left; vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-weight: 600; }
thead { position: sticky; top: 0; z-index: 4; }
thead th { background: #0d1931; box-shadow: 0 1px 0 rgba(255,255,255,.08); }
th[data-col-key] { position: relative; }
th[data-col-key].is-dragging { opacity: .4; }
.col-resize-handle {
  position: absolute;
  top: 0;
  right: -2px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}
.col-resize-handle::before {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 3px;
  width: 1px;
  background: rgba(125, 211, 252, 0.35);
}
.col-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
}
.col-sort-indicator {
  display: inline-flex;
  width: 14px;
  justify-content: center;
  color: var(--primary);
  font-size: 11px;
  opacity: .9;
}
.col-sort[data-active="asc"] .col-sort-indicator::before { content: "▲"; }
.col-sort[data-active="desc"] .col-sort-indicator::before { content: "▼"; }
.col-sort[data-active="none"] .col-sort-indicator::before { content: "↕"; opacity: .5; }
.col-sort:hover { color: var(--text); }
.col-filter-btn {
  margin-left: 4px;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
}
.col-filter-btn.has-filter {
  color: #fbbf24;
}
.license-col-menu {
  position: fixed;
  z-index: 1200;
  min-width: 260px;
  max-width: 320px;
  background: #11192c;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 14px 34px rgba(2,6,23,.45);
  display: grid;
  gap: 8px;
}
.license-col-menu-title {
  font-weight: 700;
}
.license-col-menu-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.license-col-menu-label {
  color: var(--muted);
  font-size: 12px;
}
.status-pill, .mini-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}
.status-pill.active { background: rgba(52,211,153,.14); color: #86efac; border-color: rgba(52,211,153,.26); }
.status-pill.expired { background: rgba(251,191,36,.14); color: #fde68a; border-color: rgba(251,191,36,.24); }
.status-pill.revoked { background: rgba(251,113,133,.14); color: #fecdd3; border-color: rgba(251,113,133,.24); }
.status-pill.new { background: rgba(148,163,184,.16); color: #cbd5e1; border-color: rgba(148,163,184,.28); }
.status-pill.pass { background: rgba(52,211,153,.14); color: #86efac; border-color: rgba(52,211,153,.26); }
.status-pill.fail { background: rgba(251,113,133,.14); color: #fecdd3; border-color: rgba(251,113,133,.24); }
.status-pill.unknown { background: rgba(148,163,184,.16); color: #cbd5e1; border-color: rgba(148,163,184,.28); }

/* Inline select colors - background based */
.inline-select.pkg-monthly { background: rgba(59,130,246,.25) !important; color: #93c5fd !important; border-color: rgba(59,130,246,.4) !important; }
.inline-select.pkg-quarterly { background: rgba(52,211,153,.2) !important; color: #86efac !important; border-color: rgba(52,211,153,.35) !important; }
.inline-select.pkg-yearly { background: rgba(251,191,36,.2) !important; color: #fde68a !important; border-color: rgba(251,191,36,.35) !important; }
.inline-select.pkg-lifetime { background: rgba(139,92,246,.25) !important; color: #c4b5fd !important; border-color: rgba(139,92,246,.4) !important; }

.inline-select.st-active { background: rgba(52,211,153,.2) !important; color: #86efac !important; border-color: rgba(52,211,153,.35) !important; }
.inline-select.st-unactivated { background: rgba(148,163,184,.15) !important; color: #cbd5e1 !important; border-color: rgba(148,163,184,.3) !important; }
.inline-select.st-expired { background: rgba(251,191,36,.2) !important; color: #fde68a !important; border-color: rgba(251,191,36,.35) !important; }
.inline-select.st-revoked { background: rgba(251,113,133,.2) !important; color: #fecdd3 !important; border-color: rgba(251,113,133,.35) !important; }

/* CTV colors */
.inline-select.ctv-0 { background: rgba(56,189,248,.2) !important; color: #7dd3fc !important; border-color: rgba(56,189,248,.35) !important; }
.inline-select.ctv-1 { background: rgba(168,85,247,.2) !important; color: #d8b4fe !important; border-color: rgba(168,85,247,.35) !important; }
.inline-select.ctv-2 { background: rgba(251,146,60,.2) !important; color: #fdba74 !important; border-color: rgba(251,146,60,.35) !important; }
.inline-select.ctv-3 { background: rgba(52,211,153,.2) !important; color: #86efac !important; border-color: rgba(52,211,153,.35) !important; }
.inline-select.ctv-4 { background: rgba(251,113,133,.2) !important; color: #fda4af !important; border-color: rgba(251,113,133,.35) !important; }
.inline-select.ctv-5 { background: rgba(96,165,250,.2) !important; color: #93c5fd !important; border-color: rgba(96,165,250,.35) !important; }
.inline-select.ctv-6 { background: rgba(253,224,71,.18) !important; color: #fef08a !important; border-color: rgba(253,224,71,.3) !important; }
.inline-select.ctv-7 { background: rgba(45,212,191,.2) !important; color: #5eead4 !important; border-color: rgba(45,212,191,.35) !important; }

/* Paid select */
.inline-select.paid-yes { background: rgba(52,211,153,.2) !important; color: #86efac !important; border-color: rgba(52,211,153,.35) !important; }
.inline-select.paid-no { background: rgba(251,113,133,.2) !important; color: #fecdd3 !important; border-color: rgba(251,113,133,.35) !important; }

/* Delete X button */
.del-x {
  position: absolute;
  top: 2px;
  right: 2px;
  cursor: pointer;
  color: rgba(251,113,133,.5);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}
tr:hover .del-x { opacity: 1; }
.del-x:hover { color: #fb7185; }
.activity-list { display: grid; gap: 12px; margin-top: 16px; }
.activity-item { padding: 16px; display: grid; gap: 8px; }
.activity-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.detail-panel .detail-content { margin-top: 16px; }
.detail-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.badge-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.badge-card { padding: 16px; display: grid; gap: 6px; }
.badge-card span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.badge-card strong { font-size: 18px; }
.stack { display: grid; gap: 14px; }
.detail-box {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
}
.detail-box h3 { margin-bottom: 10px; }
.note-item, .license-item, .order-item, .chatbot-item {
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.note-item:last-child, .license-item:last-child, .order-item:last-child, .chatbot-item:last-child { border-bottom: 0; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.empty-state { color: var(--muted); padding: 22px 4px; }
.form-grid { display: grid; gap: 12px; }
.form-error { min-height: 20px; color: #fecdd3; font-size: 13px; }
.login-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2,6,23,.65);
  backdrop-filter: blur(8px);
  z-index: 999;
}
.login-modal.is-hidden { display: none; }
.login-card { width: min(420px, calc(100vw - 28px)); padding: 22px; }
.license-detail-modal {
  width: min(1360px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  overflow: auto;
  padding: 20px 22px;
  background: linear-gradient(180deg, #11192c 0%, #0f1728 100%);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(2,6,23,.48);
}
.license-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, #11192c 0%, rgba(17,25,44,.96) 75%, rgba(17,25,44,.88) 100%);
  padding-bottom: 12px;
}
.license-detail-content {
  display: grid;
  gap: 18px;
  background: #11192c;
}
.license-check-line { display: grid; gap: 6px; }
.detail-list { display: grid; gap: 10px; }
.detail-kv { display: grid; gap: 4px; }
.detail-kv strong { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.check-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.check-card { padding: 14px; border-radius: 16px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.03); display: grid; gap: 8px; }
.check-card span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.check-card strong { font-size: 18px; }
.machine-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 14px; }
.field-diff-list { display: grid; gap: 10px; margin-top: 10px; }
.field-diff-item { padding: 10px 12px; border-radius: 14px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.03); display: grid; gap: 6px; }
.field-diff-item.matched { border-color: rgba(52,211,153,.22); }
.field-diff-item.changed { border-color: rgba(251,113,133,.22); }
.field-diff-item.missing_current,
.field-diff-item.missing_baseline { border-color: rgba(251,191,36,.22); }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; word-break: break-all; }
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th, .detail-table td { padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,.06); vertical-align: top; }
.detail-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.link-button { color: var(--primary); cursor: pointer; text-decoration: underline; }
.license-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  background: #11192c;
}
.detail-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.detail-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.detail-form-field { display: grid; gap: 6px; }
.detail-form-field span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.detail-form-field input,
.detail-form-field select,
.detail-form-field textarea { width: 100%; min-width: 0; background: rgba(7,12,25,.9); border: 1px solid rgba(255,255,255,.1); color: var(--text); border-radius: 12px; padding: 11px 12px; }
.detail-form-field textarea { min-height: 96px; resize: vertical; }
.detail-form-field-full { grid-column: 1 / -1; }
.license-priority-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.license-priority-item {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(125, 211, 252, 0.2);
  background: linear-gradient(180deg, rgba(56,189,248,.08), rgba(56,189,248,.03));
  display: grid;
  gap: 6px;
}
.license-priority-item span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
}
.license-priority-item strong {
  font-size: 16px;
  line-height: 1.3;
}
.license-priority-item-full {
  grid-column: 1 / -1;
}
.date-stack { display: grid; gap: 2px; line-height: 1.1; }
.date-stack.compact { margin-bottom: 8px; }
.date-time { font-weight: 700; }
.date-date { color: var(--muted); font-size: 12px; }
.single-line-cell { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-line-edit { display: block; color: var(--muted); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-inline-line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-line-edit { color: inherit; font-size: inherit; font-weight: inherit; }
.ctv-cell { display: flex; gap: 8px; align-items: center; min-width: 160px; }
.ctv-cell .inline-select { flex: 1; min-width: 0; }
.ctv-add-btn { flex: 0 0 auto; padding-inline: 10px !important; }
.field-edit-modal { width: min(760px, calc(100vw - 20px)); }
.field-edit-head { margin-bottom: 16px; }
.field-edit-body { display: grid; gap: 12px; }
.field-edit-body textarea { min-height: 260px; resize: vertical; }
a { color: #7dd3fc; text-decoration: none; }
code { word-break: break-all; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .detail-grid, .badge-grid { grid-template-columns: 1fr 1fr; }
  .check-card-grid, .machine-grid { grid-template-columns: 1fr 1fr; }
  .license-layout { grid-template-columns: 1fr; }
  .ctv-cell { min-width: 0; }
}
@media (max-width: 760px) {
  .stats-grid, .detail-grid, .badge-grid { grid-template-columns: 1fr; }
  .check-card-grid, .machine-grid { grid-template-columns: 1fr; }
  .detail-form-grid { grid-template-columns: 1fr; }
  .license-priority-grid { grid-template-columns: 1fr; }
  .shell { padding-left: 14px; padding-right: 14px; }
  .ctv-cell { flex-direction: column; align-items: stretch; }
  .field-edit-modal { width: min(760px, calc(100vw - 18px)); }
}

/* Inline Edit Styles */
.inline-input {
  background: rgba(7, 12, 25, 0.84);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9em;
  width: 100%;
  box-sizing: border-box;
}
.inline-select {
  background: rgba(18, 26, 48, 0.95);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 2px 20px 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.85em;
  width: auto;
  min-width: 60px;
  cursor: pointer;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg fill=\"white\" height=\"16\" viewBox=\"0 0 24 24\" width=\"16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7 10l5 5 5-5z\"/></svg>');
  background-repeat: no-repeat;
  background-position-x: calc(100% - 4px);
  background-position-y: center;
}
.inline-select option {
  background: #121a30;
  color: #eef2ff;
}
.inline-input:focus, .inline-select:focus {
  border-color: var(--primary);
  outline: none;
}
.editable-cell {
  cursor: text;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.2s;
  min-height: 24px;
  display: block;
}
.editable-cell:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Custom Detail Tabs inside License Detail Modal */
.detail-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}
.detail-tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}
.detail-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}
.detail-tab-btn.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

/* state-of-the-art visual grid for google account details */
.google-account-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  backdrop-filter: blur(10px);
}
.google-account-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}
.google-account-header h3 {
  margin: 0;
  font-size: 18px;
  color: #86efac;
  display: flex;
  align-items: center;
  gap: 8px;
}
.google-account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.google-account-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.15);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.google-account-field span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.google-account-value-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
}
.google-account-value {
  font-family: monospace;
  font-size: 13px;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-grow: 1;
}
.google-account-field-full {
  grid-column: 1 / -1;
}
.google-account-field-full .google-account-value {
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 80px;
  overflow-y: auto;
}
.btn-copy-mini {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-copy-mini:hover {
  background: var(--primary);
  border-color: var(--primary);
}
