/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ---- Theme (ported from SudoRender admin design system) ---- */
:root {
  --bg:         #0f1310;
  --bg2:        #161d18;   /* panel */
  --bg3:        #1a231c;   /* raised panel / code blocks */
  --bg-hover:   #1a231c;
  --sidebar:    #121712;
  --text:       #dbe7df;
  --name:       #f0f6ef;   /* brightest — titles, primary names */
  --muted:      #9db3a4;
  --dim:        #7d9a86;
  --label:      #6f8a7a;   /* micro-labels */
  --accent:     #7fe6a6;
  --border:     #232f26;
  --border-mid: #2e3d31;
  --input-border: #2a3a30;
  --focus-border: #4c7a5c;
  --red:        #e08a8a;
  --danger:     #e08a8a;
  --green:      #8fe6ab;
  --yellow:     #e6b566;
  --blue:       #8aa6c8;
  --pink:       #d8a6c8;
  --purple:     #b8a6e0;
  --font:       'Space Grotesk', system-ui, sans-serif;
  --mono:       'IBM Plex Mono', monospace;
}

html { scrollbar-color: var(--border-mid) transparent; }
html, body {
  width: 100%; height: 100%;
  font: 14px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(127, 230, 166, .22); }
::placeholder { color: #5f7768; opacity: 1; }

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

/* ---- App layout ---- */
#app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */
#app-header {
  width: 224px;
  min-width: 224px;
  height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

body.no-sidebar #app-header { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---- Cross-app switcher ---- */
.app-switcher { position: relative; display: inline-flex; flex-shrink: 0; }
.app-switcher-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--muted); cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.app-switcher-btn:hover { color: var(--text); border-color: var(--border-mid); background: var(--bg2); filter: none; }
.app-switcher-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 300;
  width: 160px; background: var(--bg3); border: 1px solid var(--border-mid);
  border-radius: 12px; padding: 6px; box-shadow: 0 16px 48px rgba(0, 0, 0, .5); display: none;
}
.app-switcher.open .app-switcher-menu { display: block; }
.app-switcher-title { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--label); padding: 6px 10px 5px; }
.app-switcher-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 13.5px; font-weight: 500; }
.app-switcher-item:hover { background: var(--bg2); text-decoration: none; }
.app-switcher-item.current { color: var(--accent); }
.app-switcher-mono { width: 24px; height: 24px; flex: none; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 12px; font-weight: 600; background: rgba(127, 230, 166, .12); color: var(--accent); border: 1px solid rgba(127, 230, 166, .25); }
.app-switcher-check { margin-left: auto; color: var(--accent); }
.sidebar-brand a {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--name);
  text-decoration: none;
}
.sidebar-brand a:hover { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-section { padding: 0 10px; }

.sidebar-section-label {
  padding: 16px 12px 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--label);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 8px;
  border-left: 2px solid transparent;
  transition: background .1s, color .1s;
}
.sidebar-nav a:hover {
  color: var(--text);
  background: var(--bg2);
  text-decoration: none;
}
.sidebar-nav a.active {
  color: var(--accent);
  background: rgba(127, 230, 166, .08);
}
.sidebar-nav a svg { flex-shrink: 0; opacity: .6; }
.sidebar-nav a.active svg, .sidebar-nav a:hover svg { opacity: 1; }

/* Nav row with an inline quick-action (e.g. + Generate license) */
.nav-item-row { display: flex; align-items: center; }
.nav-item-row > a { flex: 1; }
.nav-quick-add {
  flex-shrink: 0;
  width: auto;
  min-width: 0;
  height: 26px;
  margin: 0 4px 0 4px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--dim);
  line-height: 0;
  cursor: pointer;
  transition: background .1s, color .1s, border-color .1s;
}
.nav-quick-add:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(127, 230, 166, .08);
  filter: none;
}

.sidebar-spacer { flex: 1; }

.sidebar-account {
  padding: 14px 18px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-account-email {
  font-size: 11px;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
}
.sidebar-account-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.btn-logout {
  font: 500 12px var(--font);
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
  width: 100%;
  text-align: center;
  transition: color .1s, border-color .1s, background .1s;
}
.btn-logout:hover { color: var(--text); border-color: var(--border-mid); background: var(--bg2); opacity: 1; filter: none; }

/* ---- Main content ---- */
#main-content {
  flex: 1;
  overflow-y: auto;
  height: 100vh;
}

/* ---- Container ---- */
.container { max-width: 1280px; margin: 0 auto; padding: 30px 34px 80px; }

/* ---- Headings ---- */
h2 { font-size: 22px; font-weight: 600; letter-spacing: -.4px; color: var(--name); margin-bottom: 18px; }
h3 {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--label);
  margin-bottom: 10px;
}

/* ---- Page head (title + action row) ---- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head h2 { margin: 0; }

/* ---- Buttons ---- */
button {
  font: 600 13px var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  padding: 9px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  white-space: nowrap;
  transition: filter .15s, background .15s, color .15s, border-color .15s;
}
button:hover { filter: brightness(1.08); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[aria-busy="true"] { opacity: .5; pointer-events: none; }
button:disabled { opacity: .35; cursor: default; filter: none; }
button.secondary, button.outline {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}
button.secondary:hover, button.outline:hover {
  color: var(--text);
  border-color: var(--border-mid);
  background: var(--bg2);
  filter: none;
}
button.danger, button.secondary.danger {
  background: rgba(224, 138, 138, .08);
  color: var(--red);
  border: 1px solid #3a2626;
}
button.danger:hover, button.secondary.danger:hover {
  background: rgba(224, 138, 138, .16);
  border-color: #a05050;
  color: var(--red);
  filter: none;
}
.btn-sm { padding: 5px 11px; font-size: 12px; font-weight: 500; border-radius: 7px; }

/* ---- Forms ---- */
input, select, textarea {
  font: 13.5px var(--font);
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--input-border);
  padding: 9px 12px;
  border-radius: 9px;
  outline: none;
  width: 100%;
}
textarea { font-family: var(--font); line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--focus-border); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 5px; }

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input[type="search"] { flex: 1; min-width: 220px; }
.toolbar select { width: auto; min-width: 130px; }
.toolbar button { white-space: nowrap; }

/* ---- Segmented toggle (dashboard range, etc.) ---- */
.view-toggle, .dash-range-toggle {
  display: inline-flex;
  background: var(--bg2);
  border: 1px solid var(--input-border);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 16px;
}
.view-toggle button, .dash-range-toggle button,
.view-toggle button.secondary, .dash-range-toggle button.secondary {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
}
.view-toggle button:hover, .dash-range-toggle button:hover {
  color: var(--text); background: transparent; filter: none;
}
.dash-range-toggle button:not(.secondary),
.view-toggle button.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--label);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
}
tbody tr { transition: background .1s; }
tr.clickable { cursor: pointer; }
tr.clickable:hover, .lic-table tbody tr:hover,
.admin-table tbody tr[data-email]:hover,
.admin-table tbody tr.row-clickable:hover { background: var(--bg-hover); }

/* Data tables sit in a rounded panel */
.overflow-auto, .lic-table, .admin-table { position: relative; }
.lic-table, .admin-table {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.lic-table th:first-child, .admin-table th:first-child,
.lic-table td:first-child, .admin-table td:first-child { padding-left: 18px; }
.lic-table th:last-child, .admin-table th:last-child,
.lic-table td:last-child, .admin-table td:last-child { padding-right: 18px; }
.lic-table tbody tr:last-child td, .admin-table tbody tr:last-child td { border-bottom: none; }

.lic-table .mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}
.pagination button { padding: 5px 12px; font-size: 12px; }

/* ---- Detail page ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px 18px;
  margin-bottom: 20px;
  font-size: 13.5px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}
.detail-grid dt {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
  text-align: right;
  color: var(--label);
  padding-top: 3px;
}
.detail-grid dd { margin: 0; }
.detail-grid dd input,
.detail-grid dd textarea {
  display: inline-block;
  width: auto;
  padding: 5px 9px;
  font-size: 13px;
}

.device-list { list-style: none; }
.device-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 6px;
  font-size: 12.5px;
}
.device-list li:hover { border-color: var(--border-mid); }
.device-list .device-info { word-break: break-all; color: var(--text); }
.device-list button { margin-left: 10px; padding: 5px 10px; font-size: 11px; }

/* ---- Users / admin sections ---- */
.admin-section { margin-bottom: 24px; }
.admin-section > h3 { margin-bottom: 12px; }
.admin-table td, .admin-table th { padding-top: 9px; padding-bottom: 9px; }

/* ---- Inline forms ---- */
.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-top: 12px;
}
.inline-form input, .inline-form select { width: auto; min-width: 150px; }
.inline-form button { white-space: nowrap; }

/* ---- Modal / dialog ---- */
dialog {
  max-width: 460px;
  width: 92%;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border-mid);
  border-radius: 14px;
  padding: 0;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
}
dialog[open] { animation: modal-in .18s ease; }
@keyframes modal-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}
dialog::backdrop { background: rgba(5, 8, 6, .72); }
dialog article { padding: 0; }
dialog header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
dialog header h3 {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: -.2px;
  color: var(--name);
  margin: 0;
  flex: 1;
}
.modal-close {
  order: 2;
  background: transparent;
  border: none;
  color: var(--dim);
  width: 26px; height: 26px;
  padding: 0;
  border-radius: 7px;
  position: relative;
  flex-shrink: 0;
}
.modal-close::before {
  content: '\00d7';
  font-size: 20px;
  line-height: 1;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.modal-close:hover { color: var(--text); background: var(--bg3); filter: none; }
dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}
.modal-body { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal-body label { margin-bottom: 12px; }
.modal-body label.label-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.modal-body label.label-checkbox input[type="checkbox"] { width: auto; margin: 0; }

/* ---- Badge / pill ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-color: var(--border-mid);
}
.badge-psslic      { border-color: var(--accent); color: var(--accent); }
.badge-gumroad     { border-color: var(--pink); color: var(--pink); }
.badge-pluginplay  { border-color: var(--purple); color: var(--purple); }
.badge-prefix      { border-color: var(--yellow); color: var(--yellow); margin-right: 4px; }
.badge-active      { border-color: var(--accent); color: var(--accent); background: rgba(127, 230, 166, .08); }
.badge-deactivated { border-color: var(--red); color: var(--red); background: rgba(224, 138, 138, .08); }

/* ---- Toast (flash style: colored border + translucent fill) ---- */
#toast-root {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid;
  max-width: 360px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-color: var(--accent); color: var(--accent); background: rgba(127, 230, 166, .08); }
.toast-error   { border-color: var(--red); color: var(--red); background: rgba(224, 138, 138, .08); }
.toast-info    { border-color: var(--blue); color: var(--blue); background: rgba(138, 166, 200, .08); }

/* ---- Login ---- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.login-card {
  width: 360px;
  max-width: 92vw;
  text-align: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 44px 36px;
}
.login-card h1 { font-size: 21px; font-weight: 600; letter-spacing: -.4px; color: var(--name); margin-bottom: 6px; }
.login-card h2 { font-size: 18px; text-align: center; }
.login-card p { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card hgroup { margin-bottom: 4px; }
.login-card button.contrast {
  background: none;
  border: 1px solid var(--border-mid);
  color: var(--text);
  padding: 11px 20px;
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 9px;
}
.login-card button.contrast:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.error-text { color: var(--red); margin-top: 10px; font-size: 12px; }

/* ---- License key hero ---- */
.license-key-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.license-key-hero code {
  font: 600 20px/1.3 var(--mono);
  color: var(--accent);
  word-break: break-all;
  user-select: all;
  flex: 1;
}
.license-key-hero .btn-copy {
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 12px;
  width: auto;
}

.license-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
}
.license-result .license-key {
  flex: 1;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  word-break: break-all;
  user-select: all;
}
.license-result .btn-copy-key {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
}

/* ---- Misc ---- */
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--dim); }
.overflow-auto { overflow-x: auto; }
.mono { font-family: var(--mono); word-break: break-all; color: var(--accent); font-size: 12px; }
code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--bg3);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--muted);
}
.btn-copy {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--dim); cursor: pointer; padding: 3px 5px; margin-right: 8px;
  vertical-align: middle; line-height: 0;
}
.btn-copy:hover { color: var(--accent); border-color: var(--accent); background: rgba(127, 230, 166, .06); filter: none; }

/* ---- Dashboard ---- */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.dash-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.dash-card-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.5px;
  color: var(--accent);
  line-height: 1.2;
}
.dash-card-label {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--label);
  margin-top: 4px;
}
.dash-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.dash-chart-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.dash-chart-box h3 { margin-bottom: 12px; }
.dash-chart-wrap { height: 220px; position: relative; }
.dash-recent { max-height: 240px; overflow-y: auto; }
.dash-recent table { font-size: 12px; table-layout: fixed; width: 100%; }
.dash-recent th { font-size: 9.5px; }
.dash-recent td { padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-recent .mono { font-size: 11px; }

/* ---- Setup / profile sections ---- */
.setup-section { margin-bottom: 28px; }
.setup-section > summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: 8px;
}
.setup-section > summary::-webkit-details-marker { display: none; }
.setup-section > summary h3 { margin: 0; }
.setup-section h3 { margin-bottom: 10px; }
.setup-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.setup-table th { text-align: left; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--label); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.setup-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.setup-label { white-space: nowrap; color: var(--muted); width: 150px; }
.setup-flow { padding-left: 20px; font-size: 13px; line-height: 1.8; }
.setup-flow code { font-family: var(--mono); font-size: 12px; }

/* ---- Standalone-products separator row ---- */
.sep-row td {
  font-family: var(--mono);
  font-size: 9.5px !important;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--label) !important;
  opacity: 1 !important;
  background: var(--bg3);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  #app-header { width: 190px; min-width: 190px; }
  .container { padding: 22px 20px 60px; }
  .dash-cards { grid-template-columns: repeat(2, 1fr); }
  .dash-charts { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .detail-grid dt { text-align: left; margin-top: 8px; }
}

/* ============================================================
   pss-sales additions
   ============================================================ */

/* ---- Currency toggle (sidebar) ---- */
.currency-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.currency-toggle button {
  flex: 1;
  font: 500 10.5px var(--mono);
  letter-spacing: 1px;
  padding: 6px 0;
  background: transparent;
  color: var(--dim);
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: background .1s, color .1s;
}
.currency-toggle button:hover { color: var(--text); background: var(--bg2); filter: none; }
.currency-toggle button.active {
  background: rgba(127, 230, 166, .1);
  color: var(--accent);
}

/* ---- KPI tiles ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
}
.kpi-label {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--label);
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.6px;
  color: var(--accent);
  line-height: 1.15;
}
.kpi-value.plain { color: var(--name); }
.kpi-sub {
  margin-top: auto;
  padding-top: 6px;
  font-size: 11px;
  color: var(--dim);
}
.kpi-sub .up { color: var(--green); }
.kpi-sub .down { color: var(--red); }
.kpi.muted .kpi-value { color: var(--dim); }

/* thin progress rail for "% of FY elapsed" */
.kpi-rail {
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.kpi-rail span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

/* ---- Chart panels ---- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.chart-grid.full { grid-template-columns: 1fr; }
.chart-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.chart-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.chart-box-head h3 { margin: 0; }
.chart-wrap { height: 240px; position: relative; }
.chart-wrap.tall { height: 320px; }
.chart-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 12px;
}

/* ---- Milestone toggle ---- */
.ms-toggle button { font-size: 10px; padding: 4px 8px; }

/* ---- Banners ---- */
.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg3);
  border: 1px solid var(--border-mid);
  border-left: 2px solid var(--yellow);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.banner.info { border-left-color: var(--blue); }
.banner.danger { border-left-color: var(--red); }
.banner strong { color: var(--name); font-weight: 600; }

/* ---- Data tables ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--label);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table th.no-sort { cursor: default; }
.data-table th.sorted { color: var(--accent); }
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table .num { text-align: right; font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.data-table .name { color: var(--name); font-weight: 500; }
.data-table .up { color: var(--green); }
.data-table .down { color: var(--red); }
.data-table .dim { color: var(--dim); }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--dim);
}
.badge.on { color: var(--accent); border-color: rgba(127,230,166,.3); background: rgba(127,230,166,.08); }
.badge.off { color: var(--dim); }
.badge.warn { color: var(--yellow); border-color: rgba(230,181,102,.3); background: rgba(230,181,102,.08); }
.badge.danger { color: var(--red); border-color: rgba(224,138,138,.3); background: rgba(224,138,138,.08); }

/* ---- Sparklines ---- */
.spark { display: block; width: 90px; height: 24px; }

/* ---- Import ---- */
.dropzone {
  border: 1.5px dashed var(--border-mid);
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--bg2);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: rgba(127, 230, 166, .04);
}
.dropzone strong { color: var(--name); display: block; margin-bottom: 4px; font-size: 15px; }
.import-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 16px 0; }
.import-stat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; text-align: center;
}
.import-stat .n { font-size: 20px; font-weight: 600; color: var(--name); }
.import-stat.added .n { color: var(--green); }
.import-stat.refunded .n { color: var(--yellow); }
.import-stat.errors .n { color: var(--red); }
.import-stat .l {
  font-family: var(--mono); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 1.1px; color: var(--label); margin-top: 3px;
}
.progress-rail { height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; margin: 10px 0; }
.progress-rail span { display: block; height: 100%; background: var(--accent); transition: width .2s; }

/* ---- Column mapper ---- */
.mapper { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px 12px; align-items: center; }
.mapper-col { font-family: var(--mono); font-size: 11.5px; color: var(--text); }
.mapper-arrow { color: var(--dim); }
.mapper select { width: 100%; }

/* ---- Misc ---- */
.mono { font-family: var(--mono); }
.text-muted { color: var(--muted); }
.text-dim { color: var(--dim); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.spinner-row { padding: 40px; text-align: center; color: var(--dim); font-size: 13px; }

/* ---- Wide modal ----
   The source mapper wizard carries a 3-column mapper and a 6-column preview
   table; the 460px default dialog would force both into horizontal scroll. */
dialog.modal-wide { max-width: 880px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .import-stats { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Scope (product filter) ---- */
.scope-btn {
  display: flex; align-items: center; gap: 7px; width: 100%;
  font: 500 12px var(--font); text-align: left;
  padding: 7px 10px; margin-bottom: 8px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  transition: color .1s, border-color .1s, background .1s;
}
.scope-btn:hover { color: var(--text); border-color: var(--border-mid); background: var(--bg2); filter: none; }
.scope-btn > span:first-of-type { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-clear {
  flex: none; width: 16px; height: 16px; line-height: 15px; text-align: center;
  border-radius: 4px; color: var(--dim); font-size: 14px;
}
.scope-clear:hover { color: var(--red); background: rgba(224,138,138,.12); }

.scope-picker { max-height: 52vh; overflow-y: auto; }
.scope-group { margin-bottom: 12px; }
.scope-group-head {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--name); font-size: 13px;
  padding: 6px 8px; border-radius: 7px; background: var(--bg3); cursor: pointer;
}
.scope-count {
  margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--label);
}
.scope-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px 5px 24px; font-size: 12.5px; color: var(--text);
  border-radius: 6px; cursor: pointer;
}
.scope-item:hover { background: var(--bg-hover); }
.scope-swatch, .cat-swatch {
  width: 9px; height: 9px; border-radius: 2px; flex: none; display: inline-block;
}
.cat-swatch { margin-right: 7px; vertical-align: baseline; }

/* FX state under the currency toggle — the rate must never be invisible */
.fx-note {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .3px;
  color: var(--dim);
  margin: -4px 0 8px;
  line-height: 1.3;
}
.fx-note.warn { color: var(--yellow); }
