/* ============================================================================
 * Zenadrone theme for Flight Review
 *
 * Design tokens are copied from the GCS web UI (zd.1000.web.ui):
 *   - brand palette      -> src/Config/ColorSchemes.js  (default scheme)
 *   - --app-* tokens     -> src/index.css  (:root and [data-theme="dark"])
 *   - typography         -> src/index.css  (* { font-family: "Roboto" })
 *
 * Appearance follows the same contract as the main app: a `data-theme`
 * attribute on <html> ("light" | "dark"), persisted under the localStorage
 * key `zd-ui-appearance`, falling back to prefers-color-scheme. The bootstrap
 * script lives in header.html so the attribute is set before first paint.
 *
 * `data-bs-theme` is kept in sync with `data-theme` so Bootstrap 5.3's own
 * dark mode drives the components we do not restyle by hand.
 *
 * Load order matters: this file must come AFTER bootstrap.min.css and
 * main.css so these overrides win without needing !important everywhere.
 * ========================================================================= */

/* ---------------------------------------------------------------- tokens */

:root {
  /* Brand — ColorSchemes.js `default` */
  --primary-color: #005987;
  --secondary-color: #d11d27;
  --background-color: #f5f5f5;

  /* Text / border — index.css :root */
  --app-text-primary: #101828;
  --app-text-secondary: #475467;
  --app-text-muted: #667085;
  --app-border-default: #d0d5dd;

  /* Surfaces — index.css :root */
  --app-header-gradient: linear-gradient(90deg, #0c5072 0%, #11698f 58%, #1797cf 100%);
  --app-content-background: #f3f5f7;
  --app-panel-background: #f6f8fa;
  --app-card-background: #f8fafc;
  --app-table-header-background: #e9eef3;
  --app-table-row-background: #f7f9fb;
  --app-table-row-hover-background: #edf2f7;
  --app-table-border: #dce3ea;
  --app-surface-muted: #edf1f5;
  --app-header-background: #eef3f6;
  --app-header-border: #d9e2e8;

  /* Form controls — index.css :root */
  --app-control-bg: #ffffff;
  --app-control-border: #d0d5dd;
  --app-control-text: #101828;
  --app-control-placeholder: #667085;

  /* Local additions: things Flight Review needs that the SPA gets from antd */
  --app-elevated-background: #ffffff;
  --app-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --app-shadow-md: 0 2px 8px rgba(15, 42, 58, 0.06);
  --app-shadow-lg: 0 16px 38px rgba(15, 23, 42, 0.12);
  --app-radius-control: 8px;
  --app-radius-card: 12px;
  --app-link: #005987;
  --app-link-hover: #0b6f9f;
}

[data-theme="dark"] {
  color-scheme: dark;

  --background-color: #141414;

  /* index.css [data-theme="dark"] */
  --app-text-primary: rgba(255, 255, 255, 0.92);
  --app-text-secondary: rgba(255, 255, 255, 0.72);
  --app-text-muted: rgba(255, 255, 255, 0.55);
  --app-border-default: #424242;

  --app-header-gradient:
    radial-gradient(circle at 86% 12%, rgba(96, 165, 250, 0.18), transparent 28%),
    linear-gradient(135deg, #0b1729 0%, #0a2237 52%, #0e3a56 100%);
  --app-content-background: #0f1620;
  --app-panel-background: rgba(15, 23, 42, 0.52);
  --app-card-background: #161e2d;
  --app-table-header-background: rgba(22, 30, 45, 0.92);
  --app-table-row-background: rgba(15, 23, 42, 0.52);
  --app-table-row-hover-background: rgba(30, 41, 59, 0.72);
  --app-table-border: rgba(96, 165, 250, 0.2);
  --app-surface-muted: #2a2a2a;
  --app-header-background: #1f1f1f;
  --app-header-border: #303030;

  --app-control-bg: #2a2a2a;
  --app-control-border: #424242;
  --app-control-text: rgba(255, 255, 255, 0.88);
  --app-control-placeholder: rgba(255, 255, 255, 0.45);

  --app-elevated-background: #1f1f1f;
  --app-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --app-shadow-md: 0 2px 8px rgba(0, 0, 0, 0.28);
  --app-shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.42);
  --app-link: #4ea1ff;
  --app-link-hover: #7cbaff;
}

/* Map our tokens onto Bootstrap 5.3's variables so every Bootstrap component
 * we do not touch by hand (progress bars, alerts, badges, close buttons,
 * pagination) lands on-brand automatically. */
:root,
[data-bs-theme="light"] {
  --bs-primary: #005987;
  --bs-primary-rgb: 0, 89, 135;
  --bs-danger: #d11d27;
  --bs-danger-rgb: 209, 29, 39;
  --bs-link-color: var(--app-link);
  --bs-link-color-rgb: 0, 89, 135;
  --bs-link-hover-color: var(--app-link-hover);
  --bs-body-bg: var(--background-color);
  --bs-body-color: var(--app-text-primary);
  --bs-border-color: var(--app-border-default);
  --bs-font-sans-serif: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-border-radius: var(--app-radius-control);
}

[data-bs-theme="dark"] {
  --bs-primary: #1e679b;
  --bs-primary-rgb: 30, 103, 155;
  --bs-danger: #e5484d;
  --bs-danger-rgb: 229, 72, 77;
  --bs-link-color: var(--app-link);
  --bs-link-color-rgb: 78, 161, 255;
  --bs-link-hover-color: var(--app-link-hover);
  --bs-body-bg: var(--background-color);
  --bs-body-color: var(--app-text-primary);
  --bs-border-color: var(--app-border-default);
  --bs-emphasis-color: #ffffff;
  --bs-secondary-color: var(--app-text-secondary);
  --bs-tertiary-bg: var(--app-surface-muted);
}

/* ------------------------------------------------------------ typography */

/* Matches the SPA's global `* { font-family: "Roboto", sans-serif }` */
body {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  background-color: var(--background-color);
  color: var(--app-text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Suppress the transition while the theme is being flipped, mirroring the
 * SPA's html.theme-switching guard in src/Styles/Theme.css. */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
  animation: none !important;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--app-text-primary);
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 22px;
  margin-bottom: 12px;
}

a {
  color: var(--app-link);
}

a:hover {
  color: var(--app-link-hover);
}

small,
.text-muted {
  color: var(--app-text-muted) !important;
}

/* ---------------------------------------------------------------- header */

/* The bar keeps its dark brand gradient in BOTH appearances, so its contents
 * must always use light-on-dark colours. Bootstrap 5.3 removed `navbar-dark`
 * in favour of `data-bs-theme`, but we cannot set that here without also
 * flipping the dropdowns that live inside the navbar — so drive Bootstrap's
 * navbar variables directly instead. Without the toggler-icon override the
 * hamburger renders as a dark-stroked SVG and disappears on the gradient in
 * light mode. */
#header.navbar {
  background: var(--app-header-gradient) !important;
  border-bottom: 1px solid var(--app-header-border);
  box-shadow: var(--app-shadow-md);
  min-height: 64px;
  padding: 6px 0;

  --bs-navbar-color: rgba(255, 255, 255, 0.88);
  --bs-navbar-hover-color: #ffffff;
  --bs-navbar-active-color: #ffffff;
  --bs-navbar-brand-color: #ffffff;
  --bs-navbar-brand-hover-color: #ffffff;
  --bs-navbar-toggler-border-color: rgba(255, 255, 255, 0.3);
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

#header .navbar-brand {
  display: flex;
  align-items: center;
  margin-right: 20px;
}

#header .navbar-brand h1 {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
}

#header .brand-mark {
  height: 34px;
  width: auto;
  display: block;
}

/* Wordmark beside the logo, styled like .logo-cluster__title / __status in
 * the SPA header. */
#header .brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  line-height: 1.2;
}

#header .brand-title {
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}

#header .brand-subtitle {
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#header .navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--app-radius-control);
  transition: background-color 80ms linear, color 80ms linear;
}

#header .navbar-nav .nav-link:hover,
#header .navbar-nav .nav-link:focus,
#header .navbar-nav .show > .nav-link {
  background-color: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

#header .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.3);
  padding: 6px 10px;
}

#header .navbar-toggler:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
}

/* Appearance toggle — same affordance as .appearance-toggle-btn in the SPA */
.appearance-toggle-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  margin-left: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: background-color 120ms linear, border-color 120ms linear;
}

.appearance-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.45);
}

.appearance-toggle-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
}

/* Show the sun in dark mode and the moon in light mode — i.e. the icon
 * advertises what you will get, matching the SPA's toggle. */
.appearance-toggle-btn .icon-sun { display: none; }
[data-theme="dark"] .appearance-toggle-btn .icon-sun { display: block; }
[data-theme="dark"] .appearance-toggle-btn .icon-moon { display: none; }

/* -------------------------------------------------------------- dropdowns */

/* Mirrors .drone-navigation-dropdown__menu in the SPA. */
#header .dropdown-menu {
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--app-table-border);
  border-radius: var(--app-radius-card);
  background: var(--app-panel-background);
  background-color: var(--app-elevated-background);
  box-shadow: var(--app-shadow-lg);
}

#header .dropdown-item {
  min-height: 36px;
  margin: 2px 0;
  padding: 7px 12px;
  border-radius: var(--app-radius-control);
  color: var(--app-text-primary);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 80ms linear, color 80ms linear;
}

#header .dropdown-item:hover,
#header .dropdown-item:focus {
  background-color: color-mix(in srgb, var(--primary-color) 11%, var(--app-elevated-background));
  color: var(--app-text-primary);
  box-shadow: inset 3px 0 0 var(--primary-color);
}

[data-theme="dark"] #header .dropdown-item:hover,
[data-theme="dark"] #header .dropdown-item:focus {
  background-color: rgba(30, 103, 155, 0.32);
  color: #ffffff;
  box-shadow: inset 3px 0 0 #0086b8;
}

#header .dropdown-header {
  color: var(--app-text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 12px 4px;
}

/* --------------------------------------------------------------- surfaces */

/* Generic card, standing in for antd's Card in the SPA. */
.app-card {
  background: var(--app-card-background);
  border: 1px solid var(--app-table-border);
  border-radius: var(--app-radius-card);
  box-shadow: var(--app-shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

.app-card > h3:first-child,
.app-card > h4:first-child {
  margin-top: 0;
}

.app-page-intro {
  color: var(--app-text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

/* ----------------------------------------------------------- form controls */

/* 44px tall, 8px radius — the SPA's .model-popup-input-field geometry. */
.form-control,
.form-select {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--app-control-border);
  border-radius: var(--app-radius-control);
  background-color: var(--app-control-bg);
  color: var(--app-control-text);
  box-shadow: var(--app-shadow-sm);
  font-size: 14px;
}

textarea.form-control {
  min-height: 88px;
}

.form-control::placeholder {
  color: var(--app-control-placeholder);
  opacity: 1;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-color);
  background-color: var(--app-control-bg);
  color: var(--app-control-text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 18%, transparent);
}

/* Bootstrap's file input segment */
.form-control::file-selector-button {
  background: var(--app-surface-muted);
  color: var(--app-text-primary);
  border-color: var(--app-control-border);
}

/* ---------------------------------------------------------------- buttons */

.btn {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--app-radius-control);
  font-size: 14px;
  font-weight: 600;   /* .ant-btn { font-weight: 600 } in the SPA */
  letter-spacing: 0.01em;
  transition: background-color 120ms linear, border-color 120ms linear, color 120ms linear;
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: color-mix(in srgb, var(--primary-color) 85%, #ffffff);
  border-color: color-mix(in srgb, var(--primary-color) 85%, #ffffff);
  color: #ffffff;
}

.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 30%, transparent);
}

/* Secondary/cancel action — .btn-cancel in the SPA: neutral until hover,
 * then it goes brand-red. */
.btn-outline-secondary,
.btn-secondary {
  background-color: transparent;
  border: 1px solid var(--app-control-border);
  color: var(--app-text-secondary);
  box-shadow: var(--app-shadow-sm);
}

.btn-outline-secondary:hover,
.btn-secondary:hover {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  color: #ffffff;
}

.btn-danger {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  color: #ffffff;
}

/* ----------------------------------------------------------------- tables */

/* Info tables on the plot page and the DataTable on /browse. */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--app-text-primary);
  --bs-table-border-color: var(--app-table-border);
  --bs-table-striped-bg: var(--app-table-row-background);
  --bs-table-striped-color: var(--app-text-primary);
  --bs-table-hover-bg: var(--app-table-row-hover-background);
  --bs-table-hover-color: var(--app-text-primary);
  border-color: var(--app-table-border);
  color: var(--app-text-primary);
  font-size: 14px;
}

.table > thead {
  background: var(--app-table-header-background);
}

.table > thead th {
  background: var(--app-table-header-background);
  border-bottom: 1px solid var(--app-table-border);
  color: var(--app-text-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table > tbody td {
  border-color: var(--app-table-border);
  vertical-align: middle;
}

/* The plot page's info table is emitted by plotted_tables.py without any
 * Bootstrap classes, so target it structurally. */
.content table:not(.table):not(.dataTable):not(.spaced) {
  width: 100%;
  border-collapse: collapse;
  background: var(--app-card-background);
  border: 1px solid var(--app-table-border);
  border-radius: var(--app-radius-card);
  overflow: hidden;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--app-text-primary);
}

.content table:not(.table):not(.dataTable):not(.spaced) td,
.content table:not(.table):not(.dataTable):not(.spaced) th {
  padding: 9px 14px;
  border-bottom: 1px solid var(--app-table-border);
  text-align: left;
}

/* Upload form's layout table — keep it transparent, it is a layout grid and
 * must not read as a data table. */
table.spaced {
  width: 100%;
  margin: 0;
}

table.spaced tbody {
  background: transparent;
  border: 0;
}

table.spaced td {
  padding: 8px 0;
  vertical-align: middle;
  color: var(--app-text-primary);
  font-size: 14px;
}

table.spaced td.left {
  padding-right: 20px;
  color: var(--app-text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

/* DataTables (bs5 integration) on /browse */
.dataTables_wrapper {
  color: var(--app-text-primary);
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--app-control-border);
  border-radius: var(--app-radius-control);
  background-color: var(--app-control-bg);
  color: var(--app-control-text);
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  color: var(--app-text-secondary);
  font-size: 13px;
}

.page-link {
  color: var(--app-link);
  background-color: var(--app-elevated-background);
  border-color: var(--app-table-border);
}

.page-item.active .page-link {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
}

.page-link:hover {
  background-color: var(--app-table-row-hover-background);
  color: var(--app-link-hover);
}

/* ------------------------------------------------------------------ alerts */

.alert {
  border-radius: var(--app-radius-card);
  border: 1px solid transparent;
  font-size: 14px;
  padding: 14px 18px;
}

.alert-primary {
  background-color: color-mix(in srgb, var(--primary-color) 10%, var(--app-card-background));
  border-color: color-mix(in srgb, var(--primary-color) 28%, transparent);
  color: var(--app-text-primary);
}

.alert-primary .alert-link {
  color: var(--app-link);
  font-weight: 600;
}

.alert-danger {
  background-color: color-mix(in srgb, var(--secondary-color) 10%, var(--app-card-background));
  border-color: color-mix(in srgb, var(--secondary-color) 30%, transparent);
  color: var(--app-text-primary);
}

/* -------------------------------------------------------------- Leaflet map */

#mapid {
  height: 500px;
  border: 1px solid var(--app-table-border);
  border-radius: var(--app-radius-card);
  box-shadow: var(--app-shadow-sm);
  overflow: hidden;   /* clip tiles to the rounded corners */
  margin-bottom: 24px;
  background: var(--app-surface-muted);
}

.leaflet-control-zoom a {
  background: var(--app-elevated-background);
  color: var(--app-text-primary);
  border-color: var(--app-table-border);
}

.leaflet-control-zoom a:hover {
  background: var(--app-table-row-hover-background);
  color: var(--app-link);
}

.leaflet-control-attribution {
  background: color-mix(in srgb, var(--app-elevated-background) 82%, transparent) !important;
  color: var(--app-text-muted) !important;
  font-size: 10px;
}

.leaflet-control-attribution a {
  color: var(--app-link) !important;
}

/* ------------------------------------------------------------------- Bokeh */

/* Plot canvases are themed server-side per request — see plot_app/plot_theme.py,
 * which picks a light or dark bokeh Theme from the `zd-ui-appearance` cookie. So
 * the charts arrive already matching the page and need no CSS compensation here;
 * only the surrounding HTML chrome (fonts, widgets) is styled below. */
.bk-root {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif !important;
}

/* Bokeh's own widgets (the "Select Some Options" multiselect above the map) */
.bk-root .bk-input {
  border-radius: var(--app-radius-control) !important;
  border-color: var(--app-control-border) !important;
  min-height: 44px;
  font-family: inherit !important;
}

/* ------------------------------------------------------------- chosen.js */

/* Error-label picker on the plot page. */
.chosen-container {
  font-family: "Roboto", system-ui, sans-serif;
  font-size: 14px;
}

.chosen-container-multi .chosen-choices,
.chosen-container-single .chosen-single {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--app-control-border) !important;
  border-radius: var(--app-radius-control) !important;
  background: var(--app-control-bg) !important;
  background-image: none !important;
  box-shadow: var(--app-shadow-sm) !important;
  color: var(--app-control-text);
}

.chosen-container .chosen-drop {
  border-color: var(--app-control-border);
  background: var(--app-elevated-background);
  border-radius: 0 0 var(--app-radius-control) var(--app-radius-control);
  box-shadow: var(--app-shadow-lg);
}

.chosen-container .chosen-results li {
  color: var(--app-text-primary);
}

.chosen-container .chosen-results li.highlighted {
  background: var(--primary-color) !important;
  background-image: none !important;
  color: #ffffff;
}

.chosen-container-multi .chosen-choices li.search-choice {
  background: color-mix(in srgb, var(--primary-color) 14%, var(--app-control-bg)) !important;
  background-image: none !important;
  border: 1px solid color-mix(in srgb, var(--primary-color) 32%, transparent) !important;
  border-radius: 999px !important;
  box-shadow: none !important;
  color: var(--app-text-primary);
  padding: 4px 22px 4px 10px;
}

/* -------------------------------------------------------------------- misc */

pre {
  background-color: var(--app-surface-muted);
  border: 1px solid var(--app-table-border);
  border-radius: var(--app-radius-control);
  color: var(--app-text-primary);
  font-size: 13px;
  padding: 14px;
}

code {
  color: var(--secondary-color);
}

/* Log-overview thumbnails on /browse */
.map_overview {
  border: 1px solid var(--app-table-border);
  border-radius: var(--app-radius-control);
}

.no_map_overview {
  color: var(--app-text-muted);
}

/* pace.js load bar — brand it */
.pace .pace-progress {
  background: var(--secondary-color);
  height: 3px;
}

/* Plot-legend colour chips in the header dropdown.
 *
 * header.html emits the chip colour inline as rgba(r, g, b, 0.2) — deliberately
 * translucent, because it mirrors the faint flight-mode bands drawn behind the
 * plots. Over a dark dropdown that composites to almost nothing, so paint white
 * under the border box (background-clip: border-box extends the background
 * beneath the border area) and let the translucent colour sit on white exactly
 * as it does on the plot canvas. Keeps legend and plot in agreement. */
.plot-legend-box {
  border-left-width: 18px;
  border-radius: 3px;
  padding-left: 8px;
  background-image: linear-gradient(to right, #ffffff 18px, transparent 18px);
  background-clip: border-box;
  background-repeat: no-repeat;
}

/* ------------------------------------------------------------------ footer */

#footer {
  margin-top: 48px;
  padding: 24px 0;
  border-top: 1px solid var(--app-header-border);
  background: transparent;
}

#footer .copyright-text {
  margin-top: 0;
}

#footer .copyright-text p {
  color: var(--app-text-muted);
  font-size: 13px;
  margin-bottom: 0;
}

#footer .copyright-text a {
  color: var(--app-link);
  font-weight: 500;
}

/* ------------------------------------------------------------ log summary */

/* The block at the top of a log page: identity + actions, a KPI row of
 * headline figures, then grouped detail panels. Markup comes from
 * plotted_tables.py (get_heading_html / get_info_table_html).
 *
 * All ink is text tokens — the numbers are never brand-coloured, so identity
 * stays with the icon and the label. */

.log-summary__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--app-table-border);
}

.log-summary__identity {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-width: 0;
}

.log-summary__mark {
  width: 22px;
  height: 22px;
  flex: none;
}

.log-summary__title {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--app-text-primary);
}

.log-summary__subtitle {
  font-size: 13px;
  color: var(--app-text-muted);
}

.log-summary__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.log-summary__action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--app-border-default);
  border-radius: var(--app-radius-control);
  background: var(--app-elevated-background);
  color: var(--app-text-primary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.log-summary__action:hover,
.log-summary__action:focus {
  border-color: var(--primary-color);
  color: var(--app-link);
  text-decoration: none;
}

.log-summary__action i {
  font-size: 12px;
  color: var(--app-text-muted);
}

.log-summary__action:hover i,
.log-summary__action:focus i {
  color: var(--app-link);
}

.log-summary__description {
  margin: -8px 0 20px;
  color: var(--app-text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

/* ------------------------------------------------------------- KPI row */

/* Flex rather than an auto-fit grid: a grid sizes every column to the widest
 * tile, which pushed the 5th headline onto its own row. */
.log-summary__kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 24px;
  margin-bottom: 24px;
}

.kpi {
  flex: 1 1 110px;
  min-width: 0;
}

.kpi__label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--app-text-secondary);
}

.kpi__label i {
  font-size: 11px;
  color: var(--app-text-muted);
}

.kpi__value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--app-text-primary);
  /* proportional figures: tabular digits read loose at this size */
}

.kpi__unit {
  margin-left: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--app-text-muted);
}

/* -------------------------------------------------------- detail panels */

.log-summary__panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 16px;
}

.info-panel {
  background: var(--app-panel-background);
  border: 1px solid var(--app-table-border);
  border-radius: var(--app-radius-card);
  padding: 16px 18px;
  min-width: 0;
}

.info-panel__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--app-text-secondary);
}

.info-panel__title i {
  font-size: 12px;
  color: var(--app-text-muted);
}

.info-panel__rows {
  margin: 0;
}

.info-panel__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0;
  min-width: 0;
}

.info-panel__label {
  margin: 0;
  flex: 0 1 auto;
  font-size: 13px;
  font-weight: 400;
  color: var(--app-text-secondary);
}

.info-panel__value {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font-size: 13px;
  color: var(--app-text-primary);
  font-variant-numeric: tabular-nums;   /* these do align vertically */
  overflow-wrap: anywhere;
}

/* Free text and long identifiers read badly right-aligned against a label,
 * so they get the full row width underneath it. */
.info-panel__row--wide {
  display: block;
}

.info-panel__row--wide .info-panel__value {
  text-align: left;
  margin-top: 3px;
}

.info-panel__value a {
  color: var(--app-link);
}

.info-panel__value-note {
  color: var(--app-text-muted);
  font-size: 12px;
}

.info-panel__value small {
  color: var(--app-text-muted);
}

.info-panel__hint {
  margin-left: 4px;
  font-size: 11px;
  color: var(--app-text-muted);
  cursor: help;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 575.98px) {
  .log-summary__kpis {
    gap: 14px 18px;
  }

  .kpi {
    flex-basis: 90px;
  }

  .kpi__value {
    font-size: 24px;
  }
}

@media (max-width: 991.98px) {
  #header .brand-text {
    display: none;   /* logo only, once the nav collapses */
  }

  .app-card {
    padding: 18px;
  }
}

@media (max-width: 575.98px) {
  table.spaced td.left {
    display: block;
    padding-bottom: 4px;
    white-space: normal;
  }

  table.spaced td:not(.left) {
    display: block;
    padding-top: 0;
  }
}
