/* ═══════════════════════════════════════════════════════════════
   PanelIQ — core.css  (mobile-first, v2)
   Breakpoints: 0–599 phone | 600–899 tablet | 900+ desktop
═══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body[data-theme="hacker"] { font-family: 'Courier New', Courier, monospace; }

/* ── App Shell ─────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.piq-body { display: flex; flex: 1; overflow: hidden; position: relative; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════ */
.piq-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 .85rem;
  height: 52px; flex-shrink: 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: 200;
}
@media (min-width: 900px) { .piq-header { padding: 0 1.25rem; height: 56px; } }

.piq-logo {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.05rem; font-weight: 900; letter-spacing: -.03em;
  user-select: none;
}
.piq-logo svg { width: 26px; height: 26px; flex-shrink: 0; }
.piq-logo span { color: var(--accent); }
@media (min-width: 900px) { .piq-logo { font-size: 1.1rem; } .piq-logo svg { width: 28px; height: 28px; } }

.piq-header-left  { display: flex; align-items: center; gap: .5rem; }
.piq-header-right { display: flex; align-items: center; gap: .4rem; }
@media (min-width: 900px) { .piq-header-right { gap: .75rem; } }

/* Hamburger — phone/tablet only */
.piq-hamburger {
  display: flex; flex-direction: column; justify-content: center;
  gap: 4px; width: 36px; height: 36px; padding: 6px;
  background: none; border: none; cursor: pointer; border-radius: 8px;
  flex-shrink: 0;
}
.piq-hamburger span {
  display: block; height: 2px; background: var(--text);
  border-radius: 2px; transition: transform .22s ease, opacity .22s ease;
}
.piq-hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.piq-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.piq-hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
@media (min-width: 900px) { .piq-hamburger { display: none; } }

/* Theme dots — hidden on phone */
.theme-switcher { display: none; align-items: center; gap: .3rem; }
@media (min-width: 600px) { .theme-switcher { display: flex; } }
.theme-btn {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.theme-btn:hover { transform: scale(1.2); }
.theme-btn.active { border-color: var(--accent); transform: scale(1.25); }
.theme-btn[data-theme="dark"]      { background: #1a1d27; }
.theme-btn[data-theme="light"]     { background: #f4f6fb; border-color: #ccd; }
.theme-btn[data-theme="midnight"]  { background: #0d1424; }
.theme-btn[data-theme="hacker"]    { background: #000; outline: 1px solid #00ff41; }
.theme-btn[data-theme="corporate"] { background: #1d4ed8; }

/* Alert bell */
.piq-alert-bell {
  position: relative; cursor: pointer;
  padding: .35rem; border-radius: 8px;
  display: flex; align-items: center;
  transition: background .15s;
}
.piq-alert-bell:hover { background: var(--bg3); }
.piq-alert-bell svg { width: 19px; height: 19px; stroke: var(--text); }
.piq-alert-count {
  position: absolute; top: 1px; right: 1px;
  background: var(--danger); color: #fff;
  font-size: .58rem; font-weight: 800;
  min-width: 15px; height: 15px; border-radius: 99px;
  display: flex; align-items: center; justify-content: center; padding: 0 2px;
}

/* Live pulse dot */
.piq-refresh-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success); flex-shrink: 0;
  animation: livePulse 2.5s ease-in-out infinite;
}
@keyframes livePulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.3;transform:scale(.8)} }

/* ══════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════ */
.piq-sidebar {
  width: 230px; flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; padding: .5rem 0 1.5rem;
  /* Mobile: off-canvas drawer */
  position: fixed; top: 52px; left: 0; bottom: 0; z-index: 150;
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  -webkit-overflow-scrolling: touch;
}
.piq-sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.25); }
@media (min-width: 900px) {
  .piq-sidebar {
    position: relative; top: auto; left: auto; bottom: auto; z-index: auto;
    transform: none; box-shadow: none;
  }
}

/* Overlay (mobile only) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; top: 52px;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 140;
}
.sidebar-overlay.active { display: block; }
@media (min-width: 900px) { .sidebar-overlay { display: none !important; } }

.nav-section-label {
  font-size: .66rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); padding: .7rem 1.1rem .25rem;
  margin-top: .15rem;
}
.piq-nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .62rem 1.1rem;
  color: var(--muted);
  font-size: .875rem; font-weight: 500;
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; text-decoration: none;
  border-left: 3px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
  /* big tap target on mobile */
  min-height: 44px;
}
.piq-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.piq-nav-item:hover { color: var(--text); background: var(--bg3); }
.piq-nav-item.active {
  color: var(--accent); background: var(--accent-bg);
  border-left-color: var(--accent); font-weight: 700;
}
.piq-nav-item.active svg { color: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════════════════ */
.piq-main {
  flex: 1; overflow-y: auto;
  padding: .9rem .85rem;
  padding-bottom: calc(.9rem + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 600px) { .piq-main { padding: 1.1rem 1.1rem; } }
@media (min-width: 900px) { .piq-main { padding: 1.4rem 1.6rem; } }

/* ══════════════════════════════════════════════════════════════
   SECTION TITLES
══════════════════════════════════════════════════════════════ */
.piq-section-title {
  display: flex; align-items: center; gap: .5rem;
  font-size: .95rem; font-weight: 800; margin-bottom: .85rem;
}
.piq-section-title svg { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.piq-section-title .piq-refresh-dot { margin-left: auto; }

/* ══════════════════════════════════════════════════════════════
   BENTO GRID  (Rule #15 — no stat cards, use bento)
══════════════════════════════════════════════════════════════ */
.bento {
  display: grid;
  gap: .7rem;
  grid-template-columns: 1fr;
  margin-bottom: 1rem;
}
@media (min-width: 480px) { .bento { grid-template-columns: repeat(2, 1fr); gap: .8rem; } }
@media (min-width: 900px) { .bento { grid-template-columns: repeat(3, 1fr); gap: .9rem; } }
@media (min-width: 1200px) { .bento { grid-template-columns: repeat(4, 1fr); } }

/* span helpers — collapse on phone */
.bento-card.span-2 { grid-column: span 2; }
.bento-card.span-3 { grid-column: span 3; }
.bento-card.span-full { grid-column: 1 / -1; }
@media (max-width: 479px) {
  .bento-card.span-2,
  .bento-card.span-3,
  .bento-card.span-full { grid-column: span 1; }
}

.bento-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: flex; flex-direction: column; gap: .35rem;
  transition: box-shadow .15s, border-color .15s;
  min-height: 80px;
}
.bento-card:hover { box-shadow: var(--card-shadow); }
.bento-card.interactive { cursor: pointer; }
.bento-card.interactive:hover { border-color: var(--accent); }
.bento-card.dashed { border-style: dashed; }

.card-label {
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
}
.card-value {
  font-size: 1.65rem; font-weight: 800;
  line-height: 1; letter-spacing: -.03em;
}
.card-value.sm { font-size: 1.15rem; }
.card-sub { font-size: .76rem; color: var(--muted); margin-top: .1rem; }

/* ══════════════════════════════════════════════════════════════
   PROGRESS BARS
══════════════════════════════════════════════════════════════ */
.piq-bar-wrap {
  background: var(--bg3);
  border-radius: 99px;
  height: 7px; overflow: hidden; margin: .2rem 0;
}
.piq-bar {
  height: 100%; border-radius: 99px;
  transition: width .65s cubic-bezier(.4,0,.2,1);
  min-width: 3px;
}
.bar-green  { background: var(--success); }
.bar-yellow { background: var(--warning); }
.bar-red    { background: var(--danger); }
.bar-accent { background: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   TABLES  (horizontally scrollable on mobile)
══════════════════════════════════════════════════════════════ */
.tbl-wrap {
  overflow-x: auto; border-radius: var(--radius);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}
table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 380px; }
thead tr { background: var(--bg3); }
th {
  padding: .5rem .75rem; text-align: left;
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); white-space: nowrap;
}
td {
  padding: .52rem .75rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
  /* prevent overflow blowout */
  max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
tr:hover td { background: var(--bg3); }

/* ══════════════════════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: .2rem;
  padding: .17rem .5rem; border-radius: 99px;
  font-size: .69rem; font-weight: 700; white-space: nowrap;
}
.badge-green  { background: rgba(34,197,94,.13);  color: var(--success); }
.badge-red    { background: rgba(239,68,68,.13);  color: var(--danger); }
.badge-yellow { background: rgba(245,158,11,.13); color: var(--warning); }
.badge-blue   { background: rgba(56,189,248,.13); color: var(--info); }
.badge-gray   { background: var(--bg3); color: var(--muted); }
.badge-accent { background: var(--accent-bg); color: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .52rem 1rem; border-radius: 10px;
  font-size: .85rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: filter .15s, background .15s, opacity .15s;
  text-decoration: none; white-space: nowrap;
  /* 44px min tap target */
  min-height: 40px;
}
.btn:active { transform: scale(.97); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.1); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost  { background: var(--bg3); color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: .35rem .75rem; font-size: .79rem; min-height: 34px; }

/* ══════════════════════════════════════════════════════════════
   SERVICE GRID
══════════════════════════════════════════════════════════════ */
.svc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .4rem; margin-top: .35rem;
}
@media (min-width: 600px) { .svc-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.svc-pill {
  display: flex; align-items: center; gap: .4rem;
  padding: .42rem .65rem; border-radius: 8px; font-size: .77rem;
  font-weight: 600; background: var(--bg3); border: 1px solid var(--border);
  min-height: 36px;
}
.svc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green  { background: var(--success); box-shadow: 0 0 5px var(--success); }
.dot-red    { background: var(--danger);  box-shadow: 0 0 5px var(--danger); }
.dot-yellow { background: var(--warning); box-shadow: 0 0 5px var(--warning); }

/* ══════════════════════════════════════════════════════════════
   COMPLIANCE CHECKLISTS
══════════════════════════════════════════════════════════════ */
.compliance-tabs {
  display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.comp-tab {
  padding: .42rem .85rem; border-radius: 8px;
  font-size: .8rem; font-weight: 700;
  cursor: pointer; border: 1.5px solid var(--border);
  background: var(--bg2); color: var(--muted);
  transition: all .15s; min-height: 36px;
}
.comp-tab.active { color: #fff; border-color: transparent; }
.comp-tab:hover:not(.active) { background: var(--bg3); }

.comp-score-bar {
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1rem; background: var(--bg3);
  border-radius: 12px; margin-bottom: 1rem;
  flex-wrap: wrap;
}
.comp-score-val { font-size: 2rem; font-weight: 900; line-height: 1; }
.comp-score-info { flex: 1; min-width: 140px; }
.comp-score-label { font-size: .75rem; color: var(--muted); margin-bottom: .35rem; }

.comp-section { margin-bottom: 1.1rem; }
.comp-section-title {
  font-size: .72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
  padding-bottom: .35rem; border-bottom: 1px solid var(--border);
  margin-bottom: .5rem;
}

.comp-item {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .6rem .75rem; border-radius: 10px; margin-bottom: .3rem;
  background: var(--bg2); border: 1px solid var(--border);
  cursor: pointer; transition: background .12s;
  /* accessible tap target */
  min-height: 48px;
}
.comp-item:hover { background: var(--bg3); }
.comp-item:active { transform: scale(.99); }

.comp-check {
  width: 21px; height: 21px; border-radius: 6px;
  border: 2px solid var(--border); flex-shrink: 0;
  margin-top: 1px; display: flex; align-items: center;
  justify-content: center; transition: all .15s;
}
.comp-item.checked .comp-check { background: var(--success); border-color: var(--success); }
.comp-item.checked .comp-check::after { content: '✓'; font-size: .72rem; color: #fff; font-weight: 900; }
.comp-item.na .comp-check { background: var(--muted); border-color: var(--muted); }
.comp-item.na .comp-check::after { content: '—'; font-size: .65rem; color: #fff; font-weight: 700; }

.comp-item-body { flex: 1; min-width: 0; }
.comp-item-title { font-size: .875rem; font-weight: 600; line-height: 1.3; }
.comp-item.checked .comp-item-title { text-decoration: line-through; color: var(--muted); }
.comp-item.na .comp-item-title { color: var(--muted); }
.comp-item-desc { font-size: .74rem; color: var(--muted); margin-top: .18rem; line-height: 1.4; }
.comp-badge { flex-shrink: 0; align-self: flex-start; margin-top: 3px; }

/* ══════════════════════════════════════════════════════════════
   FORMS / INPUTS
══════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: .85rem; }
.form-group label {
  display: block; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin-bottom: .35rem;
}
.form-input, input[type=text], input[type=password],
input[type=email], select, textarea {
  width: 100%; background: var(--bg3);
  border: 1.5px solid var(--border);
  color: var(--text); border-radius: 10px;
  padding: .65rem .9rem; font-size: .9rem;
  transition: border-color .15s; line-height: 1.4;
  /* 44px touch target */
  min-height: 44px;
}
.form-input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}

/* ══════════════════════════════════════════════════════════════
   LOADING / EMPTY STATES
══════════════════════════════════════════════════════════════ */
.piq-loading {
  display: flex; align-items: center; justify-content: center;
  gap: .65rem; padding: 2.5rem 1rem; color: var(--muted); font-size: .9rem;
}
.piq-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--muted);
}
.empty-state svg { width: 42px; height: 42px; opacity: .3; margin-bottom: .85rem; display: block; margin-inline: auto; }
.empty-state p { font-size: .9rem; }

/* ══════════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════════ */
.piq-toast {
  position: fixed;
  bottom: calc(1.1rem + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: .7rem 1.2rem;
  font-size: .85rem; font-weight: 500;
  z-index: 999; box-shadow: 0 8px 28px rgba(0,0,0,.3);
  opacity: 0; transition: all .22s ease;
  white-space: nowrap; pointer-events: none;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.piq-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ══════════════════════════════════════════════════════════════
   LOGIN / SETUP
══════════════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem; background: var(--bg); overflow-y: auto;
}
.login-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem 1.5rem;
  width: 100%; max-width: 400px;
  box-shadow: var(--card-shadow);
}
@media (min-width: 480px) { .login-box { padding: 2.25rem 2rem; } }
.login-logo {
  font-size: 1.6rem; font-weight: 900;
  text-align: center; margin-bottom: 1.75rem;
  letter-spacing: -.04em;
}
.login-logo span { color: var(--accent); }
.err {
  background: rgba(239,68,68,.1); color: var(--danger);
  padding: .65rem .9rem; border-radius: 8px;
  font-size: .83rem; margin-bottom: .85rem;
  border-left: 3px solid var(--danger);
}

/* ══════════════════════════════════════════════════════════════
   ALERTS FEED
══════════════════════════════════════════════════════════════ */
.alert-item {
  display: flex; align-items: flex-start; gap: .65rem;
  padding: .65rem .8rem; border-radius: 10px; margin-bottom: .4rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-left-width: 3px;
}
.alert-item.danger  { border-left-color: var(--danger); }
.alert-item.warning { border-left-color: var(--warning); }
.alert-item.info    { border-left-color: var(--info); }
.alert-item.success { border-left-color: var(--success); }

/* ══════════════════════════════════════════════════════════════
   TOOLBAR (search + actions row)
══════════════════════════════════════════════════════════════ */
.piq-toolbar {
  display: flex; align-items: center; gap: .6rem;
  margin-bottom: .85rem; flex-wrap: wrap;
}
.piq-search {
  flex: 1; min-width: 160px;
  background: var(--bg3); border: 1.5px solid var(--border);
  color: var(--text); border-radius: 10px;
  padding: .55rem .85rem; font-size: .875rem; min-height: 40px;
}
.piq-search:focus { outline: none; border-color: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   DIVIDER & MISC
══════════════════════════════════════════════════════════════ */
hr.divider, .divider { border: none; border-top: 1px solid var(--border); margin: .85rem 0; }
.mono { font-family: 'Courier New', Courier, monospace; font-size: .8rem; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--muted); }
.text-accent  { color: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════════ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .2s ease; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.pulse { animation: pulse 2s infinite; }