/* Fixed application frame. Only bounded panels, tables and menus scroll. */
html { height: 100%; }
.app-shell, .public-shell, .login-page { height: 100dvh; min-height: 0; overflow: hidden; }
.app-shell { --sidebar-width: 230px; }
.app-shell .workspace {
  margin-left: var(--sidebar-width); height: 100dvh; min-height: 0;
  display: grid; grid-template-rows: 38px minmax(0, 1fr) 26px;
}
.app-shell .topbar { min-height: 0; padding: 0 22px; gap: 14px; justify-content: flex-start; }
.app-shell .topbar > .eyebrow { display: block; font-size: 9px; }
.app-shell .content, .public-shell .content {
  display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0;
  max-width: none; padding: 18px 22px; overflow: hidden;
}
.app-shell .content > * { flex-shrink: 0; }
.app-shell .page-heading { margin: 0; gap: 12px; }
.app-shell .page-heading > div { min-width: 0; }
.app-shell h1 { font-size: 25px; margin-bottom: 5px; overflow-wrap: anywhere; }
.app-shell .eyebrow { margin-bottom: 4px; }
.app-shell .page-heading p { font-size: 12px; }
.app-shell .content > .panel, .public-shell .content > .panel { flex: 1 1 0; min-height: 0; }
.app-shell .panel, .public-shell .panel {
  margin: 0; padding: 18px; min-height: 0; overflow: auto; overscroll-behavior: contain;
}
.app-shell .panel h2 { margin-bottom: 12px; }
.app-shell .narrow, .public-shell .narrow { width: 100%; }
.app-shell .error-panel { margin-top: 0; }
.app-shell .two-columns {
  flex: 1 1 0; min-height: 0; min-width: 0; gap: 16px; align-items: stretch;
  grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr);
}
.app-shell .table-panel { display: flex; flex-direction: column; overflow: hidden; }
.app-shell .table-panel > * { flex-shrink: 0; }
.app-shell .table-panel > .table-scroll, .app-shell .panel-scroll {
  flex: 1 1 0; min-height: 0; overflow: auto; overscroll-behavior: contain;
}
.app-shell .table-scroll { scrollbar-gutter: stable; }
.app-shell .table-scroll thead { position: sticky; top: 0; z-index: 1; background: var(--panel); }
.app-shell .table-scroll th { padding: 10px 12px; }
.app-shell .table-scroll td { padding: 12px; }
.app-shell .table-scroll form > button { margin: 0; }
.app-shell .panel-heading { margin-bottom: 12px; }
.app-shell .panel-heading h2 { margin-bottom: 0; }
.app-shell .stats { margin: 0; gap: 10px; }
.app-shell .stats article { padding: 10px 15px; }
.app-shell .stats strong { font-size: 25px; margin: 2px 0; }
.app-shell .stats .small-value { font-size: 14px; }
.app-shell .stats small { font-size: 10px; }
.app-shell .stats.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.app-shell .footnote { font-size: 10px; }
.app-shell footer { align-items: center; padding: 0 22px; font-size: 9px; flex-wrap: nowrap; }
.app-shell footer span:last-child { margin-left: auto; width: auto; }
.app-shell .notice { margin: 0; padding: 8px 12px; max-height: 15dvh; overflow: auto; }
.app-shell .sidebar {
  width: var(--sidebar-width); padding: 24px 16px 16px; height: 100dvh;
  overflow: hidden; z-index: 1100;
}
.app-shell .sidebar .brand { flex-shrink: 0; font-size: 26px; }
.app-shell .nav-label { flex-shrink: 0; margin: 28px 12px 12px; }
.app-shell .sidebar nav { display: flex; flex-direction: column; overflow: auto; min-height: 0; margin: 0; flex: 1 1 0; }
.app-shell .sidebar nav a { flex-shrink: 0; white-space: normal; }
.sidebar-account { flex-shrink: 0; border-top: 1px solid var(--border); padding: 16px 10px 0; margin-top: 16px; }
.account-name { display: block; font-weight: 600; overflow-wrap: anywhere; max-height: 60px; overflow: auto; }
.sidebar-account > small { display: block; text-transform: capitalize; }
.account-actions-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 12px; font-size: 12px; }
.account-actions-row form { margin: 0; }
.sidebar-status { color: var(--muted); font-size: 10px; margin-top: 12px; }
.menu-toggle, .sidebar-close, .sidebar-backdrop { display: none; }
.accounts-panel-switch { display: none; }
.app-shell .account-actions, .app-shell .view-tabs {
  display: flex; flex-wrap: nowrap; overflow: auto; gap: 6px; margin: 0;
  min-width: 0; overscroll-behavior: contain; padding-bottom: 3px;
}
.app-shell .account-actions a, .app-shell .view-tabs a {
  flex-shrink: 0; padding: 8px 12px; white-space: nowrap; font-size: 12px;
  border: 1px solid var(--border); align-items: center;
}
.app-shell .account-actions a.selected, .app-shell .view-tabs a.selected { border-color: var(--accent); }
.device-heading-actions { display: flex; align-items: center; gap: 12px; }
.device-heading-actions .back-link { margin: 0; white-space: nowrap; }
.app-shell .location-panel { display: flex; flex-direction: column; }
.location-form { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: minmax(240px, .7fr) minmax(0, 1.3fr); gap: 24px; }
.location-fields { overflow: auto; min-height: 0; padding: 0 4px 4px; }
.location-fields label:first-child { margin-top: 0; }
.location-fields .muted { margin: 12px 0; }
.app-shell .location-form .edit-map { height: 100%; min-height: 180px; margin: 0; }
.app-shell .large-map { flex: 1 1 0; min-height: 0; height: auto; }
.app-shell #map-status { margin: 0; flex-shrink: 0; font-size: 12px; }
.public-shell .public-workspace { height: 100dvh; display: flex; flex-direction: column; }
.public-shell .content { flex: 1 1 0; }
.public-shell footer { flex-shrink: 0; padding: 10px 20px; }
/* Login keeps the brand in view and scrolls only inside the sign-in panel. */
.login-panel { height: 100dvh; min-height: 0; padding-top: 28px; padding-bottom: 18px; }
.login-panel > .brand, .login-footer { flex-shrink: 0; }
.login-copy { margin-top: clamp(16px, 4vh, 48px); flex-shrink: 0; }
.login-copy h1 { font-size: clamp(30px, 5vh, 49px); margin: 12px 0; }
.login-copy p { margin-bottom: 10px; }
.login-form { flex: 1 1 0; min-height: 0; overflow: auto; overscroll-behavior: contain; margin-top: 10px; padding-top: 16px; }
.login-form h2 { margin-bottom: 12px; }
.login-form label { margin-top: 12px; }
.login-form button { margin-top: 18px; }
.login-footer { margin-top: 0; padding-top: 16px; }
@media (max-width: 1100px) and (min-width: 721px) {
  .app-shell { --sidebar-width: 205px; }
  .app-shell .content { padding: 14px 16px; }
}
@media (max-width: 900px) {
  .app-shell .two-columns { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; }
  .location-form { display: flex; flex-direction: column; min-height: auto; }
  .location-fields { flex-shrink: 0; overflow: visible; }
  .app-shell .location-form .edit-map { flex: none; height: 260px; }
  .accounts-panel-switch { display: inline-flex; flex-shrink: 0; }
  .app-shell .accounts-layout { grid-template-rows: minmax(0, 1fr); }
  .accounts-layout:not(.accounts-list-view) > .accounts-list,
  .accounts-layout.accounts-list-view > .accounts-form { display: none; }
}
@media (max-width: 720px) {
  .app-shell .workspace { margin: 0; grid-template-rows: 38px minmax(0, 1fr) 22px; }
  .app-shell .topbar { padding: 0 12px; }
  .app-shell .topbar > .eyebrow { font-size: 8px; letter-spacing: 1px; }
  .app-shell .content { padding: 12px; gap: 10px; }
  .app-shell .page-heading h1 { font-size: 21px; }
  .app-shell .page-heading .eyebrow { font-size: 8px; }
  .app-shell .page-heading .button { padding: 6px 9px; min-height: 34px; }
  .app-shell .page-heading p { font-size: 11px; }
  .app-shell .panel { padding: 14px; }
  .app-shell .panel h2 { font-size: 15px; }
  .app-shell .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .app-shell .stats article { padding: 7px; }
  .app-shell .stats span { font-size: 10px; overflow-wrap: anywhere; }
  .app-shell .stats strong { font-size: 21px; }
  .app-shell .stats small { display: none; }
  .app-shell .stats .small-value { font-size: 11px; }
  .app-shell .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(290px, 85vw); padding: 18px;
    transform: translateX(-100%); visibility: hidden;
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); visibility: visible; }
  .app-shell .sidebar .brand { font-size: 26px; margin: 12px 0; }
  .app-shell .sidebar .brand small { display: block; }
  .app-shell .sidebar .nav-label { display: block; }
  .app-shell .sidebar nav a { font-size: 13px; padding: 12px; }
  .app-shell .sidebar nav a span { display: inline; }
  .menu-toggle, .sidebar-close { display: inline-flex; flex-shrink: 0; }
  .sidebar-close { align-self: flex-end; }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; background: #020a12aa; z-index: 1090; }
  .app-shell footer { padding: 0 12px; font-size: 8px; }
  .app-shell footer span:last-child { white-space: nowrap; letter-spacing: 0; }
  .app-shell .device-heading-actions { flex-direction: column; align-items: flex-end; gap: 5px; }
  .app-shell .panel-heading { gap: 8px; }
  .app-shell .form-row { gap: 8px; }
  .app-shell .form-row select { min-width: 0; }
  .app-shell .account-actions a, .app-shell .view-tabs a { font-size: 11px; padding: 7px 10px; }
  .login-panel { padding: 22px; }
  .login-copy { margin-top: 20px; }
  .login-footer { padding-top: 12px; }
}
@media (max-height: 600px) {
  .app-shell .content { padding-top: 8px; padding-bottom: 8px; gap: 7px; }
  .app-shell .page-heading .eyebrow, .app-shell .page-heading p, .app-shell .stats small, .app-shell .footnote { display: none; }
  .app-shell .page-heading h1 { font-size: 20px; margin: 0; }
  .app-shell .stats article { padding: 5px 10px; }
  .app-shell .stats strong { font-size: 20px; }
  .app-shell .stats .small-value { font-size: 11px; }
  .app-shell .sidebar { padding-top: 10px; padding-bottom: 10px; }
  .app-shell .nav-label { margin-top: 12px; }
  .sidebar-account { margin-top: 8px; padding-top: 8px; }
  .sidebar-status { display: none; }
  .login-copy { margin-top: 10px; }
  .login-copy .eyebrow, .login-copy p { display: none; }
  .login-copy h1 { font-size: 24px; margin: 8px 0; }
  .login-panel { padding-top: 14px; padding-bottom: 10px; }
  .login-panel .brand { font-size: 24px; }
  .login-panel .brand-symbol { font-size: 32px; }
  .login-footer { padding-top: 8px; }
}
@media (max-height: 500px) {
  .app-shell .stats:not(.compact) article { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .app-shell .panel { padding: 12px; }
  .app-shell .table-panel { overflow: auto; }
  .app-shell .table-panel > .table-scroll { flex: 1 0 120px; }
}
.capability-fields { margin: 16px 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.capability-fields legend { padding: 0 6px; font-size: 13px; }
.capability-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.capability-columns h3 { font-size: 13px; margin: 12px 0; }
.capability-fields .capability-choice { display: flex; align-items: center; gap: 9px; margin: 10px 0; cursor: pointer; }
.capability-choice input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0; flex: 0 0 18px; accent-color: var(--accent); }
.capability-summary { padding-left: 20px; line-height: 2; }
