/* Log tables are operational streams, not spreadsheets.
   Render them as compact cards so audit/event review stays readable on notebooks. */
.log-card-table {
  padding: 16px !important;
}

.log-card-table > h3 {
  margin-bottom: 12px;
}

.log-card-table > .table-wrap {
  max-height: clamp(430px, 64dvh, 760px);
  border: 0 !important;
  overflow: auto !important;
  background: transparent;
}

.log-card-table table {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  border-collapse: separate;
  border-spacing: 0;
}

.log-card-table thead {
  display: none !important;
}

.log-card-table tbody {
  display: grid !important;
  gap: 10px;
}

.log-card-table tr {
  display: grid !important;
  grid-template-columns: 132px 92px 120px minmax(120px, 1fr) 88px 92px 108px;
  gap: 8px 12px;
  min-height: 0 !important;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 7px 20px rgba(16, 24, 40, 0.04);
}

.log-card-table td {
  display: grid !important;
  align-content: start;
  gap: 3px;
  min-width: 0 !important;
  max-width: none !important;
  border-bottom: 0 !important;
  padding: 0 !important;
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal !important;
}

.log-card-table td::before {
  display: block;
  color: var(--muted);
  content: attr(data-label);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.06em;
  line-height: 1.25;
  text-transform: uppercase;
}

.log-card-table .cell-badge {
  justify-self: start;
  max-width: 100%;
  height: auto;
  min-height: 24px;
  white-space: normal;
}

.log-card-table .column-timestamp,
.log-card-table .column-ip,
.log-card-table .column-source-ip {
  color: var(--text);
  font-weight: 720;
}

.log-card-table .column-fingerprint,
.log-card-table .column-fingerprint-id,
.log-card-table .column-session,
.log-card-table .column-session-id,
.log-card-table .column-target,
.log-card-table .column-summary,
.log-card-table .column-path {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
}

.log-card-table .column-reasons,
.log-card-table .column-summary {
  grid-column: 1 / -1 !important;
  padding-top: 8px !important;
  border-top: 1px solid var(--line) !important;
  color: var(--muted-strong);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
}

.table-panel-latest-collector-decisions .column-path {
  overflow: hidden;
  overflow-wrap: normal;
}

.table-panel-latest-collector-decisions .column-path .cell-truncated-value {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-card-table.table-panel-audit tr,
.log-card-table.table-panel-platform-audit tr {
  grid-template-columns: 148px 82px minmax(120px, 0.9fr) minmax(120px, 0.9fr) minmax(120px, 1fr) 126px;
}

.log-card-table.table-panel-audit .column-target,
.log-card-table.table-panel-platform-audit .column-target {
  grid-column: span 2;
}

/* Operational events keep compact network metadata and give stable identities
   and the visited path the flexible desktop space they need. */
@media (min-width: 1501px) {
  .log-card-table.table-panel-latest-collector-decisions tr,
  .log-card-table.table-panel-latest-browser-sdk-events tr {
    grid-template-columns:
      132px
      92px
      100px
      112px
      minmax(210px, 1.25fr)
      minmax(200px, 1.15fr)
      minmax(240px, 1.5fr);
  }
}

/* System log summaries have different column counts. At workstation width each
   one gets a data-specific grid instead of inheriting the generic seven tracks. */
@media (min-width: 1701px) {
  .log-card-table.table-panel-triggered-rules tr {
    grid-template-columns: minmax(280px, 2fr) 90px 110px 110px 110px 110px 150px;
  }

  .log-card-table.table-panel-ip-reputation tr {
    grid-template-columns: minmax(150px, 1.4fr) 88px 105px 105px 88px 110px 100px 150px;
  }

  .log-card-table.table-panel-ja4-reputation tr {
    grid-template-columns: minmax(300px, 2fr) 82px 105px 100px 82px 82px 110px 100px 150px;
  }

  .log-card-table.table-panel-period-request-logs tr {
    grid-template-columns:
      132px
      90px
      130px
      112px
      minmax(180px, 1.1fr)
      minmax(210px, 1.25fr)
      72px
      minmax(240px, 1.6fr);
  }
}

@media (max-width: 1500px) {
  .log-card-table tr,
  .log-card-table.table-panel-audit tr,
  .log-card-table.table-panel-platform-audit tr {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .log-card-table .column-fingerprint,
  .log-card-table .column-fingerprint-id,
  .log-card-table .column-session,
  .log-card-table .column-session-id,
  .log-card-table .column-target,
  .log-card-table .column-path {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  .log-card-table tr,
  .log-card-table.table-panel-audit tr,
  .log-card-table.table-panel-platform-audit tr {
    grid-template-columns: 1fr;
  }

  .log-card-table .column-fingerprint,
  .log-card-table .column-fingerprint-id,
  .log-card-table .column-session,
  .log-card-table .column-session-id,
  .log-card-table .column-target,
  .log-card-table .column-path,
  .log-card-table.table-panel-audit .column-target,
  .log-card-table.table-panel-platform-audit .column-target {
    grid-column: 1 / -1;
  }
}

/* Session request rows contain long TLS/FP identifiers.
   On notebook screens they work better as inspection cards than as a squeezed table. */
@media (max-width: 1500px) {
  .table-panel-session-requests {
    padding: 16px !important;
  }

  .table-panel-session-requests > h3 {
    margin-bottom: 12px;
  }

  .table-panel-session-requests > .table-wrap {
    max-height: clamp(390px, 60dvh, 720px);
    border: 0 !important;
    overflow: auto !important;
    background: transparent;
  }

  .table-panel-session-requests table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate;
    border-spacing: 0;
  }

  .table-panel-session-requests thead {
    display: none !important;
  }

  .table-panel-session-requests tbody {
    display: grid !important;
    gap: 10px;
  }

  .table-panel-session-requests tr {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 12px;
    min-height: 0 !important;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 7px 20px rgba(16, 24, 40, 0.04);
  }

  .table-panel-session-requests td {
    display: grid !important;
    align-content: start;
    gap: 3px;
    min-width: 0 !important;
    max-width: none !important;
    border-bottom: 0 !important;
    padding: 0 !important;
    overflow-wrap: anywhere;
    word-break: normal;
    white-space: normal !important;
  }

  .table-panel-session-requests td::before {
    display: block;
    color: var(--muted);
    content: attr(data-label);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: 0.06em;
    line-height: 1.25;
    text-transform: uppercase;
  }

  .table-panel-session-requests .cell-badge {
    justify-self: start;
    max-width: 100%;
    height: auto;
    min-height: 24px;
    white-space: normal;
  }

  .table-panel-session-requests .column-timestamp,
  .table-panel-session-requests .column-ip {
    grid-column: span 2;
    color: var(--text);
    font-weight: 720;
  }

  .table-panel-session-requests .column-fingerprint,
  .table-panel-session-requests .column-fingerprint-id,
  .table-panel-session-requests .column-path,
  .table-panel-session-requests .column-tls-ja4 {
    grid-column: span 2;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 11px;
  }
}

@media (max-width: 900px) {
  .table-panel-session-requests tr {
    grid-template-columns: 1fr;
  }

  .table-panel-session-requests .column-timestamp,
  .table-panel-session-requests .column-ip,
  .table-panel-session-requests .column-fingerprint,
  .table-panel-session-requests .column-fingerprint-id,
  .table-panel-session-requests .column-path,
  .table-panel-session-requests .column-tls-ja4 {
    grid-column: 1 / -1;
  }
}

/* Stable desktop sidebar.
   Keep one predictable scroll area: the whole sidebar, not the navigation list. */
@media (min-width: 761px) {
  .topbar {
    position: fixed !important;
    top: 0 !important;
    right: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  .top-actions {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    min-height: auto;
    overflow: visible;
  }

  .topbar .tabs {
    min-height: auto;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .sidebar-footer {
    align-self: end;
    margin-top: 12px;
  }

  .sidebar-collapsed .topbar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    height: auto !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    overflow: visible;
  }

  .sidebar-collapsed .top-actions {
    display: block;
    overflow: visible;
  }

  .sidebar-collapsed .topbar .tabs {
    overflow: visible;
  }
}

@media (min-width: 761px) {
  .shell {
    min-height: 100vh;
  }

  .workspace-header,
  .view {
    min-width: 0;
  }

  .traffic-background {
    left: var(--sidebar-width);
  }
}

/* Low-height desktop sidebar.
   Notebook screens need one predictable scroll area; otherwise the tenant,
   timezone and footer controls leave too little room for navigation. */
@media (min-width: 761px) and (max-height: 860px) {
  .topbar {
    display: flex !important;
    flex-direction: column;
    height: 100vh !important;
    min-height: 0 !important;
    max-height: 100vh !important;
    padding-top: 14px;
    padding-bottom: 14px;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  .top-actions {
    display: flex !important;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 9px;
    min-height: auto;
    overflow: visible !important;
  }

  .topbar .tabs {
    flex: 0 0 auto;
    overflow: visible !important;
    max-height: none !important;
    padding-right: 0;
  }

  .topbar .tab {
    min-height: 38px;
    padding-block: 7px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .sidebar-search input,
  .tenant-picker input,
  .timezone-trigger,
  .language-trigger {
    min-height: 38px;
  }

  .sidebar-footer {
    flex: 0 0 auto;
    margin-top: 10px;
    padding-top: 10px;
  }

  .topbar .button.secondary {
    min-height: 36px;
  }

  .sidebar-collapsed .topbar {
    overflow-x: visible !important;
    overflow-y: auto !important;
  }

  .sidebar-collapsed .top-actions {
    display: block !important;
  }
}
