:root {
  --bg-0: #f4f7fb;
  --bg-1: #e5ecf6;
  --bg-2: #d4e2f2;
  --card: #ffffff;
  --ink: #0f1c2e;
  --muted: #5a6b84;
  --border: #c7d4e7;
  --accent: #0059d6;
  --accent-2: #0182d9;
  --good: #16854d;
  --danger: #c62828;
  --warning: #d18a00;
  --critical: #8b1c1c;
  --shadow: 0 10px 30px rgba(20, 36, 62, 0.12);
}

[data-theme="dark"] {
  --bg-0: #0b1220;
  --bg-1: #111f33;
  --bg-2: #1a2b45;
  --card: #13253e;
  --ink: #e6edf8;
  --muted: #99abc8;
  --border: #2d4468;
  --accent: #2d8cff;
  --accent-2: #24a8ff;
  --good: #26ae6c;
  --danger: #e25555;
  --warning: #e3a82f;
  --critical: #ff7272;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(1, 130, 217, 0.18), transparent 34%),
    radial-gradient(circle at 95% 8%, rgba(0, 89, 214, 0.16), transparent 28%),
    linear-gradient(170deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
}

.shell {
  width: min(1024px, 95vw);
  margin: 18px auto 40px;
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  gap: 14px;
}

.app-shell {
  display: grid;
  gap: 12px;
  padding-bottom: 14px;
}

.brand-header {
  padding: 12px;
}

.brand-row {
  display: grid;
  gap: 10px;
}

.login-brand-grid {
  display: grid;
  gap: 12px;
}

.login-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.login-brand-copy {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 6px;
}

.login-customer-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.login-customer-text #customer-name {
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.login-customer-text .tiny {
  margin: 0;
}

.brand-logo.login-saas-logo {
  width: 100px;
  height: 100px;
  border-radius: 12px;
  align-self: center;
}

.brand-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.brand-strip-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
}

.brand-logo.brand-logo-saas {
  width: 100px;
  height: 100px;
  border-radius: 12px;
}

.brand-fallback {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.8);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0,0,0,0.14);
}

.topbar-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.topbar-brand-rail {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
}

.header-duty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}

.compact-header-row h1 {
  margin: 0;
  font-size: clamp(1rem, 3vw, 1.35rem);
}

#top-profile-edit,
#top-logout {
  border-color: var(--border);
  color: var(--ink);
}

#top-logout {
  min-width: 38px;
  min-height: 38px;
  padding: 7px;
}

.header-main-left {
  display: grid;
  align-items: start;
  gap: 4px;
  min-width: 0;
}

.header-meta-row {
  display: grid;
  gap: 8px;
}

.header-badge-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.header-action-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.role-badge-label {
  line-height: 1;
}

.role-badge-impersonating {
  cursor: pointer;
}

.role-impersonation-mark {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.1);
}

.role-impersonation-mark svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
}

#welcome {
  overflow-wrap: anywhere;
}

#welcome.welcome-long {
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
}

#welcome.welcome-xlong {
  font-size: clamp(0.95rem, 1.9vw, 1.25rem);
}

.header-main-right {
  margin-left: auto;
}

#top-owner-log {
  width: auto;
}

#self-role-badge {
  margin-left: 0;
}

#top-duty-toggle {
  min-width: 38px;
  min-height: 38px;
  padding: 7px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
}

#customer-name {
  font-size: 13px;
  color: #374151;
  text-transform: none;
  letter-spacing: 0;
}

h1 {
  margin: 2px 0 3px;
  font-size: clamp(1.3rem, 3.2vw, 2rem);
}

.login-brand-copy h1 {
  margin: 0;
  line-height: 1.05;
}

h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.section-title {
  margin: 10px 0 8px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.muted { color: var(--muted); margin: 0; }
.tiny { font-size: 12px; color: var(--muted); }
.error-line { color: var(--danger); font-weight: 700; }

.app-status {
  min-height: 16px;
  padding: 0 4px;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tab-btn {
  width: 100%;
  background: #edf3fb;
  border-color: #b7c6dd;
  color: #233248;
}

.tab-btn.active {
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: #1b6dd8;
  box-shadow: 0 2px 10px rgba(0, 89, 214, 0.26);
}

.app-status.error {
  color: var(--danger);
  font-weight: 700;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

label {
  font-size: 13px;
  color: var(--muted);
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  white-space: nowrap;
}

.inline-check.compact {
  margin: 0;
}

.inline-check input[type="checkbox"] {
  width: auto;
  min-width: 16px;
  max-width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

input, textarea, select {
  width: 100%;
  margin-top: 6px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  color: inherit;
  background: color-mix(in srgb, var(--card), #fff 30%);
}

input::placeholder,
textarea::placeholder {
  color: #6b7280;
  opacity: 1;
}

input.is-readonly {
  background: color-mix(in srgb, var(--bg-1), #fff 25%);
  color: var(--muted);
}

button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  transition: transform 100ms ease, filter 120ms ease, background 120ms ease;
}

button.secondary {
  background: #f5f8fc;
  border-color: #b7c6dd;
  color: #233248;
}

button.secondary.active {
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  border-color: #1b6dd8;
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 89, 214, 0.26);
}

button.ghost {
  width: auto;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
}

button:not(:disabled):hover {
  filter: brightness(1.04);
}

button:not(:disabled):active {
  transform: translateY(1px);
}

.theme-slider-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card), #fff 15%);
}

.theme-slider {
  width: 72px;
  margin: 0;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.role-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.card-collapse-toggle {
  width: auto;
  min-width: 34px;
  padding: 4px 8px;
}

.card-collapsible-body {
  display: grid;
  gap: 8px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--border);
}

.role-member { background: #ddf6e7; color: #0c5d31; border-color: #9ce0b6; }
.role-supervisor { background: #dfe9ff; color: #1e3f8a; border-color: #aec3ff; }
.role-owner { background: #fff1ce; color: #845200; border-color: #ffda88; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.analytics-grid {
  margin-top: 8px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px;
  background: linear-gradient(170deg, #ffffff, #eff5ff);
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-grid {
  display: grid;
  gap: 6px;
}

.badge {
  display: inline-block;
  margin-left: 0;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dff7e8;
  color: #135b33;
}

.badge.off {
  background: #e8eef8;
  color: #475a78;
}

.badge.severity-info {
  background: #deecff;
  color: #16417d;
}

.badge.severity-warning {
  background: #fff1cf;
  color: #885b00;
}

.badge.severity-critical {
  background: #ffd9d9;
  color: #7f1414;
}

.badge.status-monitoring {
  background: #dcefff;
  color: #1b4f8f;
}

.badge.status-contained {
  background: #fff3dd;
  color: #8a5a00;
}

.meter {
  margin-top: 8px;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e5eaf3;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  width: 0%;
  background: #0d66da;
  transition: width 180ms ease;
}

.meter > span.is-warning {
  background: #c47a00;
}

.meter > span.is-critical {
  background: #b71c1c;
}

.meter > span.is-efficient {
  background: #0f6b34;
}

.quick-actions {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.inline-actions {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.runtime-settings-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.runtime-setting-row {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--card), #eff5ff 55%);
}

.runtime-setting-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.runtime-setting-label {
  font-weight: 700;
  font-size: 13px;
}

.runtime-setting-source {
  font-size: 11px;
}

.runtime-setting-control {
  width: 100%;
}

.runtime-setting-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.history-toolbar {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.ops-optional {
  transition: opacity 120ms ease;
}

.tab-hidden {
  display: none !important;
}

.ops-hidden {
  display: none !important;
}

body.compact-mode .card {
  padding: 9px;
  border-radius: 10px;
}

body.compact-mode .list {
  gap: 5px;
}

body.compact-mode .list li {
  padding: 7px;
}

body.compact-mode .stat {
  padding: 6px;
}

body.compact-mode .stat-value {
  font-size: 16px;
}

body.compact-mode .tiny {
  font-size: 11px;
}

body.compact-mode .mini-btn {
  padding: 5px 8px;
  min-height: 30px;
}

body.compact-mode .dense-table th,
body.compact-mode .dense-table td {
  padding: 6px;
  font-size: 11px;
}

.critical-banner {
  border-color: #f3b1b1;
  background: linear-gradient(160deg, #fff0f0, #ffe2e2);
}

#impersonation-banner {
  border-color: #f2d48a;
  background: linear-gradient(160deg, #fff8e6, #fff0c7);
}

.impersonation-footer {
  order: 200;
  grid-column: 1 / -1;
}

.history-filters {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

#team-card .history-filters {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

#team-card .inline-actions {
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 6px;
}

#team-card .inline-actions .secondary {
  min-height: 52px;
  font-size: 14px;
}

.team-duty-grid {
  display: grid;
  gap: 10px;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.list li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: color-mix(in srgb, var(--card), #eff5ff 55%);
  min-width: 0;
}

.list li.empty {
  color: var(--muted);
  font-style: italic;
}

.list li.activity-critical {
  border-left: 4px solid #b91c1c;
  background: #fff3f3;
}

.list li.activity-warning {
  border-left: 4px solid #d18a00;
  background: #fff7e5;
}

.list li.activity-medical {
  border-left: 4px solid #d4a216;
  background: #fff7d6;
}

.list li.activity-sweep {
  border-left: 4px solid #1d4ed8;
  background: #edf4ff;
}

.list li.activity-info {
  border-left: 4px solid #0e7490;
  background: #edf9ff;
}

.user-manage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.user-meta {
  min-width: 0;
}

.user-name-marked {
  position: relative;
  display: inline-block;
  padding-right: 14px;
}

.impersonation-name-badge {
  position: absolute;
  right: -2px;
  top: -7px;
  width: 15px;
  height: 15px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #eef4ff;
  border: 1px solid #90a7d6;
  color: #2c436a;
}

.impersonation-name-badge svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.mini-btn {
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.action-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.action-icon-btn {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 7px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #b7c6dd;
  border-radius: 10px;
  background: #f5f8fc;
  color: #233248;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.action-icon-btn.secondary {
  background: #f5f8fc;
  border-color: #b7c6dd;
  color: #233248;
}

.action-icon-btn:hover {
  background: #eaf1fb;
}

.action-icon-btn.ok {
  background: #f5f8fc;
  border-color: #b7c6dd;
  color: #233248;
}

.action-icon-btn.ok:hover {
  background: #eaf1fb;
  border-color: #b7c6dd;
}

.action-icon-btn.danger {
  background: #f5f8fc;
  border-color: #b7c6dd;
  color: #233248;
}

.action-icon-btn.danger:hover {
  background: #eaf1fb;
  border-color: #b7c6dd;
}

.action-duty-btn {
  color: #334155;
}

.action-dm-btn {
  min-width: 46px;
  width: 46px;
  min-height: 36px;
  padding: 6px 8px;
}

.action-pill svg,
.action-icon-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-btn {
  min-width: 38px;
  min-height: 38px;
  padding: 7px;
  font-size: 14px;
  line-height: 1;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.form-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.composer-meta-row {
  display: grid;
  grid-template-columns: auto minmax(170px, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.composer-meta-row label[for="team-message-scope"] {
  margin: 0;
  white-space: nowrap;
}

#team-message-scope {
  margin: 0;
  justify-self: end;
  width: min(260px, 100%);
}

[data-theme="dark"] .action-icon-btn,
[data-theme="dark"] .action-icon-btn.secondary {
  background: #243850;
  border-color: #3f5b7f;
  color: #dbe8fb;
}

[data-theme="dark"] button.secondary {
  background: #243850;
  border-color: #3f5b7f;
  color: #dbe8fb;
}

[data-theme="dark"] button.secondary.active {
  background: linear-gradient(92deg, #1d4ed8, #2563eb);
  border-color: #5da7ff;
  color: #f8fbff;
  box-shadow: 0 2px 10px rgba(45, 140, 255, 0.32);
}

[data-theme="dark"] .tabbar .tab-btn {
  background: #22354f;
  border-color: #3f5b7f;
  color: #dbe8fb;
}

[data-theme="dark"] .tabbar .tab-btn.active {
  border-color: #5da7ff;
  box-shadow: 0 2px 10px rgba(45, 140, 255, 0.32);
}

[data-theme="dark"] .action-icon-btn:hover,
[data-theme="dark"] .action-icon-btn.secondary:hover {
  background: #2a4260;
}

[data-theme="dark"] .list li {
  background: #1a2e47;
  border-color: #35506f;
}

[data-theme="dark"] .list li.activity-critical,
[data-theme="dark"] #incident-list li.incident-tone-critical {
  background: #3c1f2a;
}

[data-theme="dark"] .list li.activity-warning,
[data-theme="dark"] .list li.activity-medical,
[data-theme="dark"] #incident-list li.incident-tone-medical {
  background: #3b3421;
}

[data-theme="dark"] .list li.activity-sweep,
[data-theme="dark"] #incident-list li.incident-tone-security {
  background: #1b2d4a;
}

[data-theme="dark"] .list li.activity-info,
[data-theme="dark"] #incident-list li.incident-tone-other {
  background: #1f3646;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #c0cde3;
  opacity: 1;
}

.command-item {
  width: 100%;
  justify-content: flex-start;
}

#admin-history-card .list li,
#owner-audit-card .list li,
#notification-list li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.dense-table td {
  max-width: 300px;
  overflow-wrap: anywhere;
}

.mini-btn.danger {
  background: var(--danger);
}

.mini-btn.ok {
  background: var(--good);
}

.incident-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.incident-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
  align-items: center;
}

#manage-team-list .incident-actions .mini-btn {
  min-height: 36px;
}

#manage-team-list .incident-actions {
  justify-content: flex-end;
}

#incident-list li.incident-tone-critical {
  border-left: 4px solid #b91c1c;
  background: #fff1f1;
}

#incident-list li.incident-tone-medical {
  border-left: 4px solid #d4a216;
  background: #fff8df;
}

#incident-list li.incident-tone-security {
  border-left: 4px solid #1d4ed8;
  background: #eff5ff;
}

#incident-list li.incident-tone-other {
  border-left: 4px solid #d2dae8;
  background: #f6f9ff;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 26, 0.56);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 80;
}

.modal-panel {
  width: min(740px, 96vw);
  max-height: 86vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--card);
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  display: grid;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 8px;
}

.dense-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-size: 12px;
}

.dense-table th,
.dense-table td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 8px;
  vertical-align: top;
}

.dense-table th {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  color: var(--muted);
  background: color-mix(in srgb, var(--card), #fff 15%);
}

#incident-command-rail {
  position: static;
}

.mobile-dock {
  display: none;
}

.quick-float-nav {
  position: fixed;
  right: 12px;
  top: 120px;
  z-index: 66;
  display: grid;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card), #fff 8%);
  box-shadow: 0 8px 20px rgba(20, 36, 62, 0.16);
  backdrop-filter: blur(6px);
}

.quick-float-nav .icon-btn {
  min-width: 34px;
  min-height: 34px;
  padding: 6px;
  border-radius: 10px;
}

.quick-float-nav .icon-btn svg {
  width: 16px;
  height: 16px;
}

.version-footer {
  text-align: center;
  padding: 8px 0 14px;
}

.hidden { display: none; }
.dev-link-wrap { margin-top: 6px; }

.install-help-card {
  padding-top: 10px;
  padding-bottom: 10px;
}

.install-help-inline {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

#install-help-summary {
  margin: 0;
}

#install-availability {
  margin: 6px 0 0;
}

.install-help-icon-btn {
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

#install-help-details {
  margin-top: 8px;
  line-height: 1.45;
}

.compact-pager {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.compact-pager .mini-btn {
  min-width: 34px;
  padding: 4px 8px;
}

#owner-email-events-list {
  min-width: 0;
}

#owner-email-events-list li {
  overflow: hidden;
}

.event-detail {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#incident-create-card {
  scroll-margin-top: 10px;
}

.mention-suggest {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  padding: 6px;
  display: grid;
  gap: 6px;
  margin: -4px 0 8px;
}

.mention-suggest button {
  width: 100%;
  text-align: left;
  border-radius: 8px;
  padding: 7px 9px;
  background: #334155;
  color: #fff;
}

@media (min-width: 920px) {
  .app-shell {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .topbar,
  .app-status,
  .actions,
  #incidents-card,
  #incident-command-rail,
  #incident-create-card,
  #recent-activity-card,
  #incident-timeline-stream,
  #plan-usage-card,
  #runtime-settings-card,
  #owner-email-events-card,
  #notification-card,
  #admin-history-card,
  #owner-audit-card,
  #admin-sessions-card {
    grid-column: 1 / -1;
  }

  #member-message-card {
    grid-column: 1 / 2;
  }

  #team-card {
    grid-column: 1 / -1;
  }

  #team-card .team-duty-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 12px;
  }

  #team-card.team-duty-single .team-duty-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .header-duty {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
  }

  .header-main-left {
    min-width: 0;
  }

  .header-meta-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .header-action-row {
    flex-wrap: nowrap;
  }

  .header-main-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  #top-owner-log {
    margin-left: 0;
    white-space: nowrap;
  }

  #incident-timeline-stream {
    order: 99;
  }

  .history-filters {
    grid-template-columns: 2fr 1fr 1fr auto;
    align-items: end;
  }

  #incidents-card .history-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
  }

  #incident-search {
    grid-column: 1 / span 2;
  }

  #incident-sort {
    grid-column: 3;
  }

  #incident-filter-status {
    grid-column: 4;
  }

  #incident-filter-severity {
    grid-column: 1;
  }

  #incident-filter-owner {
    grid-column: 2;
  }

  #incident-filter-reset {
    grid-column: 3 / span 2;
    align-self: end;
    min-height: 48px;
  }

  .quick-actions {
    grid-template-columns: 1fr 1fr;
  }

  .history-toolbar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    gap: 10px;
    padding-bottom: calc(108px + env(safe-area-inset-bottom));
  }

  .tabbar {
    display: none;
  }

  .tab-btn {
    min-height: 42px;
    font-size: 13px;
    padding: 10px 8px;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
  }

  .actions button {
    min-height: 46px;
    font-size: 15px;
  }

  .mini-btn {
    min-height: 36px;
    font-size: 12px;
  }

  .composer-meta-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 6px;
  }

  #team-message-scope {
    justify-self: stretch;
    width: 100%;
  }

  .stats-grid {
    gap: 6px;
  }

  .stat {
    padding: 8px;
  }

  .stat-value {
    font-size: 18px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 10px;
  }

  .topbar-brand-rail {
    justify-content: flex-end;
    align-items: flex-start;
  }

  .header-meta-row {
    display: grid;
    gap: 8px;
  }

  .header-badge-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .header-action-row {
    display: grid;
    grid-template-columns: repeat(4, 56px);
    gap: 8px;
    justify-content: start;
  }

  .header-action-row > button {
    width: 56px;
    min-width: 56px;
    justify-self: start;
  }

  #top-impersonation {
    display: none !important;
  }

  .brand-logo.brand-logo-saas {
    width: 100px;
    height: 100px;
  }

  .brand-logo.login-saas-logo {
    width: 100px;
    height: 100px;
  }

  #welcome.welcome-long {
    font-size: clamp(1rem, 5.2vw, 1.2rem);
  }

  #welcome.welcome-xlong {
    font-size: clamp(0.9rem, 4.6vw, 1.05rem);
  }

  #team-card .history-filters {
    grid-template-columns: 1fr;
  }

  #team-card .inline-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .theme-slider-wrap {
    width: fit-content;
  }

  .mobile-dock {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 70;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
    background: color-mix(in srgb, var(--card), #fff 10%);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    font-size: 16px;
  }

  .quick-float-nav {
    top: auto !important;
    right: 10px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    z-index: 69;
    padding: 5px;
  }

  .quick-float-nav .icon-btn {
    min-width: 32px;
    min-height: 32px;
    padding: 5px;
  }

  .mobile-dock .mini-btn {
    min-height: 48px;
    font-size: clamp(12px, 3.1vw, 15px);
    padding: 8px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #334155;
    color: #dbe4f0;
    border: 1px solid #2c3d53;
  }

  .mobile-dock .mini-btn.active {
    background: linear-gradient(92deg, var(--accent), var(--accent-2));
    color: #ffffff;
    border-color: transparent;
  }

  input,
  textarea,
  select {
    font-size: 16px;
  }
}

@media (min-width: 1240px) {
  #incidents-card .history-filters {
    grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(130px, 1fr)) minmax(160px, auto);
  }

  #incident-search,
  #incident-sort,
  #incident-filter-status,
  #incident-filter-severity,
  #incident-filter-owner,
  #incident-filter-reset {
    grid-column: auto;
  }

  .brand-logo.brand-logo-saas {
    width: 100px;
    height: 100px;
  }

  .brand-logo.login-saas-logo {
    width: 100px;
    height: 100px;
  }
}
