/* ─── CORE MDM Console — Light theme (mirrors the Android app light mode) ───
   App light palette: #F3F6FB bg · #FFFFFF cards · #1764B5 blue · #14734F teal
   All HTML IDs and JS hooks are left intact — only visual properties change.
   ────────────────────────────────────────────────────────────────────────── */

:root {
  --bg:          #EEF4FB;
  --text:        #0D1B2A;
  --muted:       rgba(13,27,42,.52);
  --glass:       rgba(255,255,255,.9);
  --glass-hi:    rgba(255,255,255,.98);
  --line:        rgba(13,27,42,.1);
  --accent:      #1764B5;
  --accent2:     #14734F;
  --ok:          #15803D;
  --bad:         #C4364F;
  --warn:        #A16207;
  --cyan:        #1764B5;
  --green:       #15803D;
  --red:         #C4364F;
  --yellow:      #A16207;
  --textSec:     #4E6A88;
  --textDim:     rgba(13,27,42,.35);
  --field:       rgba(255,255,255,.9);
  --panel:       #FFFFFF;
  --card:        #FFFFFF;
  --grad-btn:    linear-gradient(135deg,#1764B5,#14734F);
  --grad-btn-hi: linear-gradient(135deg,#2278CC,#1A9065);
}

/* ─── Enroll modal ─── */
#enroll-modal { display: none; position: fixed; inset: 0; z-index: 210; align-items: center; justify-content: center; padding: 24px; }
#enroll-modal .modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }

/* ─── Background ─── */
html { background: var(--bg); color: var(--text); }
body { background: var(--bg); color: var(--text); }
.bg {
  background: radial-gradient(1200px 800px at 50% -10%,#C8DFF5 0%,transparent 60%),var(--bg);
}
.o1 { background: #BDD5EF; opacity:.6; }
.o2 { background: #A8D5BC; opacity:.5; }
.o3 { background: #1764B5; opacity:.06; }

/* ─── Global text ─── */
a { color: #1764B5; }
.login-legal a, .login-aside a, .link-btn { color: #1764B5; }

/* ─── Gradient text ─── */
.grad {
  background: linear-gradient(120deg,#1764B5,#14734F);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ─── Nav active pill ─── */
.console-page .links a.active {
  box-shadow: inset 0 0 0 1px rgba(23,100,181,.5);
}

/* ─── Override glass card surfaces → white cards with shadow ─── */
.login-card, #reset-panel, .stat-card, .device-card,
.inv-form-card, .admin-table-wrap, .admin-tab-bar, .danger-card {
  background: #FFFFFF;
  border: 1px solid rgba(13,27,42,.1);
  box-shadow: 0 2px 14px rgba(13,27,42,.07);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* ─── Buttons ─── */
#btn-login,
.btn-pri,
.dc-btn-manage,
.btn-lock-dns,
.btn-add-pkg,
.btn-send-msg,
.btn-register,
.btn-confirm,
.at-btn-manage,
.tab-btn.active,
.admin-tab-btn.active,
.seg button.on {
  background: var(--grad-btn);
  box-shadow: 0 8px 22px -8px rgba(23,100,181,.35);
  color: #fff;
}
#btn-login:hover, .btn-pri:hover, .dc-btn-manage:hover,
.btn-lock-dns:hover, .btn-add-pkg:hover, .btn-send-msg:hover,
.btn-register:hover, .btn-confirm:hover {
  background: var(--grad-btn-hi);
}

/* Secondary / sign-out buttons on light background */
.btn-sec,
#btn-signout,
#btn-signout-admin {
  background: rgba(13,27,42,.05);
  border-color: rgba(13,27,42,.12);
  color: var(--text);
}
.btn-sec:hover,
#btn-signout:hover,
#btn-signout-admin:hover {
  background: rgba(13,27,42,.09);
}

/* ─── Super admin button ─── */
#btn-admin {
  background: rgba(20,115,79,.1);
  border-color: rgba(20,115,79,.3);
  color: #14734F;
}
#btn-admin:hover { background: rgba(20,115,79,.16); }

/* ─── Stats strip ─── */
.stat-total .stat-val {
  background: linear-gradient(120deg,#1764B5,#14734F);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-online .stat-val  { color: #15803D; }
.stat-offline .stat-val { color: var(--muted); }

/* ─── Search bar ─── */
#search {
  background: #fff;
  border-color: rgba(13,27,42,.15);
  color: var(--text);
}
#search::placeholder { color: var(--textDim); }
#search:focus,
.modal-search input:focus,
.dns-input:focus,
.kiosk-add-input:focus,
.msg-form input:focus,
.msg-form textarea:focus,
.geo-row input:focus,
.geo-select:focus,
.time-in:focus,
.field input:focus,
.inv-field input:focus,
.kiosk-search:focus {
  border-color: rgba(23,100,181,.55);
  box-shadow: 0 0 0 3px rgba(23,100,181,.14);
}

/* ─── Device cards ─── */
.device-card {
  border-radius: 20px;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.device-card:hover {
  border-color: rgba(23,100,181,.35);
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(13,27,42,.12);
}
.device-card.alarming {
  border-color: rgba(196,54,79,.4);
  box-shadow: 0 0 0 1px rgba(196,54,79,.2),0 12px 36px rgba(196,54,79,.12);
}
.dc-btn-manage { box-shadow: 0 8px 22px -8px rgba(23,100,181,.35); }

/* ─── Status badges ─── */
.badge-online       { background: rgba(21,128,61,.1);  color: #15803D; }
.badge-offline      { background: rgba(13,27,42,.07);  color: var(--muted); }
.badge-asleep       { background: rgba(23,100,181,.1); color: #1764B5; }
.badge-offline-warn { background: rgba(161,98,7,.1);   color: #A16207; }
.badge-version      { background: rgba(23,100,181,.08); color: rgba(23,100,181,.65); }
.badge-alarm        { background: rgba(196,54,79,.1);  color: #C4364F; }
.badge-pending      { background: rgba(20,115,79,.12); color: #14734F; }
.badge-chat         { background: rgba(21,128,61,.12); color: #15803D; }

/* ─── Info chips on device cards ─── */
.chip { background: rgba(23,100,181,.08); color: #1764B5; border-color: rgba(23,100,181,.2); }

/* ─── Empty state ─── */
#empty-state { border-color: rgba(13,27,42,.15); }
#empty-state strong { color: var(--text); }
#empty-state a { color: #1764B5; border-bottom-color: rgba(23,100,181,.3); }

/* ─── Modal ─── */
.modal-panel {
  max-width: 980px;
  background: #FFFFFF;
  border-color: rgba(13,27,42,.1);
  box-shadow: 0 24px 80px rgba(13,27,42,.18);
}
@media (min-width: 720px) {
  #dev-modal { padding: 20px; }
  .modal-panel { max-height: 88vh; border-radius: 26px; }
}
#modal-device-name { font-size: 1.25rem; color: var(--text); }
#modal-device-sub  { color: var(--muted); }
.tab-bar { border-bottom-color: rgba(13,27,42,.1); }
.tab-btn {
  background: rgba(13,27,42,.05);
  color: var(--muted);
  padding: 9px 16px;
  font-size: .88rem;
}
.tab-btn:hover { color: var(--text); background: rgba(13,27,42,.09); }
.tab-btn.active {
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(23,100,181,.35);
}
#btn-close-modal {
  background: rgba(13,27,42,.05);
  border-color: rgba(13,27,42,.12);
  color: var(--muted);
}
#btn-close-modal:hover { background: rgba(13,27,42,.09); color: var(--text); }

/* ─── Rename button ─── */
.btn-rename { color: #1764B5; background: rgba(23,100,181,.08); border-color: rgba(23,100,181,.22); }
.btn-rename:hover { background: rgba(23,100,181,.14); }

/* ─── Sidebar navigation ─── */
.group-sidebar {
  width: 220px;
  background: rgba(13,27,42,.03);
  border-right-color: rgba(13,27,42,.1);
}
.sidebar-item { font-size: .9rem; padding: 11px 14px; color: var(--text); }
.sidebar-item:hover { background: rgba(23,100,181,.07); color: var(--text); }
.sidebar-item.active { background: rgba(23,100,181,.12); color: #1764B5; }
.sidebar-num { background: rgba(23,100,181,.12); color: #1764B5; }
.sidebar-item.active .sidebar-num { background: rgba(23,100,181,.22); }
.sidebar-icon { font-size: 1rem; }
.sidebar-item.danger-item { color: #C4364F; }

/* ─── Section headings ─── */
.net-section h3 { color: #1764B5; }
.kiosk-section-hdr { color: #1764B5; }
.pending-cmds h3 { color: #1764B5; }
.search-group { color: #1764B5; }

/* ─── Toggles — on light bg the unchecked track needs to be visible ─── */
.toggle-track { background: rgba(13,27,42,.18); }
.toggle input:checked + .toggle-track { background: var(--grad-btn); }
.toggle input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px rgba(23,100,181,.25); }

/* ─── Policy rows ─── */
.policy-row { border-bottom-color: rgba(13,27,42,.07); }
.policy-label { color: var(--text); font-size: .9rem; font-weight: 500; }
.policy-sub { color: var(--muted); }

/* ─── Command buttons ─── */
.cmd-lock      { background: rgba(23,100,181,.1);  color: #1764B5; border-color: rgba(23,100,181,.3); }
.cmd-reboot    { background: rgba(21,128,61,.09);  color: #15803D; border-color: rgba(21,128,61,.28); }
.cmd-alarm-off { background: rgba(161,98,7,.09);   color: #A16207; border-color: rgba(161,98,7,.28); }
.cmd-alarm-on  { background: #A16207; color: #fff; }
.cmd-lockdown  { background: rgba(196,54,79,.08);  color: #C4364F; border-color: rgba(196,54,79,.28); }
.ld-sub        { color: rgba(196,54,79,.65); }

/* ─── Pending command ─── */
.cmd-pending   { border-color: rgba(20,115,79,.45); }
.cmd-pending small,
.cmd-lockdown.cmd-pending .ld-sub { color: #14734F; }
.cmd-pending .spin {
  border-color: rgba(20,115,79,.25);
  border-top-color: #14734F;
}

/* ─── Chat ─── */
.chat-mine .chat-bubble { background: var(--grad-btn); }
.chat-tag { color: #1764B5; }

/* ─── Domain chips ─── */
.domain-chip button:hover { color: var(--red); }

/* ─── Super admin ─── */
.sa-badge { background: var(--grad-btn); color: #fff; }
.admin-tab-btn.active { box-shadow: 0 6px 18px -6px rgba(23,100,181,.35); }
.admin-tab-btn:hover:not(.active) { background: rgba(23,100,181,.07); color: var(--text); }
.admin-table th { color: #1764B5; }
.at-btn-manage { background: rgba(20,115,79,.1);  color: #14734F; border-color: rgba(20,115,79,.28); }
.at-btn-lock   { background: rgba(23,100,181,.1); color: #1764B5; border-color: rgba(23,100,181,.28); }
.audit-REBOOT, .audit-POLICY, .audit-LOGIN { background: rgba(20,115,79,.1); color: #14734F; }

/* ─── Org / managed badges ─── */
.badge-org { background: rgba(23,100,181,.1); color: #1E5FA0; }
.policy-org { color: #1E5FA0; }
.managed-banner { background: rgba(23,100,181,.07); border-color: rgba(23,100,181,.25); color: #1E5FA0; }

/* ─── Toast ─── */
#toast { background: #FFFFFF; border-color: rgba(13,27,42,.15); color: var(--text); box-shadow: 0 8px 32px rgba(13,27,42,.12); }
#toast.ok  { border-color: rgba(21,128,61,.5); }
#toast.bad { border-color: rgba(196,54,79,.5); }

/* ─── Org.html list tiles ─── */
.org-tile:hover { border-color: rgba(23,100,181,.4); }
.seg button.on  { background: var(--grad-btn); color: #fff; }

/* ─── Location map ─── */
#loc-map { border-color: rgba(13,27,42,.15); }

/* ─── Inventory form ─── */
.inv-form-card.inv-info {
  background: linear-gradient(145deg,rgba(23,100,181,.07),rgba(20,115,79,.05));
  border-color: rgba(23,100,181,.2);
}
.btn-copy { background: var(--ok); color: #fff; }
.token-box { background: rgba(21,128,61,.06); border-color: rgba(21,128,61,.3); }

/* ─── Wider layout on large screens ─── */
main.wide { max-width: 1360px; }

/* ─── Align stat cards better on small layouts ─── */
@media (max-width: 900px) {
  #stats-strip, .admin-stats { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 600px) {
  #stats-strip, .admin-stats { grid-template-columns: 1fr 1fr; }
}

/* ─── Scrollbars ─── */
.group-sidebar::-webkit-scrollbar-thumb { background: rgba(23,100,181,.18); }
.tab-body::-webkit-scrollbar-thumb      { background: rgba(23,100,181,.13); }

/* ─── Usage bar ─── */
.usage-bar { background: var(--grad-btn); }

/* ─── Status indicators ─── */
.comp-dot.ok   { background: #15803D; box-shadow: 0 0 6px rgba(21,128,61,.5); }
.comp-dot.warn { background: #A16207; box-shadow: 0 0 6px rgba(161,98,7,.5); }
.comp-dot.bad  { background: #C4364F; box-shadow: 0 0 6px rgba(196,54,79,.5); }

/* ─── Kiosk bar buttons ─── */
.kiosk-bar-btn:hover { border-color: rgba(23,100,181,.4); color: var(--text); }
.kiosk-bar-btn.active { border-color: rgba(23,100,181,.5); color: #1764B5; background: rgba(23,100,181,.08); }

/* ─── Filter groups card ─── */
.btn-hide.on    { color: #A16207; border-color: rgba(161,98,7,.4);  background: rgba(161,98,7,.08); }
.btn-disable.on { color: #C4364F; border-color: rgba(196,54,79,.4); background: rgba(196,54,79,.08); }

/* ─── Time / schedule labels ─── */
.time-start { color: #15803D; }
.time-end   { color: #C4364F; }
.geo-on     { color: #15803D; }

/* ─── Turnstile / consent widget ─── */
.consent:has(.consent-box:checked) {
  border-color: rgba(23,100,181,.5);
  background: rgba(23,100,181,.06);
}
.consent .consent-box { accent-color: #1764B5; }

/* ══ STRUCTURAL IMPROVEMENTS — card sections, sidebar descriptions ══════════ */

/* ─── net-section → app-style card ─── */
body:not(.device-directory) .net-section {
  background: #FFFFFF;
  border: 1px solid rgba(13,27,42,.1);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 14px !important;
  padding: 0 !important;
  box-shadow: 0 1px 6px rgba(13,27,42,.06);
}
body:not(.device-directory) .net-section > h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 13px !important;
  margin: 0 !important;
  background: rgba(23,100,181,.05);
  border-bottom: 1px solid rgba(13,27,42,.08);
  color: #1764B5 !important;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
}
/* Rows and inner elements get horizontal padding */
.net-section .policy-row  { padding: 13px 16px !important; border-bottom: 1px solid rgba(13,27,42,.07); }
.net-section .comp-row    { padding: 11px 16px !important; border-bottom: 1px solid rgba(13,27,42,.07); }
.net-section .usage-row   { padding: 9px 16px !important;  border-bottom: 1px solid rgba(13,27,42,.07); }
.net-section .app-row     { padding: 10px 16px !important; border-bottom: 1px solid rgba(13,27,42,.07); }
.net-section .policy-row:last-child,
.net-section .comp-row:last-child,
.net-section .usage-row:last-child,
.net-section .app-row:last-child { border-bottom: none; }
.net-section > .apps-meta { padding: 12px 16px 4px; margin: 0 !important; }
.net-section .cmd-grid    { margin: 12px 16px 14px !important; }
.net-section > .dns-row   { padding: 12px 16px; }
.net-section .app-search  { margin: 8px 16px; display: block; width: calc(100% - 32px - 2px); }
.net-section #inst-list   { padding: 0 16px 8px; }
.net-section .frp-reveal  { margin: 12px 16px 14px; }
.net-section .kiosk-status-bar { padding: 10px 16px; }
.net-section .kiosk-add-row    { padding: 10px 16px; }
.net-section .kiosk-no-apps    { padding: 8px 16px 12px; }

/* ─── Sidebar: label + description ─── */
.sidebar-item { align-items: flex-start !important; }
.sidebar-label-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sidebar-desc { font-size: .67rem; color: rgba(13,27,42,.35); font-weight: 400; line-height: 1.2; }
.sidebar-item.active .sidebar-desc { color: rgba(23,100,181,.55); }
.sidebar-item:hover  .sidebar-desc { color: rgba(13,27,42,.5); }

/* ─── Policy rows — comfortable touch targets ─── */
.policy-row { min-height: 50px; align-items: center; }

/* ─── Command buttons — taller, icon-first ─── */
body:not(.device-directory) .cmd-btn {
  flex-direction: column !important;
  gap: 6px !important;
  padding: 18px 8px !important;
  min-height: 76px;
}

/* ─── Device cards — blue left-edge accent ─── */
.device-card { border-left: 3px solid rgba(23,100,181,.18) !important; }
.device-card:hover { border-left-color: rgba(23,100,181,.55) !important; }

/* ─── Narrow screens: hide descriptions to save space ─── */
@media (max-width: 540px) { .sidebar-desc { display: none; } }

/* Share the enterprise navigation on the signed-in device management page. */
.management-signed-in > :is(.bg, .nav),
.management-signed-in .console-main > .foot,
.management-signed-in :is(#btn-signout, #btn-signout-admin, #signed-in-as) {
  display: none;
}
body.console-page:not(.management-signed-in) .mobile-topbar {
  display: none;
}
body.management-signed-in {
  background: #f1f5f9;
}
.management-signed-in .console-main {
  width: auto;
  max-width: none;
  padding-top: 0;
}
.management-signed-in .console-main .main-content {
  max-width: none;
  padding: 0;
}
.management-signed-in .stat-card::before {
  content: none;
}
.management-signed-in #dev-modal {
  z-index: 120;
}

/* The device route uses the full page while the legacy console keeps its dialog. */
.device-workspace #s-app .console-bar,
.device-workspace #s-app :is(#stats-strip, #toolbar, #device-grid) {
  display: none;
}
.device-workspace .device-page-status {
  margin: 24px 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.device-workspace #dev-modal {
  position: static;
  width: 100%;
  padding: 24px 0 32px;
  z-index: auto;
  align-items: stretch;
}
.device-workspace #dev-modal .modal-panel {
  width: 100%;
  max-width: none;
  max-height: none;
  min-width: 0;
  border-radius: 16px;
  box-shadow: 0 1px 3px #0f172a12;
}
.device-workspace :is(.modal-body-wrap, .group-content, .group-sidebar) {
  overflow: visible;
}
.device-workspace .group-sidebar {
  flex-shrink: 0;
}
.device-workspace .group-content {
  padding: clamp(14px, 3vw, 32px);
}
.device-workspace .group-content .net-section {
  padding: clamp(14px, 2.5vw, 24px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.device-workspace #device-page-back {
  flex-shrink: 0;
}
@media (max-width: 719px) {
  .device-workspace #dev-modal { padding: 12px 0 24px; }
  .device-workspace .group-sidebar { overflow-x: auto; }
}

.domain-import {
  box-sizing: border-box;
  margin: auto;
  width: min(32rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: clamp(1.2rem, 4vw, 2rem);
  color: #162d40;
  background: #fff;
  border: 1px solid #cad9df;
  border-radius: .9rem;
  box-shadow: 0 20px 64px #12283d33;
  font: 1rem/1.5 Inter, system-ui, sans-serif;
}
.domain-import::backdrop { background: #10243288; }
.domain-import h2 { margin: 0; font: 700 1.4rem/1.25 Inter, system-ui, sans-serif; color: #162d40; }
.domain-import p { margin: .4rem 0 .9rem; color: #435970; font-size: .95rem; }
.domain-import label { display: block; margin-top: 1.25rem; font-weight: 650; }
.domain-import textarea { width: 100%; box-sizing: border-box; resize: vertical; padding: .75rem; border: 1px solid #93aab7; border-radius: .45rem; background: #fff; color: #162d40; font: 1rem/1.5 monospace; }
.import-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1rem; }
.import-actions button { padding: .55rem 1rem; color: #162d40; background: white; border: 1px solid #a6bbc4; border-radius: .45rem; font: inherit; }
.import-actions [type=submit] { background: #006b62; color: white; border-color: #006b62; }
.import-actions button:disabled { opacity: .55; cursor: default; }
.domain-import :focus-visible { outline: 3px solid #0879b7; outline-offset: 2px; }
.domain-import-trigger { margin-top: .65rem; text-decoration: underline; text-underline-offset: .2em; color: inherit; font: inherit; cursor: pointer; }
