/* ICONEXT MDM — commercial static UI (PHASE 20F). Zero dependency, no external font/CDN. */
:root {
  --navy-0: #0b1220; --navy-1: #0f172a; --navy-2: #14213d;
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --blue: #2563eb; --cyan: #06b6d4; --green: #16a34a; --amber: #d97706; --red: #dc2626;
  --card: #ffffff; --glass: rgba(255,255,255,.06); --glass-line: rgba(255,255,255,.14);
  --radius: 16px; --shadow: 0 20px 60px rgba(2,6,23,.45);
}
* { box-sizing: border-box; }
/* PHASE 24A-FIX: make the `hidden` attribute authoritative. `.login-wrap { display:flex }` otherwise
   overrides the UA `[hidden]{display:none}` (equal specificity, author wins), so the login view never
   hides after a successful login. `!important` restores correct view toggling for BOTH login + dashboard. */
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--navy-1);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
code { background: rgba(148,163,184,.18); padding: 1px 6px; border-radius: 5px; font-size: .9em; }

/* ============ LOGIN ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 20px;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(37,99,235,.35), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(6,182,212,.30), transparent 55%),
    linear-gradient(135deg, var(--navy-0), var(--navy-2));
}
.login-grid {
  width: 100%; max-width: 1060px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 44px; align-items: center;
}
.hero { color: #e2e8f0; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.logo { display: inline-flex; filter: drop-shadow(0 6px 18px rgba(6,182,212,.35)); }
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: .3px; color: #fff; }
.brand-name span { color: #67e8f9; }
.brand-sub { font-size: 12.5px; color: #94a3b8; margin-top: 2px; }
.hero-title { font-size: 32px; line-height: 1.25; font-weight: 800; color: #fff; margin: 0 0 22px; letter-spacing: -.4px; }
.benefits { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 12px; }
.benefits li { display: flex; align-items: center; gap: 12px; color: #cbd5e1; font-size: 15px; }
.benefits .ic {
  flex: 0 0 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-style: normal;
  font-size: 13px; font-weight: 800; color: #061225; background: linear-gradient(135deg, #22d3ee, #38bdf8);
}
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: #cbd5e1;
  padding: 7px 12px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(6px);
}
.chip i { font-style: normal; }

.card-col { display: flex; flex-direction: column; align-items: stretch; }
.login-card {
  background: var(--card); border-radius: var(--radius); padding: 30px 30px 26px; box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.6);
}
.login-card h2 { margin: 0 0 2px; font-size: 22px; }
.login-card .muted { margin: 0 0 18px; }
form { display: flex; flex-direction: column; }
label { font-weight: 600; font-size: 13px; margin: 12px 0 6px; }
input {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
  background: #f8fafc; transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.18); background: #fff; }
.pw { position: relative; }
.pw input { padding-right: 62px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent;
  color: var(--blue); font-weight: 600; font-size: 13px; padding: 6px 8px; border-radius: 8px;
}
.pw-toggle:hover { background: rgba(37,99,235,.10); }
button.primary {
  margin-top: 20px; padding: 12px 16px; border: 0; border-radius: 10px; color: #fff; font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, var(--blue), var(--cyan)); display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 10px 24px rgba(37,99,235,.35);
}
button.primary:hover { filter: brightness(1.05); }
button.primary:disabled { opacity: .7; cursor: default; filter: none; }
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--red); background: #fef2f2; border: 1px solid #fecaca; padding: 9px 11px; border-radius: 10px; margin: 12px 0 0; font-size: 14px; }
.note { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; text-align: center; }
.footer { color: #94a3b8; font-size: 12px; text-align: center; margin: 16px 0 0; }
.footer.left { text-align: left; color: var(--muted); }
.muted { color: var(--muted); }

/* ============ AUTH PANELS (PHASE 27A) ============ */
textarea {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
  background: #f8fafc; transition: border-color .15s, box-shadow .15s; font-family: inherit; resize: vertical; min-height: 56px;
}
textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.18); background: #fff; }
.auth-links { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.linkbtn { border: 0; background: transparent; color: var(--blue); font-weight: 600; cursor: pointer; font-size: 13.5px; padding: 4px 6px; border-radius: 8px; }
.linkbtn:hover { background: rgba(37,99,235,.10); }
.dot { color: var(--muted); }
.req { color: var(--red); }
.otp-input { letter-spacing: .4em; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.qr-box { display: flex; justify-content: center; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin: 8px 0 10px; min-height: 120px; align-items: center; color: var(--muted); font-size: 13px; }
.qr-box svg { width: 300px; max-width: 100%; height: auto; display: block; image-rendering: pixelated; shape-rendering: crispEdges; }
.secret-details { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.secret-details summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; background: #f1f5f9; padding: 10px; border-radius: 8px; margin-top: 8px; font-size: 14px; letter-spacing: .05em; }
.ok-msg { color: var(--green); background: #f0fdf4; border: 1px solid #bbf7d0; padding: 10px 12px; border-radius: 10px; margin: 12px 0 0; font-size: 14px; }

/* ============ THIẾT BỊ MODULE (PHASE 27B-1, cloned patterns) ============ */
.dev-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dev-toolbar label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0 0 5px; display: block; }
.dev-toolbar input, .dev-toolbar select { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; background: #f8fafc; }
.dev-toolbar input:focus, .dev-toolbar select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); background: #fff; }
.dev-search { flex: 1 1 240px; }
.dev-filter { flex: 0 0 auto; min-width: 130px; }
.dev-filter-end { margin-left: auto; }
.dev-filter-end button { width: 100%; }

.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; padding: 16px 18px; }
.dcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.dcard:hover { box-shadow: 0 10px 28px rgba(2,6,23,.12); transform: translateY(-1px); }
.dcard-head { background: linear-gradient(135deg, var(--navy-1), var(--navy-2)); color: #fff; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dcard-id h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .02em; word-break: break-all; }
.dcard-id p { margin: 2px 0 0; font-size: 12px; color: #cbd5e1; }
.ios-badge { background: var(--blue); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.dcard-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.dcard-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.muted { background: #f1f5f9; color: #64748b; }
.badge.info { background: #dbeafe; color: #1d4ed8; }
.dcard-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12.5px; }
.dcard-meta > div { display: flex; flex-direction: column; }
.dcard-meta span { color: var(--muted); font-size: 11px; }
.dcard-meta b { color: var(--ink); font-weight: 600; word-break: break-all; }
.dcard-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 2px; }
.act { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 7px 4px; border: 0; border-radius: 7px; font-size: 11.5px; font-weight: 600; cursor: pointer; transition: filter .12s; }
.act:disabled { background: #f1f5f9 !important; color: #94a3b8 !important; cursor: not-allowed; }
.act:not(:disabled):hover { filter: brightness(.96); }
.a-orange { background: #ffedd5; color: #c2410c; }
.a-blue { background: #dbeafe; color: #1d4ed8; }
.a-amber { background: #fef9c3; color: #a16207; }
.a-green { background: #dcfce7; color: #15803d; }
.a-purple { background: #f3e8ff; color: #7e22ce; }
.a-cyan { background: #cffafe; color: #0e7490; }
.a-indigo { background: #e0e7ff; color: #4338ca; }
.act-del { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border: 0; border-radius: 8px; font-size: 12.5px; font-weight: 600; background: #fee2e2; color: #b91c1c; cursor: pointer; margin-top: 2px; }
.act-del:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }

.dev-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); }
.dev-pager #devCount { font-size: 13px; }
.dev-pager #loadMoreBtn[hidden] { display: none !important; }
button.primary.sm { margin-top: 0; padding: 9px 16px; font-size: 13.5px; box-shadow: 0 6px 16px rgba(37,99,235,.28); }

/* device detail modal (read-only) */
.modal-overlay { position: fixed; inset: 0; background: rgba(2,6,23,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-card { background: #fff; border-radius: 14px; width: 100%; max-width: 460px; max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { border: 0; background: transparent; font-size: 18px; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.modal-close:hover { background: #f1f5f9; }
.modal-body { padding: 16px 18px; }
.modal-badges { display: flex; gap: 6px; margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); font-weight: 600; word-break: break-all; }
.kv dd.mono { font-family: ui-monospace, Menlo, monospace; font-weight: 500; }
.xs { font-size: 12px; }
/* honest-parity (PHASE 27B-3) */
.dcard-note { font-size: 11px; color: #94a3b8; background: #f8fafc; border: 1px dashed var(--line); border-radius: 8px; padding: 6px 8px; }
.dcard-legacy { font-size: 11.5px; color: #475569; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 8px; padding: 6px 8px; }
.dcard-legacy span { color: #0369a1; font-weight: 600; }
/* command-gate dry-run (PHASE 27B-5): toast + read-only check history */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); max-width: 92%; padding: 12px 18px; border-radius: 12px; background: #0f172a; color: #fff; font-size: 14px; box-shadow: 0 12px 32px rgba(2,6,23,.35); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.info { background: #075985; }
.toast.warn { background: #b45309; }
.toast.err { background: #b91c1c; }
.hist-wrap { margin-top: 12px; }
.cmd-history { margin-top: 10px; }
.hist-note { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.hist-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.hist-row b.hok { color: var(--green); font-weight: 600; }
.hist-row b.hdeny { color: var(--amber); font-weight: 600; }
.ios-badge.muted { background: #64748b; }
.kv-h { margin: 14px 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.modal-body .kv-h:first-of-type { margin-top: 0; }
.kv dd.unsync { color: #94a3b8; font-weight: 500; font-style: italic; }
.modal-foot { padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.modal-foot .muted { margin: 0; }

@media (max-width: 560px) {
  .dev-toolbar { flex-direction: column; align-items: stretch; }
  .dev-filter, .dev-filter-end { min-width: 0; margin-left: 0; }
  .dev-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 108px 1fr; }
}

/* ============ AUTHENTICATED SHELL ============ */
.app-shell { min-height: 100vh; background: #f1f5f9; }
.topbar {
  height: 62px; background: linear-gradient(135deg, var(--navy-1), var(--navy-2)); color: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px; position: sticky; top: 0; z-index: 5;
  box-shadow: 0 2px 12px rgba(2,6,23,.25);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.topbar-brand .accent { color: #67e8f9; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.whoami { color: #cbd5e1; font-size: 13.5px; }
button.ghost {
  background: rgba(255,255,255,.10); color: #fff; border: 1px solid rgba(255,255,255,.22); border-radius: 9px; padding: 7px 13px; font-size: 13.5px;
}
button.ghost:hover { background: rgba(255,255,255,.18); }
.content { max-width: 1080px; margin: 0 auto; padding: 26px 22px 40px; }
.page-head h1 { margin: 0 0 3px; font-size: 22px; }
.page-head .muted { margin: 0 0 20px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
  display: flex; align-items: center; gap: 14px; box-shadow: 0 1px 3px rgba(2,6,23,.05);
}
.stat-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; }
.stat-ic.blue { background: #dbeafe; } .stat-ic.green { background: #dcfce7; }
.stat-ic.amber { background: #fef3c7; } .stat-ic.cyan { background: #cffafe; }
.stat-num { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-num.sm { font-size: 16px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 3px rgba(2,6,23,.05); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; }
button.ghost.sm { background: #f1f5f9; color: var(--ink); border: 1px solid var(--line); padding: 6px 11px; font-size: 13px; }
button.ghost.sm:hover { background: #e2e8f0; }
.pad { padding: 18px; }
.empty { padding: 46px 20px; text-align: center; }
.empty-ic { font-size: 40px; margin-bottom: 12px; opacity: .85; }
.empty-title { font-size: 16px; font-weight: 700; }
.empty-sub { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }

/* ============ RESPONSIVE ============ */
@media (max-width: 880px) {
  .login-grid { grid-template-columns: 1fr; gap: 26px; max-width: 460px; }
  .hero { text-align: left; }
  .hero-title { font-size: 26px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .login-wrap { padding: 20px 14px; }
  .login-card { padding: 24px 20px; }
  .hero-title { font-size: 23px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .content { padding: 18px 14px 32px; }
  .whoami { display: none; }
}
