:root {
  --hd-bg: #08090A;
  --hd-bg-alt: #0A0B0C;
  --hd-panel: #0B0C0D;
  --hd-input: #0E1011;
  --hd-accent: #D9FF4D;
  --hd-accent-wash: rgba(217, 255, 77, .06);
  --hd-border: rgba(255, 255, 255, .09);
  --hd-border-strong: rgba(255, 255, 255, .14);
  --hd-text-primary: #EDEBE6;
  --hd-text-secondary: #A6A9A2;
  --hd-text-muted: #8C8F8C;
  --hd-text-faint: #5C605A;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--hd-bg);
  color: var(--hd-text-primary);
  font-family: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.hdos-mono {
  font-family: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
}

/* ── Auth screen ─────────────────────────────────────────────────────────── */
.hdos-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.hdos-auth__card {
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--hd-border);
  background: var(--hd-panel);
  padding: 40px 36px;
}

.hdos-auth__logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: 4px;
}
.hdos-auth__logo span { color: var(--hd-text-muted); font-weight: 500; }

.hdos-auth__kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--hd-text-faint);
  margin-bottom: 32px;
}

.hdos-field {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  font-size: 12.5px;
  color: var(--hd-text-secondary);
}

.hdos-input {
  background: var(--hd-input);
  border: 1px solid var(--hd-border-strong);
  color: var(--hd-text-primary);
  padding: 12px 13px;
  font-size: 14px;
  width: 100%;
  outline: none;
  font-family: inherit;
}
.hdos-input:focus { border-color: var(--hd-accent); }

.hdos-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  padding: 12px 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.hdos-btn--solid { background: var(--hd-accent); color: var(--hd-bg); width: 100%; margin-top: 6px; }
.hdos-btn--solid:disabled { opacity: .5; cursor: progress; }

.hdos-error {
  font-size: 12.5px;
  color: #FF8A7A;
  margin: -6px 0 16px;
  min-height: 1em;
}

/* ── App shell ───────────────────────────────────────────────────────────── */
.hdos-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.hdos-sidebar {
  border-right: 1px solid var(--hd-border);
  background: var(--hd-panel);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
}

.hdos-sidebar__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.01em;
  padding: 0 8px 24px;
}
.hdos-sidebar__logo img { height: 22px; width: auto; display: block; }
.hdos-sidebar__logo span { color: var(--hd-text-muted); font-weight: 500; }

.hdos-sidebar__close { display: none; }

.hdos-nav { display: grid; gap: 2px; margin-bottom: 20px; }

.hdos-nav__link {
  padding: 10px 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--hd-text-secondary);
  border-left: 2px solid transparent;
}
.hdos-nav__link:hover { color: var(--hd-text-primary); background: rgba(255,255,255,.03); }
.hdos-nav__link.is-active { color: var(--hd-accent); border-left-color: var(--hd-accent); background: var(--hd-accent-wash); }
.hdos-nav__link.is-disabled { color: var(--hd-text-faint); cursor: default; }
.hdos-nav__link.is-disabled:hover { color: var(--hd-text-faint); background: none; }

.hdos-nav__rule { border: 0; border-top: 1px solid var(--hd-border); margin: 12px 0; }

.hdos-nav__secondary { display: grid; gap: 2px; margin-bottom: auto; }
.hdos-nav__secondary .hdos-nav__link { font-weight: 500; font-size: 13px; color: var(--hd-text-muted); }

.hdos-sidebar__profile {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hd-border);
}
.hdos-sidebar__name { font-size: 13px; font-weight: 600; }
.hdos-sidebar__role {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--hd-text-faint);
  margin-bottom: 10px;
}
.hdos-logout {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--hd-text-muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.hdos-logout:hover { color: var(--hd-accent); }

.hdos-main { padding: 32px 40px; overflow-x: auto; }

.hdos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.hdos-header h1 { font-size: 22px; margin: 0; letter-spacing: -.015em; }

.hdos-search {
  background: var(--hd-input);
  border: 1px solid var(--hd-border-strong);
  color: var(--hd-text-primary);
  padding: 9px 12px;
  font-size: 13px;
  width: 260px;
  outline: none;
  font-family: inherit;
}
.hdos-search:focus { border-color: var(--hd-accent); }

/* ── Table ───────────────────────────────────────────────────────────────── */
.hdos-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.hdos-table th {
  text-align: left;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--hd-text-faint);
  font-weight: 500;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--hd-border);
}
.hdos-table td { padding: 13px 14px; border-bottom: 1px solid var(--hd-border); }
.hdos-table tr:hover td { background: rgba(255,255,255,.02); }
.hdos-table a.hdos-row-link { display: block; }

.hdos-badge {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--hd-border-strong);
  color: var(--hd-text-secondary);
}
.hdos-badge--prospect { color: var(--hd-text-muted); }
.hdos-badge--active { color: var(--hd-accent); border-color: rgba(217,255,77,.35); }
.hdos-badge--past { color: var(--hd-text-faint); }
.hdos-badge--paid { color: var(--hd-accent); border-color: rgba(217,255,77,.35); }
.hdos-badge--issued { color: var(--hd-text-secondary); }
.hdos-badge--overdue { color: #FF8A7A; border-color: rgba(255,138,122,.35); }

.hdos-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--hd-text-muted);
  font-size: 14px;
  border: 1px dashed var(--hd-border-strong);
}

/* ── Panels / detail ─────────────────────────────────────────────────────── */
.hdos-panel { border: 1px solid var(--hd-border); background: var(--hd-panel); padding: 24px; margin-bottom: 20px; }
.hdos-panel h2 { font-size: 15px; margin: 0 0 16px; }

.hdos-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hd-border); margin-bottom: 24px; }
.hdos-tab {
  padding: 10px 4px;
  margin-right: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--hd-text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
  font-family: inherit;
}
.hdos-tab.is-active { color: var(--hd-text-primary); border-bottom-color: var(--hd-accent); }

.hdos-kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 0; font-size: 13.5px; }
.hdos-kv dt { color: var(--hd-text-faint); font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; align-self: start; padding-top: 2px; }
.hdos-kv dd { margin: 0; color: var(--hd-text-secondary); }

.hdos-activity { display: grid; gap: 0; }
.hdos-activity__item { padding: 14px 0; border-top: 1px solid var(--hd-border); }
.hdos-activity__item:first-child { border-top: 0; }
.hdos-activity__time { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--hd-text-faint); margin-bottom: 4px; }
.hdos-activity__title { font-size: 13.5px; }

.hdos-btn--ghost {
  background: none;
  border: 1px solid var(--hd-border-strong);
  color: var(--hd-text-primary);
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.hdos-btn--ghost:hover { border-color: var(--hd-accent); color: var(--hd-accent); }

.hdos-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: none; place-items: center; z-index: 50;
}
.hdos-modal-backdrop.is-open { display: grid; }
.hdos-modal {
  width: 100%; max-width: 440px;
  background: var(--hd-panel); border: 1px solid var(--hd-border-strong);
  padding: 28px;
}
.hdos-modal h2 { font-size: 16px; margin: 0 0 18px; }
.hdos-modal-actions { display: flex; gap: 10px; margin-top: 4px; }

.hdos-coming-soon {
  display: grid; place-items: center; min-height: 60vh; text-align: center;
}
.hdos-coming-soon h2 { font-size: 20px; margin-bottom: 8px; }
.hdos-coming-soon p { color: var(--hd-text-muted); font-size: 14px; }

/* ── Mobile top bar & off-canvas nav ─────────────────────────────────────── */
.hdos-mobile-topbar { display: none; }
.hdos-nav-backdrop { display: none; }

@media (max-width: 860px) {
  .hdos-shell { display: block; }

  .hdos-mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--hd-border);
    background: var(--hd-bg);
    position: sticky;
    top: 0;
    z-index: 30;
  }
  body.hdos-nav-open .hdos-mobile-topbar__logo { visibility: hidden; }

  .hdos-mobile-topbar__logo { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
  .hdos-mobile-topbar__logo img { height: 22px; width: auto; display: block; }
  .hdos-mobile-topbar__logo span { color: var(--hd-text-muted); font-weight: 500; }

  .hdos-menu-toggle {
    background: none;
    border: 1px solid var(--hd-border-strong);
    color: var(--hd-text-primary);
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex: 0 0 auto;
    font-size: 16px;
  }

  .hdos-sidebar {
    position: fixed;
    inset: 0;
    z-index: 60;
    width: 84vw;
    max-width: 320px;
    background: #08090A;
    transform: translateX(-100%);
    transition: transform .22s ease;
    overflow-y: auto;
  }
  body.hdos-nav-open .hdos-sidebar { transform: translateX(0); }

  .hdos-sidebar__close {
    display: grid;
    place-items: center;
    margin-left: auto;
    margin-bottom: 14px;
    background: none;
    border: 1px solid var(--hd-border-strong);
    color: var(--hd-text-primary);
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 15px;
  }

  .hdos-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  body.hdos-nav-open .hdos-nav-backdrop { opacity: 1; pointer-events: auto; }

  .hdos-main { padding: 20px 16px; }
  .hdos-header { flex-wrap: wrap; }
  .hdos-search { width: 100% !important; }
  .hdos-dash-grid { grid-template-columns: 1fr !important; }
  .hdos-stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .hdos-lead-grid,
  .hdos-prospect-grid,
  .hdos-forecast-grid { grid-template-columns: 1fr !important; }
  .hdos-inbox-grid { grid-template-columns: 1fr !important; height: auto !important; }
  .hdos-inbox-list { max-height: 320px; overflow-y: auto; }

  /* Data tables scroll horizontally within themselves instead of forcing every
     cell to wrap into a vertical stack (or blowing out the page width). */
  .hdos-table { display: block; overflow-x: auto; white-space: nowrap; max-width: 100%; -webkit-overflow-scrolling: touch; }

  .hdos-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .hdos-tab { flex-shrink: 0; }

  /* Long unbroken strings (email addresses in the portal-status badge) have no
     spaces to wrap on and otherwise overflow their container. */
  .hdos-badge { overflow-wrap: anywhere; white-space: normal; }

  /* Modals: top-aligned + scrollable so a tall form is never clipped off-screen
     with no way to reach the submit button, and never touches the screen edges. */
  .hdos-modal-backdrop.is-open { display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 32px 16px; }
  .hdos-modal { margin: 0; }

  .hdos-portal-header { padding: 16px 20px; }
  .hdos-portal-main { padding: 28px 20px; }
}
