/* HostBMS — "glass" admin theme. Tokens match docs/SPEC.md (Look and feel). */

:root {
  --bg-base: #070E1F;
  --bg-base-2: #0C1A36;
  --bg-elevated: #0F1E3D;
  --glass-panel: rgba(20, 40, 80, 0.55);
  --glass-solid: #132544;
  --glass-border: rgba(120, 170, 255, 0.18);
  --accent: #3B8BFF;
  --accent-glow: #5AA8FF;
  --text-primary: #E6EEFF;
  --text-muted: #8FA3C8;
  --success: #2FD18A;
  --warning: #FFB547;
  --danger: #FF5C7A;
  --info: #38C6F4;

  --radius: 10px;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font: 14px/1.5 var(--font-ui);
  color: var(--text-primary);
  background: radial-gradient(ellipse at 20% -10%, var(--bg-base-2), var(--bg-base) 60%) fixed, var(--bg-base);
}

a { color: var(--accent-glow); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0 0 8px; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

:focus-visible { outline: 2px solid var(--accent-glow); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(90, 168, 255, 0.4); }

/* Glass panels, with a solid fallback where backdrop-filter is missing or transparency is reduced. */
.glass {
  background: var(--glass-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(120, 170, 255, 0.12), 0 8px 24px rgba(0, 0, 0, 0.35);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: var(--glass-panel);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: var(--glass-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--glass-border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; color: var(--text-primary); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent-glow), var(--accent) 55%, #1C4FB8);
  box-shadow: 0 0 12px rgba(59, 139, 255, 0.6);
}
.brand-lg { font-size: 20px; margin-bottom: 20px; }
.topbar-search { flex: 1; max-width: 520px; }
.topbar-search input { width: 100%; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: 8px; color: var(--text-muted); border: 1px solid transparent;
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--glass-border); text-decoration: none; }
.admin-name { color: var(--text-muted); }
.inline-form { margin: 0; }

/* Main nav, in WHMCS order, with hover/focus dropdowns (no JavaScript needed) */
.mainnav {
  position: relative; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 6px 24px;
  background: rgba(15, 30, 61, 0.7);
  border-bottom: 1px solid var(--glass-border);
}
.navitem { position: relative; }
.navitem > a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text-muted); font-weight: 500; }
.navitem > a:hover { color: var(--text-primary); background: rgba(59, 139, 255, 0.1); text-decoration: none; }
.navitem > a.active { color: var(--text-primary); background: rgba(59, 139, 255, 0.18); box-shadow: inset 0 -2px 0 var(--accent); }
.mainnav .nav-setup { margin-left: auto; }
/* Menus open at once but stay open 0.4s after the pointer leaves, so a slightly off-course move doesn't close them. */
.submenu {
  position: absolute; top: 100%; left: 0; z-index: 1; min-width: 220px;
  padding: 6px; margin-top: 2px; background: var(--glass-solid);
  visibility: hidden; opacity: 0;
  transition: opacity 0.15s ease 0.4s, visibility 0s linear 0.55s;
}
/* Invisible bridge over the gap between the nav item and its menu. */
.submenu::before { content: ""; position: absolute; left: 0; right: 0; top: -6px; height: 6px; }
.nav-setup .submenu { left: auto; right: 0; }
.has-children:hover .submenu, .has-children:focus-within .submenu {
  visibility: visible; opacity: 1; z-index: 2;
  transition: opacity 0.1s ease 0s, visibility 0s linear 0s;
}
.submenu a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--text-primary); white-space: nowrap; }
.submenu a:hover { background: rgba(59, 139, 255, 0.18); text-decoration: none; }

.content { padding: 24px; max-width: 1400px; margin: 0 auto; }
.page-head { margin-bottom: 20px; }
.footer { padding: 16px 24px; color: var(--text-muted); font-size: 12px; text-align: center; }

/* Dashboard */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; color: var(--text-primary); }
.stat:hover { text-decoration: none; border-color: rgba(90, 168, 255, 0.45); }
.stat-value { font: 600 26px/1.2 var(--font-mono); }
.stat-label { color: var(--text-muted); }

.widget-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.widget { padding: 16px 20px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 8px 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--font-mono); }

.checklist { list-style: none; margin: 8px 0 0; padding: 0; }
.checklist li { display: grid; grid-template-columns: 12px auto 1fr; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--glass-border); }
.checklist li:first-child { border-top: 0; }
.checklist .dot { width: 8px; height: 8px; border-radius: 50%; }
.checklist .ok .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.checklist .fail .dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.check-detail { color: var(--text-muted); text-align: right; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-success { color: var(--success); background: rgba(47, 209, 138, 0.14); }
.badge-warning { color: var(--warning); background: rgba(255, 181, 71, 0.14); }
.badge-danger { color: var(--danger); background: rgba(255, 92, 122, 0.14); }

/* Forms and buttons */
input[type="text"], input[type="search"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], input[type="url"], input[type="color"], select, textarea {
  width: 100%; padding: 8px 12px;
  color: var(--text-primary); font: inherit;
  background: rgba(7, 14, 31, 0.6);
  border: 1px solid var(--glass-border); border-radius: 8px;
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(90, 168, 255, 0.35); }
label { display: block; margin: 12px 0 6px; color: var(--text-muted); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font: 600 14px var(--font-ui); cursor: pointer; color: var(--text-primary);
}
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 20px; }
.btn-primary { background: var(--accent); box-shadow: 0 0 16px rgba(59, 139, 255, 0.35); }
.btn-primary:hover { background: var(--accent-glow); }
.btn-ghost { background: transparent; border-color: var(--glass-border); color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--accent); }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 8px; }
.alert-success { color: #C9F7E2; background: rgba(47, 209, 138, 0.14); border: 1px solid rgba(47, 209, 138, 0.4); }
.alert-info { color: #CDEFFC; background: rgba(56, 198, 244, 0.12); border: 1px solid rgba(56, 198, 244, 0.4); }
.alert-warning { color: #FFE7C2; background: rgba(255, 181, 71, 0.12); border: 1px solid rgba(255, 181, 71, 0.4); }
.alert-danger { color: #FFD0D9; background: rgba(255, 92, 122, 0.14); border: 1px solid rgba(255, 92, 122, 0.4); }

/* Login */
.bm-login { display: grid; place-items: center; padding: 24px; }
.login-wrap { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; }
.login-card { width: 100%; padding: 28px; }
.login-card h1 { font-size: 18px; margin-bottom: 12px; }

/* Pages, panels, toolbars */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { padding: 16px 20px; margin-bottom: 16px; }
.narrow { max-width: 560px; margin: 0 auto; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar .grow { flex: 1; }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.btn-danger { background: rgba(255, 92, 122, 0.16); color: var(--danger); border-color: rgba(255, 92, 122, 0.45); }
.btn-danger:hover { background: rgba(255, 92, 122, 0.3); color: #FFD0D9; }
.btn-success { background: rgba(47, 209, 138, 0.16); color: var(--success); border-color: rgba(47, 209, 138, 0.45); }
.btn-success:hover { background: rgba(47, 209, 138, 0.3); }
a.btn:hover { text-decoration: none; }
code { font-family: var(--font-mono); font-size: 12px; padding: 1px 5px; border-radius: 4px; background: rgba(7, 14, 31, 0.6); }
.mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.badge-info { color: var(--info); background: rgba(56, 198, 244, 0.14); }
.badge-muted { color: var(--text-muted); background: rgba(143, 163, 200, 0.14); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--glass-border); vertical-align: middle; }
table.data th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
table.data tbody tr:hover { background: rgba(59, 139, 255, 0.06); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--font-mono); }
table.data .empty { color: var(--text-muted); text-align: center; padding: 24px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; color: var(--text-primary); font-weight: 400; }
.check input { width: auto; margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
fieldset { border: 1px solid var(--glass-border); border-radius: 8px; padding: 8px 16px 12px; margin: 12px 0; }
legend { color: var(--text-muted); padding: 0 6px; font-weight: 600; }
.help { color: var(--text-muted); font-size: 12px; margin: 4px 0 0; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--glass-border); }
.tabs a { padding: 8px 14px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text-primary); text-decoration: none; }
.tabs a.active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* Pager */
.pager { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 12px; }
.pager a, .pager span { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--glass-border); }
.pager .current { background: rgba(59, 139, 255, 0.18); color: var(--text-primary); }

.qr { background: #fff; padding: 12px; border-radius: 8px; width: 200px; height: 200px; }

@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .topbar-search { order: 3; max-width: none; flex-basis: 100%; }
  .mainnav { padding: 6px 16px; overflow-x: auto; flex-wrap: nowrap; }
  .mainnav .nav-setup { margin-left: 0; }
  .submenu { position: static; display: none; transition: none; }
  .has-children:hover .submenu, .has-children:focus-within .submenu { display: block; }
  .content { padding: 16px; }
}

.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.prewrap { white-space: pre-wrap; }
table.pricing input[type="number"] { min-width: 90px; }
table.pricing .check { margin: 0; }
h2 .grow { flex: 1; }
.linklist { list-style: none; margin: 0; padding: 0; }
.linklist a { display: block; padding: 7px 10px; border-radius: 6px; }
.linklist a.active, .linklist a:hover { background: rgba(59, 139, 255, 0.14); text-decoration: none; }
.mt { margin-top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.totals { max-width: 360px; margin-left: auto; }
.logdata { margin: 0; max-height: 160px; overflow: auto; white-space: pre-wrap; font: 11px/1.4 var(--font-mono); color: var(--text-muted); }
.sortable { list-style: none; margin: 0; padding: 0; }
.sortable-item { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; margin: 6px 0; border: 1px solid var(--glass-border); border-radius: 8px; background: rgba(7, 14, 31, 0.4); }
.sortable-item .grow { flex: 1; min-width: 140px; }
.sortable-item input.pos { width: 70px; }
.sortable-item input[type="text"], .sortable-item select { width: auto; }
.sortable-item.dragging { opacity: 0.5; border-color: var(--accent); }
.drag-handle { cursor: grab; color: var(--text-muted); font-size: 18px; user-select: none; }
.reply-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.reply-head .small { margin-left: auto; }
.reply.staff { border-left: 3px solid var(--accent); }
.reply.note { border-left: 3px solid var(--warning); background: rgba(255, 181, 71, 0.06); }
.reply-body p { margin: 0 0 8px; }
.reply-body pre { overflow-x: auto; padding: 10px; border-radius: 6px; background: rgba(7, 14, 31, 0.6); }
input[type="file"] { color: var(--text-muted); }

/* Report bars */
.chart { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 180px 1fr 110px; gap: 10px; align-items: center; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.bar-track { height: 14px; border-radius: 7px; background: rgba(7, 14, 31, 0.6); overflow: hidden; }
.bar { display: block; height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--accent), var(--accent-glow)); }
.bar-value { text-align: right; }
.bar-0 { width: 0%; }
.bar-1 { width: 1%; }
.bar-2 { width: 2%; }
.bar-3 { width: 3%; }
.bar-4 { width: 4%; }
.bar-5 { width: 5%; }
.bar-6 { width: 6%; }
.bar-7 { width: 7%; }
.bar-8 { width: 8%; }
.bar-9 { width: 9%; }
.bar-10 { width: 10%; }
.bar-11 { width: 11%; }
.bar-12 { width: 12%; }
.bar-13 { width: 13%; }
.bar-14 { width: 14%; }
.bar-15 { width: 15%; }
.bar-16 { width: 16%; }
.bar-17 { width: 17%; }
.bar-18 { width: 18%; }
.bar-19 { width: 19%; }
.bar-20 { width: 20%; }
.bar-21 { width: 21%; }
.bar-22 { width: 22%; }
.bar-23 { width: 23%; }
.bar-24 { width: 24%; }
.bar-25 { width: 25%; }
.bar-26 { width: 26%; }
.bar-27 { width: 27%; }
.bar-28 { width: 28%; }
.bar-29 { width: 29%; }
.bar-30 { width: 30%; }
.bar-31 { width: 31%; }
.bar-32 { width: 32%; }
.bar-33 { width: 33%; }
.bar-34 { width: 34%; }
.bar-35 { width: 35%; }
.bar-36 { width: 36%; }
.bar-37 { width: 37%; }
.bar-38 { width: 38%; }
.bar-39 { width: 39%; }
.bar-40 { width: 40%; }
.bar-41 { width: 41%; }
.bar-42 { width: 42%; }
.bar-43 { width: 43%; }
.bar-44 { width: 44%; }
.bar-45 { width: 45%; }
.bar-46 { width: 46%; }
.bar-47 { width: 47%; }
.bar-48 { width: 48%; }
.bar-49 { width: 49%; }
.bar-50 { width: 50%; }
.bar-51 { width: 51%; }
.bar-52 { width: 52%; }
.bar-53 { width: 53%; }
.bar-54 { width: 54%; }
.bar-55 { width: 55%; }
.bar-56 { width: 56%; }
.bar-57 { width: 57%; }
.bar-58 { width: 58%; }
.bar-59 { width: 59%; }
.bar-60 { width: 60%; }
.bar-61 { width: 61%; }
.bar-62 { width: 62%; }
.bar-63 { width: 63%; }
.bar-64 { width: 64%; }
.bar-65 { width: 65%; }
.bar-66 { width: 66%; }
.bar-67 { width: 67%; }
.bar-68 { width: 68%; }
.bar-69 { width: 69%; }
.bar-70 { width: 70%; }
.bar-71 { width: 71%; }
.bar-72 { width: 72%; }
.bar-73 { width: 73%; }
.bar-74 { width: 74%; }
.bar-75 { width: 75%; }
.bar-76 { width: 76%; }
.bar-77 { width: 77%; }
.bar-78 { width: 78%; }
.bar-79 { width: 79%; }
.bar-80 { width: 80%; }
.bar-81 { width: 81%; }
.bar-82 { width: 82%; }
.bar-83 { width: 83%; }
.bar-84 { width: 84%; }
.bar-85 { width: 85%; }
.bar-86 { width: 86%; }
.bar-87 { width: 87%; }
.bar-88 { width: 88%; }
.bar-89 { width: 89%; }
.bar-90 { width: 90%; }
.bar-91 { width: 91%; }
.bar-92 { width: 92%; }
.bar-93 { width: 93%; }
.bar-94 { width: 94%; }
.bar-95 { width: 95%; }
.bar-96 { width: 96%; }
.bar-97 { width: 97%; }
.bar-98 { width: 98%; }
.bar-99 { width: 99%; }
.bar-100 { width: 100%; }
