.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; color: #d9e1dc; background: var(--sidebar); display: flex; flex-direction: column; z-index: 30; box-shadow: 8px 0 28px rgba(8, 25, 16, .08); }
.brand { height: 76px; display: flex; align-items: center; gap: 12px; padding: 0 22px; border-bottom: 1px solid rgba(255,255,255,.075); }
.brand strong { display: block; color: #fff; font-size: 18px; font-weight: 700; }
.brand small { display: block; margin-top: 3px; color: #7f9489; font: 500 9px/1 "DM Mono", monospace; letter-spacing: 1.5px; }
.brand-mark { width: 29px; height: 29px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; transform: skewY(-8deg); }
.brand-mark span { border-radius: 2px; background: #31b77f; }
.brand-mark span:nth-child(2) { margin-top: 6px; background: #b5d25a; }
.brand-mark span:nth-child(3) { margin-top: 12px; background: #f0bd57; }
.main-nav { flex: 1; overflow-y: auto; padding: 18px 12px; scrollbar-width: thin; }
.nav-label { margin: 20px 11px 8px; color: #71867b; font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.nav-label:first-child { margin-top: 0; }
.nav-item { width: 100%; height: 44px; padding: 0 12px; border: 0; border-radius: 7px; color: #aebcb5; background: transparent; display: flex; align-items: center; gap: 11px; cursor: pointer; text-align: left; transition: color .18s ease, background .18s ease, transform .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: #23382e; box-shadow: inset 3px 0 #42c487; }
.nav-item svg { width: 18px; height: 18px; }
.nav-item span { flex: 1; }
.nav-item em { min-width: 24px; height: 20px; padding: 0 6px; border-radius: 10px; color: #8fa097; background: rgba(255,255,255,.06); font: normal 10px/20px "DM Mono", monospace; text-align: center; }
.nav-item b { width: 7px; height: 7px; border-radius: 50%; background: #ef956d; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 12px; }
.system-health { margin: 0 4px 11px; padding: 11px; border: 1px solid rgba(255,255,255,.045); border-radius: 7px; background: rgba(255,255,255,.035); }
.system-health div { display: flex; align-items: center; gap: 7px; }
.system-health strong { color: #c9d5ce; font-size: 11px; font-weight: 500; }
.system-health small { display: block; margin: 5px 0 0 15px; color: #73847b; font: 9px "DM Mono", monospace; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: #48c78e; box-shadow: 0 0 0 4px rgba(72,199,142,.1); }
.profile-button { width: 100%; padding: 8px; border: 0; border-radius: 7px; background: transparent; display: grid; grid-template-columns: 36px 1fr 18px; align-items: center; gap: 10px; color: #fff; text-align: left; cursor: pointer; transition: background .18s ease; }
.profile-button:hover { background: rgba(255,255,255,.05); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #ead9aa; color: #4b4330; display: grid; place-items: center; font-weight: 700; }
.profile-button strong, .profile-button small { display: block; }
.profile-button strong { font-size: 12px; }
.profile-button small { margin-top: 2px; color: #829188; font-size: 9px; }
.profile-button svg { width: 16px; color: #77877e; }

.main-wrap { min-width: 0; flex: 1; margin-left: 252px; }
.topbar { position: sticky; top: 0; height: 68px; padding: 0 32px; background: rgba(255,255,255,.96); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); box-shadow: 0 1px 8px rgba(20,38,29,.025); display: flex; align-items: center; justify-content: space-between; gap: 20px; z-index: 20; }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 10px; }
.tenant-scope { display: flex; align-items: center; gap: 9px; }
.tenant-scope > span { color: var(--muted); font-size: 12px; }
.tenant-scope button { border: 0; padding: 8px 10px; border-radius: 7px; background: transparent; font-weight: 700; cursor: pointer; }
.tenant-scope button:hover { background: var(--paper); }
.tenant-scope svg { width: 14px; vertical-align: -2px; }

main { min-height: calc(100vh - 68px); padding: 30px 32px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.eyebrow { color: var(--green); font: 500 9px "DM Mono", monospace; letter-spacing: 1.5px; }
.page-head h1 { margin: 7px 0 5px; font-size: 28px; line-height: 1.2; font-weight: 720; letter-spacing: 0; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.page-head-actions { display: flex; gap: 8px; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .agent-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-layout { grid-template-columns: 210px minmax(0, 1fr); }
  .chat-context { display: none; }
  .global-search { width: 240px; }
  .plan-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .mobile-menu { display: grid; }
  .global-search { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .architecture { grid-template-columns: 1fr; }
  .arch-nav { display: flex; overflow-x: auto; }
  .arch-nav button { min-width: 130px; }
  .service-map { grid-template-columns: repeat(2, 1fr); }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .monitor-grid { grid-template-columns: 1fr; }
  .service-status-list > div { grid-template-columns: 12px minmax(110px, 1fr) 60px 70px; }
  .service-status-list > div > span:last-child { display: none; }
}

@media (max-width: 620px) {
  .topbar { height: 62px; padding: 0 14px; }
  .tenant-scope > span { display: none; }
  .topbar-actions > .icon-button { display: none; }
  .primary-button { padding: 0 11px; }
  main { min-height: calc(100vh - 62px); padding: 20px 14px 36px; }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 23px; }
  .page-head-actions .secondary-button { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  .agent-grid, .service-map { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .filter-input { width: 100%; }
  .data-table { min-width: 700px; }
  .table-panel { overflow-x: auto; }
  .chat-layout { grid-template-columns: 1fr; height: calc(100vh - 106px); min-height: 560px; }
  .chat-list { display: none; }
  .chat-messages { padding: 18px 12px; }
  .message { max-width: 92%; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .isolation-choice label { width: 100%; }
  .isolation-choice label:first-of-type { margin: 0 0 7px; }
  .plan-grid, .rule-grid { grid-template-columns: 1fr; }
  .rule-grid > div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .rule-grid > div:last-child { border-bottom: 0; }
  .detail-grid, .settings-fields { grid-template-columns: 1fr; }
  .settings-fields .full-field { grid-column: auto; }
  .panel-actions, .form-actions { flex-wrap: wrap; }
  .panel-actions button, .form-actions button { flex: 1; justify-content: center; }
  .settings-footer { align-items: stretch; flex-direction: column; }
  .settings-footer button { justify-content: center; }
  .section-head { align-items: stretch; flex-direction: column; }
  .service-status-list > div { grid-template-columns: 12px minmax(100px, 1fr) 60px; }
  .service-status-list > div > span:nth-last-child(-n+2) { display: none; }
  .credential-list > div { grid-template-columns: 34px minmax(0, 1fr); }
  .credential-list .status { grid-column: 2; justify-self: start; }
  .credential-list .table-actions, .credential-list > div > .icon-button { grid-column: 2; justify-self: start; }
  .agent-card-foot { align-items: flex-start; flex-direction: column; }
  .agent-card-actions { width: 100%; justify-content: space-between; }
  .entry-brand-panel { padding: 20px 20px 25px; }
  .entry-brand-content { margin: 25px 0 0; }
  .entry-brand-line { display: none; }
  .entry-copy { margin: 0 0 20px; }
  .entry-copy h1 { margin: 8px 0 10px; font-size: 27px; }
  .entry-copy p { font-size: 10px; }
  .entry-capabilities { grid-template-columns: 1fr; }
  .entry-capabilities > div { min-height: 45px; padding: 9px 4px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.2); grid-template-columns: 27px 1fr auto; }
  .entry-capabilities > div:last-child { border-bottom: 0; }
  .entry-capabilities span { grid-column: auto; }
  .entry-form-panel { min-height: 500px; padding: 32px 20px; place-items: start center; }
  .entry-mobile-brand { margin-bottom: 26px; display: flex; align-items: center; gap: 9px; }
  .entry-mobile-brand .entry-logo { width: 34px; height: 34px; color: #fff; background: var(--entry-primary); }
  .entry-mobile-brand .entry-logo svg { width: 16px; }
  .entry-form-wrap h2 { font-size: 22px; }
  .entry-support { align-items: flex-start; flex-direction: column; gap: 8px; }
  .portal-shell { grid-template-rows: 58px minmax(0, 1fr) auto 20px; }
  .portal-header { padding: 0 12px; }
  .portal-header .secondary-button { width: 36px; padding: 0; font-size: 0; }
  .portal-header .secondary-button svg { width: 15px; }
  .portal-main { width: calc(100% - 24px); padding-top: 25px; }
  .portal-intro { padding-bottom: 18px; }
  .portal-prompts { grid-template-columns: 1fr; }
  .portal-prompts button { min-height: 43px; }
  .portal-message { max-width: 92%; }
  .portal-compose { width: calc(100% - 24px); grid-template-columns: 34px 1fr 38px; }
}
