/*
 * Giasafox visual system, v2.3.1.
 *
 * Design goals:
 * - Mobile-first, compact and calm.
 * - Strong hierarchy without oversized cards or decorative clutter.
 * - Status colours only where they carry operational meaning.
 * - No external fonts, icon CDNs or UI frameworks.
 */
:root {
  --bg: #08111f;
  --panel: #0f1b2c;
  --panel-raised: #132238;
  --panel-soft: #0b1727;
  --line: #24364d;
  --line-soft: rgba(145, 163, 186, .15);
  --text: #f5f8fc;
  --muted: #93a4b9;
  --blue: #69aefc;
  --green: #48d39b;
  --yellow: #f5ba4a;
  --red: #ff6b78;
  --shadow: 0 12px 32px rgba(0, 0, 0, .18);
  --radius: 16px;
  --radius-small: 11px;
}

* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 12% 0, rgba(40, 86, 139, .23), transparent 30%), var(--bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p, dl, dd { margin: 0; }
small, .muted { color: var(--muted); }

.app-shell { width: min(1380px, 100%); margin: auto; padding: 14px 14px 96px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; }
.brand-block { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 43px; height: 43px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(145deg, #78b5fa, #3d72ad); font-size: .85rem; font-weight: 900; letter-spacing: .04em; box-shadow: 0 8px 22px rgba(30, 88, 151, .28); }
.brand-copy { min-width: 0; }
.title-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-block h1 { font-size: clamp(1.1rem, 2.4vw, 1.55rem); white-space: nowrap; }
.app-version { color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.brand-block p { margin-top: 3px; color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58vw; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.health-pill { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid var(--line); background: rgba(15, 27, 44, .86); border-radius: 999px; font-size: .76rem; }
.health-pill > span { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }

/*
 * SVG safety rail:
 * Inline icons carry explicit dimensions in icons.js, and these rules prevent
 * a browser, inherited rule or future component from stretching them.
 */
.svg-icon {
  display: block;
  width: 18px !important;
  height: 18px !important;
  max-width: 18px;
  max-height: 18px;
  flex: 0 0 18px;
  overflow: visible;
}
.desktop-nav { display: none; gap: 3px; }
.desktop-nav button, .mobile-nav button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.desktop-nav button { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 9px; font-size: .8rem; }
.desktop-nav button .svg-icon { width: 16px; height: 16px; }
.desktop-nav button.active { background: var(--panel-raised); color: var(--text); }

.page { display: none; }
.page.active { display: block; }
.eyebrow { text-transform: uppercase; letter-spacing: .13em; font-size: .65rem; color: #7fb8f8; font-weight: 800; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 20px 1px 9px; }
.section-heading h2, .section-heading h3 { margin-top: 3px; }
.section-heading h2 { font-size: clamp(1.35rem, 3vw, 1.85rem); }
.section-heading h3 { font-size: 1rem; }
.section-heading > small { text-align: right; font-size: .72rem; }
.page-title { margin-top: 3px; }
.home-heading { margin-bottom: 10px; }

.service-health-grid { display: grid; gap: 11px; }
.service-card { position: relative; overflow: hidden; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(150deg, rgba(19, 34, 56, .96), rgba(12, 24, 40, .97)); box-shadow: var(--shadow); }
.service-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--green); }
.service-critical::before { background: var(--red); }
.service-attention::before { background: var(--yellow); }
.service-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.service-name { display: flex; align-items: center; gap: 10px; }
.service-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  max-width: 36px;
  max-height: 36px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--blue);
  background: var(--panel-soft);
}
.service-icon .svg-icon {
  width: 20px !important;
  height: 20px !important;
  max-width: 20px;
  max-height: 20px;
  flex-basis: 20px;
}
.service-name h3 { margin-top: 2px; font-size: 1.02rem; }
.service-status { padding: 5px 8px; border-radius: 999px; font-size: .67rem; font-weight: 800; color: var(--green); background: rgba(72, 211, 155, .09); }
.service-status.status-critical { color: var(--red); background: rgba(255, 107, 120, .09); }
.service-status.status-attention { color: var(--yellow); background: rgba(245, 186, 74, .09); }
.service-reason { min-height: 2.75em; margin: 13px 0; color: #c3cfdd; font-size: .83rem; line-height: 1.5; }
.service-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.service-facts div { padding: 8px 9px; border: 1px solid var(--line-soft); border-radius: 9px; background: rgba(6, 16, 29, .25); }
.service-facts dt { color: var(--muted); font-size: .66rem; }
.service-facts dd { margin-top: 3px; font-size: .77rem; font-weight: 700; line-height: 1.35; }
.service-link { margin-top: 12px; padding: 0; border: 0; background: transparent; color: var(--blue); cursor: pointer; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 15px; }
.metric-card, .panel, .incident-card, .source-card, .timeline-item { border: 1px solid var(--line); background: linear-gradient(155deg, rgba(18, 33, 54, .96), rgba(11, 23, 39, .97)); border-radius: var(--radius); }
.metric-card { padding: 13px 14px; min-width: 0; }
.metric-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .72rem; }
.metric-label .svg-icon { width: 15px; height: 15px; }
.metric-card strong { display: block; margin-top: 6px; font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1; }
.tone-good { color: var(--green); }
.tone-warn { color: var(--yellow); }
.tone-bad { color: var(--red); }
.tone-info { color: var(--blue); }

.text-button, .service-link { display: inline-flex; align-items: center; gap: 6px; }
.text-button { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: .75rem; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.icon-button .svg-icon { width: 16px; height: 16px; }
.incident-list { display: grid; gap: 8px; }
.incident-card { display: grid; grid-template-columns: 4px 1fr auto; gap: 11px; padding: 12px; overflow: hidden; }
.severity-bar { border-radius: 99px; }
.incident-card h4 { margin: 0 0 6px; font-size: .85rem; line-height: 1.42; }
.incident-topline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.incident-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; color: var(--muted); font-size: .68rem; }
.incident-count { align-self: center; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-soft); font-size: .72rem; font-weight: 800; }
.status-badge { padding: 4px 7px; border-radius: 999px; background: #102338; font-size: .64rem; font-weight: 800; }
.status-badge.ok { color: var(--green); }
.status-badge.bad { color: var(--red); }
.status-new { color: #aa94ff; }
.status-active { color: var(--red); }
.status-recurring { color: var(--yellow); }
.status-quiet { color: var(--blue); }
.status-resolved { color: var(--green); }
.status-historical { color: var(--muted); }
.new-count { color: var(--blue); font-size: .64rem; font-weight: 800; }

.timeline-list { display: grid; gap: 7px; }
.timeline-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-left: 3px solid var(--line); }
.timeline-icon { width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); border-radius: 9px; background: var(--panel-soft); }
.timeline-icon .svg-icon { width: 16px; height: 16px; }
.timeline-item b { display: block; font-size: .8rem; }
.timeline-item small { display: block; margin-top: 2px; font-size: .69rem; }
.tone-border-good { border-left-color: var(--green); }
.tone-border-warn { border-left-color: var(--yellow); }
.tone-border-bad { border-left-color: var(--red); }
.tone-border-info { border-left-color: var(--blue); }

.filter-panel { display: grid; gap: 10px; margin-bottom: 13px; }
.search-field span, .field-label { display: block; margin: 0 0 5px 3px; color: var(--muted); font-size: .7rem; }
.search-field input, .export-range input { width: 100%; border: 1px solid var(--line); background: var(--panel-soft); color: var(--text); border-radius: 10px; padding: 10px 12px; outline: none; }
.search-field input:focus, .export-range input:focus { border-color: var(--blue); }
.chips, .period-toolbar { display: flex; gap: 6px; overflow: auto; padding-bottom: 2px; }
.chip, .period-toolbar button { border: 1px solid var(--line); background: var(--panel); color: var(--muted); padding: 7px 9px; border-radius: 999px; cursor: pointer; white-space: nowrap; font-size: .72rem; }
.chip.active, .period-toolbar button.active { color: var(--text); border-color: #487db6; background: #173052; }
.period-toolbar { margin: 0 0 12px; }

.chart-grid { display: grid; gap: 10px; }
.panel { padding: 14px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--blue); border: 1px solid var(--line); border-radius: 10px; }
.chart-panel canvas { width: 100%; height: 235px; margin-top: 10px; }

.contacts-layout { display: grid; gap: 11px; }
.record-list { display: grid; gap: 8px; margin-top: 12px; }
.record-card { padding: 11px; border: 1px solid var(--line-soft); border-radius: var(--radius-small); background: rgba(7, 17, 31, .34); }
.record-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.record-title b { font-size: .78rem; }
.record-title span { color: var(--muted); font-size: .65rem; white-space: nowrap; }
.record-card p { margin-top: 7px; color: #c5d0dc; font-size: .75rem; line-height: 1.45; }
.record-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 7px; color: var(--muted); font-size: .66rem; }
.spam-record { border-left: 2px solid rgba(255, 107, 120, .65); }

.quick-links { display: grid; gap: 8px; margin-bottom: 17px; }
.quick-link { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 11px 12px; color: var(--text); text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; }
.quick-link.static { cursor: default; }
.quick-link > .svg-icon { color: var(--blue); }
.quick-link span b, .quick-link span small { display: block; }
.quick-link span b { font-size: .78rem; }
.quick-link span small { margin-top: 2px; font-size: .66rem; }
.source-grid { display: grid; gap: 8px; }
.source-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; }
.source-identity { display: flex; align-items: center; gap: 9px; min-width: 0; }
.source-identity > .svg-icon { color: var(--blue); }
.source-card b { display: block; font-size: .76rem; overflow-wrap: anywhere; }
.source-card small { display: block; margin-top: 2px; font-size: .65rem; }

.export-panel { margin-top: 13px; }
.export-panel h3 { margin-top: 3px; }
.export-panel > p { margin-top: 7px; font-size: .76rem; line-height: 1.5; }
.export-range { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.export-range label span { display: block; margin: 0 0 5px 2px; color: var(--muted); font-size: .68rem; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.primary-button, .secondary-button { border-radius: 10px; padding: 9px 11px; font-size: .74rem; font-weight: 800; cursor: pointer; }
.primary-button { border: 0; background: var(--blue); color: #07111f; }
.secondary-button { border: 1px solid #477bb4; background: #153053; color: var(--text); }
.export-note { display: block; margin-top: 9px; font-size: .66rem; line-height: 1.4; }
.empty { padding: 18px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); font-size: .78rem; }
.success-empty { color: var(--green); border-color: rgba(72, 211, 155, .3); }

.loading-screen { position: fixed; inset: 0; z-index: 1000; display: grid; place-content: center; gap: 10px; text-align: center; background: rgba(8, 17, 31, .97); }
.loading-screen.hide { display: none; }
.spinner { width: 37px; height: 37px; margin: auto; border: 3px solid #1c3554; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Fixed mobile navigation: compact, thumb-friendly and immune to SVG stretching. */
.mobile-nav {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  height: 66px;
  padding: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(10, 22, 38, .96);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.mobile-nav button {
  min-width: 0;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 3px;
  overflow: hidden;
  border-radius: 11px;
  font-size: .63rem;
  line-height: 1;
}
.mobile-nav button .svg-icon {
  width: 20px !important;
  height: 20px !important;
  max-width: 20px;
  max-height: 20px;
  flex: 0 0 20px;
}
.mobile-nav button span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-nav button.active { color: var(--text); background: #173052; }

@media (min-width: 620px) {
  .service-health-grid, .contacts-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 800px) {
  .app-shell { padding: 24px 24px 46px; }
  .desktop-nav { display: flex; }
  .mobile-nav { display: none; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-panel { grid-template-columns: minmax(280px, 1fr) auto; align-items: end; }
}

@media (min-width: 1040px) {
  .incident-filters { grid-template-columns: minmax(260px, 1fr) auto auto; }
  .service-card { padding: 18px; }
}

@media (max-width: 560px) {
  .app-shell { padding: 12px 12px 92px; }
  .topbar { align-items: center; gap: 8px; margin-bottom: 12px; }
  .brand-block { gap: 9px; min-width: 0; }
  .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
  .brand-copy { flex: 1 1 auto; min-width: 0; }
  .title-row { gap: 6px; flex-wrap: nowrap; }
  .brand-block h1 { min-width: 0; font-size: 1.12rem; overflow: hidden; text-overflow: ellipsis; }
  .app-version { font-size: .6rem; }
  .brand-block p { max-width: 100%; font-size: .7rem; }
  .topbar-actions { flex: 0 0 auto; }
  .health-pill { width: 38px; height: 38px; justify-content: center; padding: 0; }
  .health-pill b { display: none; }
  .section-heading { align-items: flex-start; gap: 8px; margin-top: 16px; }
  .section-heading > small { max-width: 48%; font-size: .68rem; line-height: 1.35; }
  .section-heading h2 { font-size: 1.35rem; }
  .service-health-grid { gap: 9px; }
  .service-card { padding: 13px; border-radius: 14px; }
  .service-card-top { align-items: center; }
  .service-name { min-width: 0; gap: 9px; }
  .service-name > div { min-width: 0; }
  .service-name h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .service-reason { min-height: 0; margin: 10px 0; font-size: .78rem; }
  .service-facts { grid-template-columns: 1fr 1fr; gap: 7px; }
  .service-facts div { padding: 7px 8px; }
  .incident-card { grid-template-columns: 4px 1fr; }
  .incident-count { grid-column: 2; justify-self: start; }
  .export-actions > button { width: 100%; }
}

/* ========================================================================
 * v2.3.2 MOBILE REDESIGN
 *
 * These rules intentionally override the generic component styles above.
 * The mobile dashboard must be scannable, not a squeezed desktop page.
 * Keep this block at the end of the file so its constraints always win.
 * ====================================================================== */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (max-width: 619px) {
  body { font-size: 14px; }
  .app-shell { padding: 12px 12px 84px; }

  /* Compact header. Version remains beside the title, never on its own row. */
  .topbar { align-items: center; gap: 8px; margin-bottom: 12px; }
  .brand-block { gap: 9px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 10px; font-size: 12px; }
  .title-row { gap: 6px; flex-wrap: nowrap; }
  .brand-block h1 { font-size: 19px; line-height: 1.15; }
  .app-version { font-size: 10px; }
  .brand-block p {
    max-width: calc(100vw - 104px);
    margin-top: 2px;
    font-size: 11px;
  }
  .health-pill { width: 34px; height: 34px; padding: 0; justify-content: center; }
  .health-pill > span { width: 9px; height: 9px; }

  /* Page headings stay readable without consuming half the viewport. */
  .section-heading { margin: 16px 0 8px; align-items: flex-end; }
  .section-heading h2 { font-size: 24px; line-height: 1.08; }
  .section-heading h3 { font-size: 17px; line-height: 1.15; }
  .section-heading > small { max-width: 48%; font-size: 11px; line-height: 1.3; }
  .eyebrow { font-size: 10px; letter-spacing: .14em; }

  /* One distinct service card per system. No free-floating text. */
  .service-health-grid { gap: 10px; }
  .service-card {
    padding: 13px 13px 12px;
    border-radius: 14px;
    background: linear-gradient(155deg, #13243a, #0c192b);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .16);
  }
  .service-card-top { align-items: center; }
  .service-name { min-width: 0; gap: 9px; }
  .service-icon {
    width: 32px; height: 32px;
    min-width: 32px; min-height: 32px;
    max-width: 32px; max-height: 32px;
    border-radius: 9px;
  }
  .service-icon .svg-icon { width: 17px !important; height: 17px !important; }
  .service-name h3 { font-size: 16px; line-height: 1.15; }
  .service-status { flex: 0 0 auto; padding: 5px 7px; font-size: 10px; }
  .service-reason {
    min-height: 0;
    margin: 10px 0;
    font-size: 13px;
    line-height: 1.38;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
  .service-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .service-facts div { min-width: 0; padding: 7px 8px; }
  .service-facts dt { font-size: 10px; line-height: 1.2; }
  .service-facts dd {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.25;
    text-align: left;
    overflow-wrap: anywhere;
  }
  .service-link {
    margin-top: 10px;
    padding: 7px 9px;
    border: 1px solid rgba(105, 174, 252, .28);
    border-radius: 9px;
    background: rgba(105, 174, 252, .08);
    color: var(--blue);
    font-size: 12px;
  }

  /* Priority incidents are summaries. Full details belong in Incidents. */
  .incident-list { gap: 8px; }
  .incident-card {
    grid-template-columns: 3px minmax(0, 1fr) auto;
    gap: 9px;
    padding: 11px;
    border-radius: 14px;
  }
  .incident-card h4 {
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.38;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
  .incident-topline { gap: 5px; margin-bottom: 5px; }
  .status-badge, .new-count { font-size: 10px; }
  .incident-meta { gap: 4px 8px; font-size: 10px; line-height: 1.3; }
  .incident-count { align-self: start; padding: 4px 7px; font-size: 11px; }

  /* Home metrics remain compact and readable. */
  .metric-grid { gap: 7px; margin-bottom: 12px; }
  .metric-card { padding: 10px; border-radius: 12px; }
  .metric-label { font-size: 10px; gap: 5px; }
  .metric-card strong { margin-top: 5px; font-size: 22px; }

  /* Timeline and records use restrained typography on narrow screens. */
  .timeline-item { padding: 9px 10px; }
  .timeline-item b { font-size: 12px; }
  .timeline-item small { font-size: 10px; }
  .panel { padding: 11px; border-radius: 14px; }
  .record-card { padding: 9px; }
  .record-card p { font-size: 12px; }

  /* Fixed bottom bar, compact enough to leave the content visible. */
  .mobile-nav {
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    height: 58px;
    padding: 4px;
    border-radius: 15px;
  }
  .mobile-nav button {
    min-height: 48px;
    gap: 3px;
    padding: 5px 2px;
    border-radius: 10px;
    font-size: 10px;
  }
  .mobile-nav button .svg-icon {
    width: 18px !important;
    height: 18px !important;
    max-width: 18px;
    max-height: 18px;
  }
}

/* ========================================================================
 * v2.4.0 MOBILE-FIRST REBUILD
 *
 * Why this block exists:
 * Android browsers may keep an old app.css/app.js even after index.html is
 * replaced. index.html now loads every asset with ?v=2.4.0. The rules below
 * also make the Home DOM deterministic on narrow screens, so desktop grid
 * rules cannot leak into the mobile presentation.
 * ====================================================================== */
@media (max-width: 619px) {
  .home-heading {
    display: block;
    margin-bottom: 12px;
  }
  .home-heading > small {
    display: block;
    max-width: none;
    margin-top: 5px;
    text-align: left;
  }

  .service-health-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    gap: 10px;
  }
  .service-card {
    display: block !important;
    width: 100%;
    min-width: 0;
    padding: 13px !important;
    overflow: hidden;
    border: 1px solid var(--line) !important;
    border-radius: 14px !important;
    background: linear-gradient(155deg, #13243a, #0c192b) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .16) !important;
  }
  .service-card-top {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 10px;
  }
  .service-name {
    display: flex !important;
    align-items: center;
    min-width: 0;
  }
  .service-status {
    display: inline-flex !important;
    align-items: center;
    white-space: nowrap;
  }
  .service-reason-block {
    margin: 11px 0 10px;
    padding: 9px 10px;
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    background: rgba(5, 15, 27, .28);
  }
  .service-reason-block > span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
  }
  .service-reason {
    display: -webkit-box !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .service-facts {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin: 0;
  }
  .service-facts div {
    display: block !important;
    min-width: 0;
    padding: 8px !important;
    text-align: left !important;
  }
  .service-facts dt,
  .service-facts dd {
    text-align: left !important;
  }
  .service-link {
    appearance: none;
    display: inline-flex !important;
    align-items: center;
    width: auto;
    margin-top: 10px;
    padding: 8px 10px !important;
    border: 1px solid rgba(105, 174, 252, .34) !important;
    border-radius: 9px !important;
    background: rgba(105, 174, 252, .10) !important;
    color: var(--blue) !important;
    font-size: 12px !important;
  }

  .priority-list .incident-card:nth-child(n+3) { display: none; }

  .timeline-list {
    display: grid !important;
    gap: 7px;
  }
  .timeline-item {
    display: grid !important;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    min-width: 0;
    padding: 9px 10px !important;
  }
  .timeline-icon {
    width: 22px;
    height: 22px;
  }
  .timeline-item > div { min-width: 0; }
  .timeline-item b,
  .timeline-item small {
    display: block !important;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .timeline-item small { margin-top: 3px !important; }

  .overview-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Reserve enough room for Android's browser/system bars and our nav. */
  .app-shell {
    padding-bottom: calc(92px + env(safe-area-inset-bottom)) !important;
  }
}


/* ========================================================================== 
   v2.5.0: official Hotel IDI branding and contact/spam workspace
   ========================================================================== */

/* The logo artwork contains dark lettering, so it sits on a quiet warm panel. */
.brand-logo-wrap {
  width: 58px;
  height: 58px;
  padding: 7px;
  border-radius: 16px;
  background: #f5efe1;
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 10px 28px rgba(0,0,0,.18);
  overflow: hidden;
}
.brand-logo-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.contact-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 18px;
}
.contact-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}
.contact-tabs button {
  min-height: 38px;
  padding: 0 13px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.contact-tabs button.active {
  background: rgba(93,164,255,.16);
  color: var(--text);
}
.contact-tabs span {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  font-size: .78rem;
}
.contact-search { flex: 1; max-width: 420px; }
.contact-search input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5,15,29,.55);
  color: var(--text);
  font: inherit;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.data-panel[hidden] { display: none !important; }

@media (max-width: 700px) {
  .brand-logo-wrap {
    width: 52px;
    height: 52px;
    padding: 6px;
    border-radius: 14px;
  }
  .contact-toolbar {
    align-items: stretch;
    flex-direction: column;
    margin-top: 10px;
  }
  .contact-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 64px;
  }
  .contact-tabs button { padding: 0 6px; font-size: .84rem; }
  .contact-search { max-width: none; }
  .contacts-layout { grid-template-columns: 1fr; }
  .record-card p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
}

/* ========================================================================== 
   v2.6.0: branding containment and dashboard stability
   ========================================================================== */

/*
 * The official logo must never participate in page layout outside the header.
 * Width/height/max-size/position are deliberately repeated here as a defensive
 * boundary against stale browser CSS and future generic img rules.
 */
.brand-block {
  position: relative;
  isolation: isolate;
}
.brand-logo-wrap {
  position: relative !important;
  inset: auto !important;
  z-index: 1;
  display: grid !important;
  place-items: center;
  width: 58px !important;
  height: 58px !important;
  min-width: 58px !important;
  max-width: 58px !important;
  min-height: 58px !important;
  max-height: 58px !important;
  flex: 0 0 58px !important;
  overflow: hidden !important;
  contain: layout paint size;
  background: #f5efe1 !important;
}
.brand-logo-wrap > img {
  position: static !important;
  inset: auto !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 100% !important;
  max-height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  object-fit: contain !important;
  object-position: center !important;
  transform: none !important;
  opacity: 1 !important;
  background: transparent !important;
}

/* Keep long operational messages readable without letting Home become a log dump. */
.service-reason,
.incident-card h4,
.record-card p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* The Home summary should present cards, not a decorative canvas. */
.service-health-grid,
.priority-list,
.overview-metrics,
.timeline-list {
  position: relative;
  z-index: 1;
}

@media (max-width: 700px) {
  .brand-logo-wrap {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    flex-basis: 50px !important;
    padding: 5px !important;
    border-radius: 13px !important;
  }

  .title-row {
    align-items: baseline;
    flex-wrap: wrap;
    column-gap: 7px;
    row-gap: 1px;
  }

  .service-reason {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
}

/* ========================================================================== 
   v2.7.0: Telemetry comparison controls and export polish
   --------------------------------------------------------------------------
   These rules keep the new date controls usable on desktop and mobile without
   changing the established v2.6 service-card layout.
   ========================================================================== */
.period-toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.period-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.custom-period {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.custom-period label,
.export-range label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.custom-period input,
.export-range input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 18, 34, 0.72);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

.compare-toggle {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  cursor: pointer;
}

.compare-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.telemetry-kpi {
  align-content: start;
}

.metric-comparison {
  display: block;
  margin-top: 6px;
  font-size: 0.74rem;
  font-weight: 700;
}

.metric-comparison.up { color: var(--good); }
.metric-comparison.down { color: var(--bad); }
.metric-comparison.neutral { color: var(--muted); }

.export-panel {
  overflow: hidden;
}

.export-note {
  display: block;
  margin-top: 12px;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .period-presets {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .period-presets::-webkit-scrollbar { display: none; }

  .period-presets button {
    flex: 0 0 auto;
  }

  .custom-period {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .custom-period .secondary-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .compare-toggle {
    width: 100%;
    padding: 2px 0;
  }

  .chart-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -------------------------------------------------------------------------
   Telegram diagnostics
   The browser never sees bot tokens or chat IDs. This card only presents the
   sanitized status object emitted by the analyzer.
   ------------------------------------------------------------------------- */
.telegram-panel { margin-top: 18px; }
.telegram-summary { display:flex; align-items:center; gap:12px; }
.telegram-summary > div { display:grid; gap:3px; }
.telegram-summary small { color:var(--muted); }
.status-dot { width:10px; height:10px; border-radius:50%; background:var(--muted); box-shadow:0 0 0 5px rgba(148,163,184,.08); }
.status-dot.good { background:var(--good); }
.status-dot.warn { background:var(--warn); }
.telegram-facts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-top:16px; }
.telegram-facts span { display:grid; gap:4px; padding:12px; border:1px solid var(--line); border-radius:12px; background:rgba(7,17,31,.28); }
.telegram-facts small { color:var(--muted); }
.telegram-error { margin:12px 0 0; color:var(--bad); overflow-wrap:anywhere; }
@media (max-width:640px) { .telegram-facts { grid-template-columns:1fr; } }
