/* =============================================================
   PATIENT COMMAND CENTER — kit.css
   Cockpit-density, Bloomberg-meets-Mayo. Dense by default,
   responsive to mobile. Inherits design tokens from /colors_and_type.css.
   ============================================================= */

@import url("../../colors_and_type.css");

:root {
  --pat-bg:            #F4F5F1;       /* slightly cooler than bone */
  --pat-surface:       #FFFFFF;
  --pat-surface-2:     #FAFAF7;
  --pat-surface-deep:  #ECEEE7;
  --pat-rail:          #1A1F2C;       /* sidebar dark — cockpit */
  --pat-rail-fg:       #D6DCD2;
  --pat-rail-fg-mute:  #8B928A;
  --pat-rail-active:   #2A8B5E;
  --pat-hairline:      rgba(26,31,44,0.08);
  --pat-hairline-2:    rgba(26,31,44,0.14);
  --pat-accent:        #117A4D;
  --pat-accent-2:      #2A8B5E;
  --pat-halo:          #B08D3C;
  --pat-alert:         #B83A2E;
  --pat-warn:          #DDA055;
  --pat-info:          #2C5F87;
  --pat-up:            #1E9E6E;
  --pat-down:          #B23A2E;
  --pat-rail-w: 244px;
  --pat-status-h: 28px;
  --pat-topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body, #app { margin:0; padding:0; }
body {
  background: var(--pat-bg);
  color: var(--fg-1);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }

/* ============================================================
   APP SHELL
   ============================================================ */
.pat-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--pat-rail-w) 1fr;
  grid-template-rows: var(--pat-status-h) var(--pat-topbar-h) 1fr;
  grid-template-areas:
    "rail status"
    "rail topbar"
    "rail main";
}
.pat-status { grid-area: status; }
.pat-rail   { grid-area: rail; }
.pat-topbar { grid-area: topbar; }
.pat-main   { grid-area: main; overflow-x: hidden; }

/* ----- status strip ----- */
.pat-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  background: #0F1320;
  color: #B7BFB6;
  border-bottom: 1px solid #21283A;
}
.pat-status .seg { display: flex; align-items: center; gap: 14px; }
.pat-status .live::before {
  content:""; width:6px; height:6px; border-radius:50%;
  background: var(--pat-up);
  display:inline-block; margin-right:6px;
  box-shadow: 0 0 6px rgba(30,158,110,0.7);
  animation: pat-pulse 2s ease-in-out infinite;
}
.pat-status .ticker { color: var(--pat-halo); }
.pat-status .integrity { color: #C1A86B; font-style: italic; }
@keyframes pat-pulse { 0%,100% { opacity:1 } 50% { opacity:0.4 } }

/* ----- rail (sidebar) ----- */
.pat-rail {
  background: var(--pat-rail);
  color: var(--pat-rail-fg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid #2A3142;
  overflow-y: auto;
}
.pat-rail::-webkit-scrollbar { width: 6px; }
.pat-rail::-webkit-scrollbar-thumb { background: #2A3142; border-radius: 3px; }

.pat-rail-brand {
  display:flex; align-items:center; gap:10px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid #21283A;
}
.pat-rail-brand .mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: linear-gradient(135deg, #2A8B5E 0%, #117A4D 100%);
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-weight: 600; color: #fff; font-size: 14px;
}
.pat-rail-brand .name {
  font-family: var(--font-display); font-weight: 600; font-size: 14.5px; color:#F0F4EE;
  letter-spacing: -0.01em;
}
.pat-rail-brand .sub {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--pat-rail-fg-mute); margin-top: 1px;
}

/* household member quick-switch */
.pat-rail-member {
  margin: 12px 12px 4px;
  padding: 10px 12px;
  background: #21283A;
  border-radius: 8px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  border: 1px solid #2A3142;
  transition: background 120ms;
}
.pat-rail-member:hover { background: #283045; }
.pat-rail-member .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #5A6F8B, #3B4A60);
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-weight: 600; font-size: 12px;
}
.pat-rail-member .who {
  flex: 1; min-width: 0;
}
.pat-rail-member .who .nm {
  font-family: var(--font-display); font-weight: 600; font-size: 12.5px; color: #F0F4EE;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pat-rail-member .who .role {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--pat-rail-fg-mute);
}
.pat-rail-member .chev { color: var(--pat-rail-fg-mute); font-size: 10px; }

.pat-rail-section {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #6B7488;
  padding: 16px 18px 6px;
}
.pat-rail-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 18px;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--pat-rail-fg);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 100ms;
}
.pat-rail-link:hover { background: #21283A; }
.pat-rail-link.active {
  background: #21283A;
  border-left-color: var(--pat-rail-active);
  color: #F0F4EE;
}
.pat-rail-link .ico {
  width: 16px; height: 16px; opacity: 0.85;
  font-family: var(--font-mono); font-size: 11px; text-align:center;
}
.pat-rail-link .badge {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 9.5px;
  background: var(--pat-rail-active);
  color: #02160C; padding: 1px 6px; border-radius: 999px;
  font-weight: 600;
}
.pat-rail-link .badge.alert { background: var(--pat-alert); color:#fff; }

.pat-rail-foot {
  margin-top: auto;
  padding: 12px 18px;
  border-top: 1px solid #21283A;
  font-family: var(--font-mono);
  font-size: 9.5px; letter-spacing: 0.10em; color: var(--pat-rail-fg-mute);
}

/* ----- topbar ----- */
.pat-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--pat-surface);
  border-bottom: 1px solid var(--pat-hairline);
}
.pat-topbar .crumbs {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  color: var(--fg-3);
}
.pat-topbar .crumbs .now { color: var(--fg-1); }
.pat-topbar .search {
  flex: 1; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--pat-surface-2);
  border: 1px solid var(--pat-hairline);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--fg-2);
}
.pat-topbar .search input {
  flex:1; border:none; background:transparent; outline:none; font:inherit; color: var(--fg-1);
}
.pat-topbar .search .kbd {
  font-family: var(--font-mono); font-size: 10px;
  background: var(--pat-surface); border: 1px solid var(--pat-hairline);
  padding: 1px 6px; border-radius: 4px; color: var(--fg-3);
}
.pat-topbar .actions { display: flex; align-items: center; gap: 8px; }
.pat-topbar .icon-btn {
  width: 32px; height: 32px;
  display:inline-flex; align-items:center; justify-content:center;
  border-radius: 6px;
  background: transparent; border: 1px solid var(--pat-hairline);
  color: var(--fg-2); cursor: pointer; font-size: 13px;
  position: relative;
}
.pat-topbar .icon-btn:hover { background: var(--pat-surface-2); color: var(--fg-1); }
.pat-topbar .icon-btn .dot {
  position: absolute; top: -2px; right: -2px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--pat-alert);
  border: 2px solid var(--pat-surface);
}
.pat-topbar .ai-btn {
  display: inline-flex; align-items:center; gap: 8px;
  padding: 7px 12px;
  white-space: nowrap;
  border-radius: 8px;
  background: linear-gradient(135deg, #117A4D 0%, #2A8B5E 100%);
  color: #fff; border: none; cursor: pointer;
  font-weight: 600; font-size: 12.5px;
  box-shadow: 0 2px 6px rgba(17,122,77,0.25);
}
.pat-topbar .ai-btn:hover { filter: brightness(1.05); }
.pat-topbar .persona {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  white-space: nowrap;
  background: var(--pat-surface-2);
  border: 1px solid var(--pat-hairline);
  border-radius: 6px;
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--fg-2);
  cursor: pointer;
}

/* ----- main content ----- */
.pat-main {
  padding: 18px 22px 60px;
  max-width: 100%;
}
.pat-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 14px;
}
.pat-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--pat-accent);
}
.pat-h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 28px; letter-spacing: -0.02em; margin: 4px 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pat-h2 { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: -0.01em; margin: 0; }
.pat-h3 { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; margin: 0; }

/* ============================================================
   CARDS / TILES
   ============================================================ */
.pat-card {
  background: var(--pat-surface);
  border: 1px solid var(--pat-hairline);
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
}
.pat-card.tight { padding: 10px 12px; }
.pat-card.dense { padding: 12px 14px; }
.pat-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.pat-card-head .ttl { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-3); }
.pat-card-head .act { font-family: var(--font-mono); font-size: 10px; color: var(--pat-accent); cursor: pointer; }
.pat-num {
  font-family: var(--font-display); font-weight: 600;
  font-size: 28px; letter-spacing: -0.02em; line-height: 1;
}
.pat-num.lg { font-size: 44px; }
.pat-num.xl { font-size: 64px; }
.pat-num .u { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); margin-left: 4px; font-weight: 400; letter-spacing: 0.08em; }
.pat-trend.up   { color: var(--pat-up); font-family: var(--font-mono); font-size: 11px; }
.pat-trend.down { color: var(--pat-down); font-family: var(--font-mono); font-size: 11px; }
.pat-mini {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--fg-3);
}

/* ----- pulse grid (cockpit) ----- */
.pat-grid { display: grid; gap: 12px; }
.pat-grid.cols-12 { grid-template-columns: repeat(12, 1fr); }
.pat-grid.cols-6  { grid-template-columns: repeat(6, 1fr); }
.pat-grid.cols-4  { grid-template-columns: repeat(4, 1fr); }
.pat-grid.cols-3  { grid-template-columns: repeat(3, 1fr); }
.pat-grid.cols-2  { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; }
.span-12 { grid-column: span 12; }

/* tickets / list rows */
.pat-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--pat-hairline);
  background: var(--pat-surface);
  font-size: 12px;
  align-items: center;
}
.pat-row + .pat-row { margin-top: 6px; }
.pat-row .badge {
  font-family: var(--font-mono); font-size: 9px;
  padding: 1px 6px; border-radius: 4px;
  background: var(--pat-surface-deep); color: var(--fg-2);
  letter-spacing: 0.10em; text-transform: uppercase;
}
.pat-row .badge.alert { background: rgba(184,58,46,0.10); color: var(--pat-alert); }
.pat-row .badge.warn  { background: rgba(221,160,85,0.16); color: #8B6020; }
.pat-row .badge.ok    { background: rgba(30,158,110,0.10); color: var(--pat-up); }
.pat-row .badge.info  { background: rgba(44,95,135,0.10); color: var(--pat-info); }

/* segmented */
.pat-tabs {
  display: inline-flex; gap: 0;
  border: 1px solid var(--pat-hairline); border-radius: 8px;
  background: var(--pat-surface);
  overflow: hidden;
}
.pat-tabs button {
  padding: 7px 14px;
  font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  background: transparent; border: none;
  color: var(--fg-2); cursor: pointer;
  border-right: 1px solid var(--pat-hairline);
}
.pat-tabs button:last-child { border-right: none; }
.pat-tabs button.active {
  background: var(--pat-accent);
  color: #fff;
}

/* primary button */
.pat-btn {
  display:inline-flex; align-items:center; gap: 6px;
  padding: 8px 14px; border-radius: 7px;
  white-space: nowrap;
  background: var(--pat-accent); color:#fff;
  border: none; font-weight: 600; font-size: 12.5px;
  cursor: pointer;
}
.pat-btn:hover { background: var(--pat-accent-2); }
.pat-btn.ghost {
  background: transparent; color: var(--fg-1);
  border: 1px solid var(--pat-hairline);
}
.pat-btn.ghost:hover { background: var(--pat-surface-2); }
.pat-btn.danger { background: var(--pat-alert); }
.pat-btn.sm { padding: 6px 10px; font-size: 11.5px; }

/* hero orb canvas */
.pat-orb-stage {
  position: relative;
  background:
    radial-gradient(60% 60% at 50% 50%, rgba(17,122,77,0.06) 0%, transparent 70%),
    var(--pat-surface);
  border: 1px solid var(--pat-hairline);
  border-radius: 12px;
  overflow: hidden;
  min-height: 360px;
}
.pat-orb-stage svg { display: block; width: 100%; height: 100%; }
.pat-orb-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 16px 18px;
}

/* mini sparkline cells */
.pat-spark {
  width: 100%; height: 26px; display: block;
}

/* AI concierge floating panel */
.pat-ai-overlay {
  position: fixed; right: 22px; bottom: 22px;
  width: 380px; max-width: calc(100vw - 28px);
  height: 540px; max-height: calc(100vh - 110px);
  background: var(--pat-surface);
  border: 1px solid var(--pat-hairline-2);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(26,31,44,0.18), 0 4px 16px rgba(26,31,44,0.10);
  display: flex; flex-direction: column;
  z-index: 80;
  overflow: hidden;
}
.pat-ai-overlay header {
  background: linear-gradient(135deg, #117A4D 0%, #2A8B5E 100%);
  color: #fff;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.pat-ai-overlay header .ttl {
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
}
.pat-ai-overlay header .sub {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.16em;
  text-transform: uppercase; opacity: 0.85;
}
.pat-ai-overlay .body { flex:1; overflow:auto; padding: 14px; font-size: 13px; }
.pat-ai-overlay .input {
  border-top: 1px solid var(--pat-hairline);
  padding: 10px 12px;
  display: flex; gap: 8px;
  background: var(--pat-surface-2);
}
.pat-ai-overlay .input input {
  flex:1; border: 1px solid var(--pat-hairline); border-radius: 6px;
  padding: 8px 10px; font: inherit;
}

/* household drawer */
.pat-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,20,25,0.40);
  z-index: 70;
}
.pat-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 92vw;
  background: var(--pat-surface);
  border-left: 1px solid var(--pat-hairline-2);
  z-index: 71;
  display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(26,31,44,0.18);
}
.pat-drawer header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--pat-hairline);
  display: flex; align-items: center; justify-content: space-between;
}
.pat-drawer .body { flex:1; overflow:auto; padding: 12px 16px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .pat-grid.cols-12 { grid-template-columns: repeat(6, 1fr); }
  .pat-grid.cols-6  { grid-template-columns: repeat(3, 1fr); }
  .span-12, .span-9, .span-8, .span-7 { grid-column: span 6; }
  .span-6, .span-5, .span-4 { grid-column: span 6; }
  .span-3, .span-2 { grid-column: span 3; }
}
@media (max-width: 820px) {
  .pat-app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--pat-status-h) var(--pat-topbar-h) 1fr;
    grid-template-areas:
      "status"
      "topbar"
      "main";
  }
  .pat-rail {
    position: fixed;
    top: 0; left: 0; bottom: 0; width: 260px;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 220ms ease;
  }
  .pat-rail.open { transform: translateX(0); }
  .pat-topbar .crumbs { display: none; }
  .pat-topbar .search { max-width: none; }
  .pat-grid.cols-12, .pat-grid.cols-6, .pat-grid.cols-4, .pat-grid.cols-3 {
    grid-template-columns: 1fr 1fr;
  }
  .pat-grid.cols-2 { grid-template-columns: 1fr; }
  [class*="span-"] { grid-column: span 2; }
  .pat-num.xl { font-size: 48px; }
  .pat-ai-overlay { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: 70vh; }
}
@media (max-width: 480px) {
  .pat-main { padding: 12px 12px 60px; }
  .pat-h1 { font-size: 22px; }
  .pat-grid.cols-12, .pat-grid.cols-6, .pat-grid.cols-4, .pat-grid.cols-3, .pat-grid.cols-2 {
    grid-template-columns: 1fr;
  }
  [class*="span-"] { grid-column: span 1; }
}

/* mobile menu burger button (hidden on desktop) */
.pat-burger {
  display: none;
  width: 32px; height: 32px;
  border-radius: 6px; border: 1px solid var(--pat-hairline);
  background: transparent; color: var(--fg-1);
  align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer;
}
@media (max-width: 820px) { .pat-burger { display: inline-flex; } }
