/*
  SkyGeo platform design system, on top of Bootstrap 3.
  One file, loaded last from base.html. Sizes are px: Bootstrap 3 sets html to 10px, so rem is unusable.

  1. tokens          4. navbar          7. tables           10. feedback (alerts, badges, empty, loading)
  2. base + type     5. page layout     8. forms            11. entity accents (project, contract, organization, user)
  3. utilities       6. cards           9. overlays (modal, dropdown, popover, select2, swal)   12. mobile
*/

/* 1. tokens ---------------------------------------------------------------------------------- */
:root {
  --sg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sg-mono: Menlo, Consolas, "Liberation Mono", monospace;

  --sg-ink: #1f2d3d;
  --sg-ink-2: #5a6b7b;
  --sg-ink-3: #97a4b1;
  --sg-line: #e4e9ee;
  --sg-line-2: #cfd8e1;
  --sg-bg: #f5f5f5;
  --sg-surface: #fff;
  --sg-surface-2: #f6f8fa;
  --sg-surface-3: #edf1f5;

  --sg-accent: #4a90c4;
  --sg-accent-ink: #3c7db0;
  --sg-accent-soft: #e8f1f8;
  --sg-accent-softer: #f1f6fc;
  --sg-focus: rgba(74, 144, 196, 0.25);

  --sg-success: #2e8b57;  --sg-success-soft: #dff3e7;  --sg-success-ink: #1d6b45;
  --sg-warning: #e8963c;  --sg-warning-soft: #fdf1e3;  --sg-warning-ink: #a0540c;
  --sg-danger: #c0392b;   --sg-danger-soft: #fbe9eb;   --sg-danger-ink: #a71d2a;
  --sg-info: #4a90c4;     --sg-info-soft: #e3ecf5;     --sg-info-ink: #31708f;

  --sg-project: #4a90c4;      --sg-project-ink: #31708f;      --sg-project-soft: #e3ecf5;      --sg-project-softer: #edf2f8;
  --sg-contract: #43a06f;     --sg-contract-ink: #2b6e4c;     --sg-contract-soft: #e3f2ea;     --sg-contract-softer: #eef7f2;
  --sg-organization: #e67e22; --sg-organization-ink: #a04f0b; --sg-organization-soft: #fdf1e6; --sg-organization-softer: #fdf6ee;
  --sg-user: #8e44ad;         --sg-user-ink: #5b2c6f;         --sg-user-soft: #f3e9f7;         --sg-user-softer: #f8f2fa;

  --sg-radius-sm: 4px;
  --sg-radius: 6px;
  --sg-radius-lg: 8px;
  --sg-shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --sg-shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.14);

  --sg-nav-h: 60px;
  --sg-sidebar-w: 216px;
}

/* 2. base + type ----------------------------------------------------------------------------- */
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sg-font);
  font-size: 13px;
  line-height: 1.4;
  color: var(--sg-ink);
  background: var(--sg-bg);
  -webkit-font-smoothing: antialiased;
}
body div, button, input, select, textarea { font-family: inherit; }

a { color: #2b6cb0; }
a:hover, a:focus { color: #1f5190; }

h1, h2, h3, h4, h5, h6 { font-family: inherit; font-weight: 600; color: var(--sg-ink); line-height: 1.3; margin: 0 0 8px; }
h1 { font-size: 24px; } h2 { font-size: 20px; } h3 { font-size: 18px; } h4 { font-size: 15px; } h5 { font-size: 13px; } h6 { font-size: 12px; }
small, .small { font-size: 12px; }
hr { border-color: var(--sg-line); margin: 14px 0; }
.text-muted { color: var(--sg-ink-2); }
code, pre, .mono { font-family: var(--sg-mono); }

/* the page title. Most pages still use <legend>, new pages use .sg-page-head */
legend {
  display: block; width: 100%;
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3;
  color: var(--sg-ink); margin: 0 0 10px; padding: 0; border: 0;
}
legend small { font-size: 13px; font-weight: 400; color: var(--sg-ink-3); }

/* small uppercase label, used for section headers, table heads, field labels */
.sg-eyebrow, .sidebar-section-title, .tile-subheader, .section-subheader, .tree-label, .items-filters-label,
.items-toolbar-label, .contract-header-label, .ds-card-title, .org-nav-label, .staff-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sg-ink-3);
}

/* 3. utilities (also the Bootstrap 4 names the templates already use) --------------------- */
.d-flex { display: flex; } .d-block { display: block; } .d-none { display: none; }
.align-items-center { align-items: center; } .align-items-start { align-items: flex-start; }
.justify-content-between { justify-content: space-between; } .justify-content-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; } .flex-1 { flex: 1; min-width: 0; } .gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.w-100 { width: 100%; } .text-nowrap { white-space: nowrap; } .text-dark { color: var(--sg-ink); }
.font-weight-bold, .fw-600 { font-weight: 600; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.ml-1, .ms-1 { margin-left: 4px; } .ml-2, .ms-2 { margin-left: 8px; } .mr-1, .me-1 { margin-right: 4px; } .mr-2, .me-2 { margin-right: 8px; } .mr-3 { margin-right: 16px; }
.p-0 { padding: 0; } .p-1 { padding: 4px; } .p-2 { padding: 8px; } .p-3 { padding: 16px; }
.bg-light { background: var(--sg-surface-2); }
.shadow { box-shadow: var(--sg-shadow); }
.form-control:focus::placeholder { color: transparent; }

/* 4. navbar ---------------------------------------------------------------------------------- */
.sg-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1030;
  height: var(--sg-nav-h); background: var(--sg-surface);
  box-shadow: 0 1px 0 var(--sg-line), 0 1px 4px rgba(16, 24, 40, 0.04);
}
.skygeo-gradient { height: 4px; background: linear-gradient(90deg, #54c8e8 0%, #90d375 48%, #cdde00 100%); }

nav.navbar-menu { margin: 0; border: 0; border-radius: 0; min-height: 0; background: transparent; }
nav.navbar-menu > .container-fluid { display: flex; align-items: center; height: calc(var(--sg-nav-h) - 4px); padding: 0 16px; }
nav.navbar-menu > .container-fluid::before, nav.navbar-menu > .container-fluid::after { display: none; }
nav.navbar-menu .navbar-header { flex: 0 0 auto; height: calc(var(--sg-nav-h) - 4px); display: flex; align-items: center; margin: 0; float: none; }
nav.navbar-menu .navbar-collapse.collapse { flex: 1; display: flex !important; align-items: center; justify-content: space-between; height: auto !important; overflow: visible; }
nav.navbar-menu .navbar-brand { height: auto; padding: 0 14px 0 0; display: flex; align-items: center; }
nav.navbar-menu .navbar-brand img { display: block; height: 26px; max-height: none; margin: 0; }
nav.navbar-menu .navbar-toggle {
  display: none; margin: 0 0 0 auto; padding: 7px 9px;
  border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); background: var(--sg-surface);
}
nav.navbar-menu .navbar-toggle .icon-bar { background: var(--sg-ink-2); }
nav.navbar-menu .navbar-collapse { padding: 0; margin: 0; border: 0; box-shadow: none; }
nav.navbar-menu .navbar-nav { margin: 0; display: flex; align-items: center; height: calc(var(--sg-nav-h) - 4px); float: none; }
nav.navbar-menu .navbar-nav.navbar-right { margin-right: 0; }
@media (min-width: 768px) {
  /* Bootstrap clearfix pseudo-elements otherwise become extra flex items. */
  nav.navbar-menu .navbar-collapse::before,
  nav.navbar-menu .navbar-collapse::after { display: none; }
  nav.navbar-menu .navbar-nav.navbar-right { margin-left: auto; }
}

nav.navbar-menu .navbar-nav > li { float: none; margin: 0 1px; position: relative; }
nav.navbar-menu .navbar-nav > li > a {
  display: flex; align-items: center; gap: 5px; position: relative;
  padding: 6px 11px; border-radius: var(--sg-radius);
  color: var(--sg-ink-2); font-size: 14px; font-weight: 500; line-height: 20px; text-transform: none;
  background: transparent;
}
nav.navbar-menu .navbar-nav > li > a:hover,
nav.navbar-menu .navbar-nav > li > a:focus { color: var(--sg-ink); background: var(--sg-surface-2); }
nav.navbar-menu .navbar-nav > li.active > a,
nav.navbar-menu .navbar-nav > li.current > a,
nav.navbar-menu .navbar-nav > li.open > a { color: var(--sg-accent-ink); background: var(--sg-accent-soft); font-weight: 600; }
nav.navbar-menu .navbar-nav > li.active > a:hover,
nav.navbar-menu .navbar-nav > li.active > a:focus,
nav.navbar-menu .navbar-nav > li.current > a:hover,
nav.navbar-menu .navbar-nav > li.current > a:focus,
nav.navbar-menu .navbar-nav > li.open > a:hover,
nav.navbar-menu .navbar-nav > li.open > a:focus {
  color: var(--sg-accent-ink); background: var(--sg-accent-soft);
}
nav.navbar-menu .navbar-nav > li > a .caret { margin-left: 1px; opacity: 0.6; }
nav.navbar-menu .navbar-nav > li > a .fa, nav.navbar-menu .navbar-nav > li > a .fas { font-size: 16px; }

/* unread counter on an icon tab */
nav.navbar-menu .navbar-nav > li > a .badge {
  position: absolute; top: 0; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; margin: 0;
  border-radius: 8px; background: var(--sg-accent); color: #fff; font-size: 10px; line-height: 16px; font-weight: 600;
}
/* who you are impersonating, with a stop */
nav.navbar-menu .navbar-nav a.navbar-impersonate {
  border: 1px solid #f0c36d; background: var(--sg-warning-soft); color: var(--sg-warning-ink); font-size: 12px; font-weight: 600;
}
nav.navbar-menu .navbar-nav a.navbar-impersonate:hover { background: #fbe3c4; color: #7a3f08; }
/* environment chip next to the logo: text, not only colour */
.sg-env {
  display: inline-block; padding: 1px 7px; margin-right: 10px; border-radius: var(--sg-radius-sm);
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--sg-warning-soft); color: var(--sg-warning-ink); border: 1px solid #f0c36d;
}
.sg-env-demo { background: var(--sg-success-soft); color: var(--sg-success-ink); border-color: #9fd3b6; }

nav.navbar-menu .dropdown-menu { margin-top: 6px; font-size: 14px; }
/* small pointer under the button that opened the menu; drawn on the li so the menu's own scroll overflow cannot clip it */
nav.navbar-menu .navbar-nav > li.open::after {
  content: ""; position: absolute; left: 50%; bottom: -11px; width: 9px; height: 9px; z-index: 1001;
  transform: translateX(-50%) rotate(45deg); background: var(--sg-surface);
  border-top: 1px solid var(--sg-line); border-left: 1px solid var(--sg-line); pointer-events: none;
}
nav.navbar-menu .dropdown-menu > li > a { padding: 6px 14px; }
nav.navbar-menu .dropdown-menu > li > a > .fa,
nav.navbar-menu .dropdown-menu > li > a > .fas,
nav.navbar-menu .dropdown-menu > li > a > .fa-solid { width: 18px; margin-right: 6px; text-align: center; color: var(--sg-ink-3); }
nav.navbar-menu .dropdown-menu > li.sg-menu-user > a { color: var(--sg-ink-3); font-size: 12px; pointer-events: none; }

/* 5. page layout ----------------------------------------------------------------------------- */
.sg-main { padding: calc(var(--sg-nav-h) + 24px) 24px 40px; max-width: 1920px; margin: 0 auto; }
.sg-main > .row > .col-md-8:empty { display: none; }
/* the table pages: container-fluid and row inside the page only add gutters, the page has its own */
.v2-page > .container-fluid { padding: 0; }
.v2-page > .container-fluid > .row { margin: 0; }
.v2-page > .container-fluid > .row > [class*="col-"] { padding: 0; }

/* page title row: title + one line of context left, actions right */
.sg-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.sg-page-head h1, .sg-page-head legend { font-size: 24px; line-height: 1.35; letter-spacing: -0.025em; margin: 0; }
.sg-page-sub { margin: 3px 0 0; font-size: 12px; color: var(--sg-ink-2); }
.sg-page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
/* a short block of help text or a note, quieter than an alert */
.sg-note { padding: 8px 12px; border-radius: var(--sg-radius); background: var(--sg-surface-2); border: 1px solid var(--sg-line); font-size: 12px; color: var(--sg-ink-2); }
.sg-note .fa { margin-right: 4px; }
/* the row of controls above a table: filters, toggles, counts */
.sg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 8px; font-size: 12px; color: var(--sg-ink-2); }
.sg-toolbar label { margin: 0; font-weight: 400; color: inherit; font-size: inherit; display: inline-flex; align-items: center; gap: 5px; }
.sg-toolbar input[type="checkbox"] { margin: 0; }

/* The context bar spans the viewport; its contents share the page gutter. */
.sg-main:has(.project-banner) { max-width: none; padding-top: var(--sg-nav-h); }
/* banner above a sidebar page: back link and where we are in the tree */
.project-banner {
  display: flex; align-items: center; gap: 14px;
  background: var(--sg-surface); border: 0; border-bottom: 1px solid var(--sg-line);
  position: sticky; top: var(--sg-nav-h); z-index: 100;
  border-radius: 0; padding: 10px 24px; margin: 0 -24px 20px;
}
.project-banner-top { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.project-banner-spacer { flex: 1 1 auto; }
.project-back-link {
  display: inline-block; padding: 4px 10px; white-space: nowrap; font-size: 12px; font-weight: 500;
  border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); background: var(--sg-surface); color: var(--sg-ink-2); text-decoration: none;
}
.project-back-link:hover, .project-back-link:focus { background: var(--sg-surface-2); color: var(--sg-ink); text-decoration: none; }
.project-tree { font-size: 12px; line-height: 1.35; color: var(--sg-ink-2); min-width: 0; }
.project-tree .tree-row { display: grid; grid-template-columns: 22px 100px minmax(0, 1fr); align-items: baseline; white-space: nowrap; }
.project-tree .tree-row-org { grid-template-columns: 0 100px minmax(0, 1fr); }
.project-tree .tree-row-project { padding-left: 22px; }
.project-tree .tree-row-contract { padding-left: 44px; }
.project-tree .tree-row-single { grid-template-columns: auto auto; column-gap: 8px; padding-left: 0; }
.project-tree .tree-elbow { color: var(--sg-ink-3); font-family: var(--sg-mono); }
.project-tree .tree-label { padding-right: 6px; }
.project-tree .tree-label-current { font-size: 11px; font-weight: 700; color: var(--sg-ink); }
.project-tree .tree-value-project, .project-tree .tree-value-contract { font-size: 14px; font-weight: 700; color: var(--sg-ink); overflow: hidden; text-overflow: ellipsis; }
.project-tree .tree-value-projects { overflow: hidden; text-overflow: ellipsis; }
.project-tree .tree-separator { color: var(--sg-line-2); }
.project-tree .tree-empty { color: var(--sg-ink-3); font-style: italic; }

/* sidebar page: sticky nav left, content right */
.project-page { display: flex; align-items: flex-start; gap: 20px; }
.project-page .sidebar {
  width: var(--sg-sidebar-w); min-width: var(--sg-sidebar-w);
  position: sticky; top: calc(var(--sg-nav-h) + var(--sg-context-offset, 0px) + 12px); max-height: calc(100vh - var(--sg-nav-h) - var(--sg-context-offset, 0px) - 24px); overflow-y: auto;
  background: var(--sg-surface); border: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg);
}
@media (min-width: 768px) {
  .project-banner { margin-bottom: 0; }
  .project-page { margin-left: -24px; }
  .project-page .sidebar {
    width: calc(var(--sg-sidebar-w) + 24px); min-width: calc(var(--sg-sidebar-w) + 24px);
    top: calc(var(--sg-nav-h) + var(--sg-context-offset, 0px));
    height: calc(100vh - var(--sg-nav-h) - var(--sg-context-offset, 0px));
    max-height: calc(100vh - var(--sg-nav-h) - var(--sg-context-offset, 0px)) !important;
    border: 0; border-right: 1px solid var(--sg-line); border-radius: 0; box-shadow: none;
  }
  .project-page .sidebar .sidebar-section-title { padding-left: 24px; }
  .project-page .sidebar .sidebar-link { padding-left: 21px; }
  .project-page .content-area { padding-top: 20px; }
}
.project-page .sidebar-nav { padding: 12px 0; }
.project-page .sidebar-section { margin-bottom: 10px; }
.project-page .sidebar-section:last-child { margin-bottom: 0; }
.project-page .sidebar-section-title { padding: 0 14px; margin-bottom: 6px; font-size: 10px; letter-spacing: 0.07em; }
.project-page .sidebar-link {
  display: flex; align-items: center; padding: 8px 14px 8px 11px; cursor: pointer;
  color: var(--sg-ink-2); font-size: 13px; line-height: 1.4; text-decoration: none;
  border-left: 3px solid transparent; transition: background 0.15s, color 0.15s;
}
.project-page .sidebar-link:hover { background: var(--sg-surface-2); color: var(--sg-ink); }
.project-page .sidebar-link.active { background: var(--sg-accent-soft); color: var(--sg-accent-ink); font-weight: 600; border-left-color: var(--sg-accent); }
.project-page .sidebar-link i { width: 20px; margin-right: 6px; text-align: center; color: var(--sg-ink-3); }
.project-page .sidebar-link.active i { color: inherit; }
.project-page .sidebar-link i.sidebar-warning-icon { width: auto; margin: 0 0 0 6px; color: var(--sg-warning); }
.project-page .content-area { flex: 1; min-width: 0; }

/* header of the entity: tag, name, one line of facts */
.dash-banner { display: flex; align-items: flex-start; gap: 14px; padding: 2px 2px 10px; }
.contract-header { display: block; padding: 2px 2px 22px; }
.contract-header > .entity-tag { display: table; margin: 0 0 8px; }
.contract-header > .contract-header-title { font-size: 22px; line-height: 1.35; margin: 0 0 8px; overflow-wrap: anywhere; }
.contract-header > .contract-header-badge { display: inline-block; border-radius: var(--sg-radius-sm); }
.contract-header .contract-header-meta { margin-top: 16px; gap: 12px 28px; }
.contract-header .contract-header-field { gap: 3px; }

.dash-banner-content { flex: 1; min-width: 0; }
.customer-facing-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  /* the internal pages have the breadcrumb bar under the navbar, its height is --sg-context-offset */
  position: sticky; top: calc(var(--sg-nav-h) + var(--sg-context-offset, 0px)); z-index: 90;
  padding: 8px 14px; margin-bottom: 14px;
  background: var(--sg-info-soft); color: var(--sg-info-ink); border: 1px solid var(--sg-info); border-radius: var(--sg-radius);
  font-size: 13px;
}
.customer-facing-bar-unpublished { background: var(--sg-danger-soft); color: var(--sg-danger-ink); border-color: var(--sg-danger); }
.customer-facing-bar-internal { background: var(--sg-surface-2); color: var(--sg-ink-2); border-color: var(--sg-line-2); }
.customer-facing-bar-text { flex: 1; min-width: 0; }
.customer-facing-bar a { color: inherit; font-weight: 600; text-decoration: underline; }
.dash-banner-logo { width: 72px; height: 72px; object-fit: contain; flex-shrink: 0; }
.dash-banner-title, .contract-header-title { font-size: 24px; letter-spacing: -0.02em; font-weight: 600; margin: 0 0 3px; }
/* the active sidebar item behind the name, quieter than the name itself */
.dash-banner-section { font-weight: 400; color: var(--sg-ink-2); }
.dash-banner-description { font-size: 13px; color: var(--sg-ink-2); margin: 6px 0 0; }
.dash-banner-key-app, .contract-header-stage { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: var(--sg-radius-sm); background: var(--sg-surface-3); color: var(--sg-ink-2); font-size: 11px; }
.contract-header-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 12px; font-size: 13px; }
.contract-header-field { display: flex; flex-direction: column; min-width: 0; }
.user-facts { font-size: 12px; color: var(--sg-ink-2); margin-top: 4px; }
.user-facts span { margin-right: 14px; }
.user-state { display: inline-block; margin-right: 10px; font-size: 12px; color: var(--sg-ink-2); }

/* 6. cards ----------------------------------------------------------------------------------- */
.panel, .card, .dashboard-tile, .ds-card, .form-wrap {
  background: var(--sg-surface); border: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg);
  box-shadow: none; margin-bottom: 12px;
}
.panel-heading, .card-header {
  padding: 12px 16px; background: transparent; border-bottom: 1px solid var(--sg-line);
  border-radius: var(--sg-radius-lg) var(--sg-radius-lg) 0 0; color: var(--sg-ink-2); font-size: 12px;
}
.panel-heading::after { content: ""; display: table; clear: both; }
.panel-title, .card-title, .tile-title { font-size: 14px; font-weight: 600; color: var(--sg-ink); margin: 0; }
.panel-heading .btn { margin-top: -3px; }
.panel-body, .card-body { padding: 14px 16px; font-size: 13px; }
.panel-footer { background: var(--sg-surface-2); border-top: 1px solid var(--sg-line); border-radius: 0 0 var(--sg-radius-lg) var(--sg-radius-lg); padding: 8px 14px; }
.panel-primary > .panel-heading { background: var(--sg-accent-soft); color: var(--sg-accent-ink); border-color: var(--sg-accent-soft); }
.panel-primary > .panel-heading .panel-title { color: var(--sg-accent-ink); }
.panel > .table, .panel > .table-responsive > .table { margin-bottom: 0; }
.panel .panel-body > .table:last-child { margin-bottom: 0; }
.dashboard-tile { padding: 10px 12px; }
.tile-row { display: flex; flex-wrap: wrap; }
.tile-row > [class*="col-"] { display: flex; }
.tile-row > [class*="col-"] > .dashboard-tile { width: 100%; }
.dashboard-tile .tile-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; }
.tile-source { display: block; font-size: 10px; font-style: italic; color: var(--sg-ink-3); margin-top: 1px; }
.tile-count, .ds-count, .sidebar-count-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; min-height: 20px; padding: 2px 8px; margin-left: auto;
  border-radius: 10px; background: var(--sg-accent); color: #fff; font-size: 11px; font-weight: 600; line-height: 16px; white-space: nowrap; flex-shrink: 0;
}
.sidebar-count-badge { margin-left: 6px; height: 18px; min-width: 18px; background: var(--sg-danger); }
.section-subheader { margin: 0 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--sg-line); }
.form-wrap { padding: 14px 16px; }

/* 7. tables ---------------------------------------------------------------------------------- */
.table { margin-bottom: 8px; font-size: 13px; }
.table > thead > tr > th {
  padding: 10px 12px; border-bottom: 1px solid var(--sg-line-2); vertical-align: middle; background: var(--sg-surface-2);
  font-size: 12px; font-weight: 600; color: var(--sg-ink); line-height: 1.3;
}
.table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > th, .table > tfoot > tr > td { padding: 9px 12px; border-top: 1px solid var(--sg-line); vertical-align: middle; line-height: 1.45; color: var(--sg-ink); }
.table > tbody > tr > th { font-weight: 600; color: var(--sg-ink-2); }
.table-condensed > thead > tr > th, .table-condensed > tbody > tr > td, .table-condensed > tbody > tr > th { padding: 6px 10px; }
/* no stripes anywhere, rows are separated by the line between them */
.table-striped > tbody > tr:nth-of-type(odd) { background: transparent; }
.table-hover > tbody > tr:hover { background: var(--sg-accent-softer); }
.table-bordered, .table-bordered > thead > tr > th, .table-bordered > tbody > tr > td { border-color: var(--sg-line); }
.table .text-right, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.section-table-scroll { max-height: 420px; overflow-y: auto; }
.section-table-scroll thead th, .group-items-scroll thead th, .group-overview-scroll thead th { position: sticky; top: 0; background: var(--sg-surface); z-index: 1; }
.group-items-scroll { max-height: 245px; overflow-y: auto; border: 1px solid var(--sg-line); border-radius: var(--sg-radius-sm); margin-top: 4px; font-size: 12px; }
.group-overview-scroll { max-height: 640px; overflow: auto; margin-bottom: 16px; }
.expand-table-btn { margin: 8px 0; }

/* DataTables 1.13 */
.dataTables_wrapper { font-size: 13px; }
.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dt-buttons { margin-bottom: 6px; }
.dataTables_wrapper .dataTables_length label, .dataTables_wrapper .dataTables_filter label { font-weight: 400; font-size: 12px; color: var(--sg-ink-2); margin: 0; }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select {
  height: 32px; padding: 5px 10px; margin-left: 6px; border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); background: var(--sg-surface); color: var(--sg-ink); font-size: 12px;
}
.dataTables_wrapper .dataTables_filter input { width: 240px; max-width: 100%; }
.dataTables_wrapper .dataTables_filter input:focus, .dataTables_wrapper .dataTables_length select:focus { outline: 0; border-color: var(--sg-accent); box-shadow: 0 0 0 3px var(--sg-focus); }
/* separate, not collapse: sticky header cells jump around in a collapsed table */
table.dataTable { border-collapse: separate !important; border-spacing: 0; margin: 0 !important; }
table.dataTable.no-footer { border-bottom: 1px solid var(--sg-line); }
table.dataTable thead > tr > th, table.dataTable thead > tr > td { border-bottom: 1px solid var(--sg-line-2); padding: 11px 26px 11px 12px; background: var(--sg-surface-2); color: var(--sg-ink-2); font-size: 12px; font-weight: 600; line-height: 1.35; white-space: nowrap; }
table.dataTable tbody > tr > td, table.dataTable tbody > tr > th { padding: 10px 12px; border-top: 0; border-bottom: 1px solid var(--sg-line); vertical-align: middle; line-height: 1.45; font-variant-numeric: tabular-nums; }
table.dataTable.compact thead > tr > th { padding: 10px 24px 10px 12px; }
table.dataTable.compact tbody > tr > td { padding: 9px 12px; }
table.dataTable thead .sorting:before, table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:before, table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:before, table.dataTable thead .sorting_desc:after { color: var(--sg-ink-3); }
/* DataTables own sorting icons are too big and don't match the design system, so we hide them and add our own. */  
.dataTables_wrapper table.dataTable thead > tr > .sorting, .dataTables_wrapper table.dataTable thead > tr > .sorting_asc,
.dataTables_wrapper table.dataTable thead > tr > .sorting_desc, .dataTables_wrapper table.dataTable thead > tr > .sorting_asc_disabled,
.dataTables_wrapper table.dataTable thead > tr > .sorting_desc_disabled { padding-right: 12px; }
.dataTables_wrapper table.dataTable thead > tr > .sorting:before, .dataTables_wrapper table.dataTable thead > tr > .sorting_asc:before,
.dataTables_wrapper table.dataTable thead > tr > .sorting_desc:before, .dataTables_wrapper table.dataTable thead > tr > .sorting_asc_disabled:before,
.dataTables_wrapper table.dataTable thead > tr > .sorting_desc_disabled:before { display: none; }
.dataTables_wrapper table.dataTable thead > tr > .sorting:after, .dataTables_wrapper table.dataTable thead > tr > .sorting_asc:after,
.dataTables_wrapper table.dataTable thead > tr > .sorting_desc:after, .dataTables_wrapper table.dataTable thead > tr > .sorting_asc_disabled:after,
.dataTables_wrapper table.dataTable thead > tr > .sorting_desc_disabled:after {
  position: static; display: inline-block; margin-left: 6px; vertical-align: middle; white-space: pre; line-height: 9px; font-size: .8em; opacity: .3; content: "\25B2\A\25BC";
}
.dataTables_wrapper table.dataTable thead > tr > .sorting_asc:after { content: "\25B2"; opacity: .75; }
.dataTables_wrapper table.dataTable thead > tr > .sorting_desc:after { content: "\25BC"; opacity: .75; }
.dataTables_wrapper table.dataTable thead > tr > .sorting_desc_disabled:after { content: "\25B2"; }
.dataTables_wrapper table.dataTable thead > tr > .sorting_asc_disabled:after { content: "\25BC"; }
table.dataTable.hover tbody tr:hover, table.dataTable.display tbody tr:hover, table.dataTable.hover tbody tr:hover > .sorting_1 { background: var(--sg-accent-softer); }
/* no stripes on any list, only the hover tint */
table.dataTable > tbody > tr.odd > *, table.dataTable > tbody > tr.even > *, table.dataTable > tbody > tr > .sorting_1 { background: transparent; box-shadow: none; }
table.dataTable.stripe > tbody > tr.odd > *, table.dataTable.display > tbody > tr.odd > * { box-shadow: none; background: transparent; }
table.dataTable.hover > tbody > tr:hover > *, table.dataTable.display > tbody > tr:hover > * { box-shadow: inset 0 0 0 9999px var(--sg-accent-softer); }
table.dataTable tbody > tr.selected > * { box-shadow: inset 0 0 0 9999px var(--sg-accent-soft) !important; color: inherit !important; }
table.dataTable tbody > tr.selected a { color: var(--sg-accent-ink) !important; }
/* beats DataTables' own position: relative on sortable cells, otherwise only its top offset would apply */
.v2-page .dataTables_wrapper table.dataTable thead > tr > th,
.v2-page .dataTables_wrapper table.dataTable thead > tr > td { position: sticky; top: 0; background: var(--sg-surface-2); z-index: 2; }
.v2-page .dataTables_wrapper { background: var(--sg-surface); border: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg); padding: 14px 16px 12px; overflow-x: auto; isolation: isolate; }
.v2-page .dataTables_wrapper .dataTables_length, .v2-page .dataTables_wrapper .dataTables_filter, .v2-page .dataTables_wrapper .dt-buttons { margin-bottom: 10px; }
.v2-page .dataTables_wrapper .dataTables_info, .v2-page .dataTables_wrapper .dataTables_paginate { padding-top: 14px; }
table.dataTable { background: var(--sg-surface); }
.dataTables_wrapper .dataTables_info { padding-top: 8px; font-size: 12px; color: var(--sg-ink-3); }
.dataTables_wrapper .dataTables_paginate { padding-top: 6px; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 6px 10px; margin: 0 2px; border: 1px solid transparent; border-radius: var(--sg-radius);
  color: var(--sg-ink-2) !important; font-size: 12px; background: transparent;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover { color: var(--sg-ink) !important; border-color: transparent; background: var(--sg-surface-3); }
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover { color: var(--sg-accent-ink) !important; background: var(--sg-accent-soft); border-color: transparent; font-weight: 600; }
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover { color: var(--sg-ink-3) !important; background: transparent; }

.dataTables_wrapper .dataTables_processing {
  top: 48px; margin-top: 0;
  z-index: 5; padding: 10px 16px; border: 1px solid var(--sg-line); border-radius: var(--sg-radius); background: var(--sg-surface); box-shadow: var(--sg-shadow-lg); color: var(--sg-ink-2); font-size: 12px;
}
div.dt-buttons button.dt-button, div.dt-buttons a.dt-button {
  padding: 5px 10px; border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); background: var(--sg-surface); color: var(--sg-ink); font-size: 12px; box-shadow: none;
}
div.dt-buttons button.dt-button:hover { background: var(--sg-surface-2); border-color: var(--sg-ink-3); }
.table-responsive { border: 0; }

/* Table content keeps a quiet hierarchy: record names first, metadata second. */
.v2-page table.dataTable tbody > tr > td:first-child { min-width: 180px; font-weight: 500; }
.v2-page table.dataTable tbody > tr > td { max-width: 360px; overflow-wrap: break-word; }
table.dataTable tbody > tr:last-child > td { border-bottom: 0; }
table.dataTable tfoot > tr > th, table.dataTable tfoot > tr > td { background: var(--sg-surface-2); border-top: 1px solid var(--sg-line); padding: 10px 12px; font-weight: 400; }
.dataTables_wrapper .dataTables_empty { padding: 36px 16px !important; color: var(--sg-ink-2); }
.sg-toolbar { min-height: 34px; margin-bottom: 12px; }
.sg-toolbar input[type="checkbox"] { accent-color: var(--sg-accent); }
:where(a, button, input, select, textarea):focus-visible { outline: 2px solid var(--sg-accent); outline-offset: 3px; }
@media (max-width: 767px) {
  .sg-main { padding: calc(var(--sg-nav-h) + 16px) 12px 24px; }
  .sg-page-head h1, .sg-page-head legend { font-size: 21px; }
}

/* 8. forms ----------------------------------------------------------------------------------- */
label { font-size: 12px; font-weight: 600; color: var(--sg-ink-2); margin-bottom: 4px; }
.checkbox label, .radio label, .checkbox-inline, .radio-inline, label.items-filters-option { font-size: 13px; font-weight: 400; color: var(--sg-ink); }
.form-group { margin-bottom: 10px; }
.form-control {
  height: 30px; padding: 4px 9px; font-size: 13px; line-height: 20px; color: var(--sg-ink);
  background: var(--sg-surface); border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); box-shadow: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { border-color: var(--sg-accent); box-shadow: 0 0 0 3px var(--sg-focus); }
.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control, input[readonly], select[disabled] { background: var(--sg-surface-2); color: var(--sg-ink-2); cursor: not-allowed; opacity: 1; }
textarea.form-control { height: auto; resize: vertical; }
select.form-control { padding-right: 24px; }
.input-sm, .form-group-sm .form-control { height: 26px; padding: 2px 7px; font-size: 12px; border-radius: var(--sg-radius-sm); }
.input-lg { height: 40px; font-size: 14px; }
.input-group-addon { border-color: var(--sg-line-2); background: var(--sg-surface-2); color: var(--sg-ink-2); border-radius: var(--sg-radius); }
.help-block { font-size: 11px; color: var(--sg-ink-3); margin: 4px 0 0; }
.has-error .form-control { border-color: var(--sg-danger); }
.has-error .help-block, .has-error .control-label, .field-error { color: var(--sg-danger-ink); font-size: 12px; }
.field-hint { font-size: 11px; color: var(--sg-ink-3); }
.required .form-control { border-color: var(--sg-danger); }
/* key: value form tables */
.sg-form-table th, .edit-user-page table.table th { width: 200px; font-weight: 600; color: var(--sg-ink-2); vertical-align: middle; }
.edit-user-page table.table td { vertical-align: middle; }
.edit-user-page td ul { list-style: none; padding: 0; margin: 0; }
.edit-user-page td ul li label { font-weight: 400; margin: 0; }
.edit-user-page, .viewer-edit { max-width: 900px; margin: 0 auto; }
/* checkbox lists rendered by bootstrapform */
div.form-group ul { padding: 0; margin-top: 6px; list-style: none; }
div.form-group li label { font-weight: 400; }
/* buttons */
.btn {
  padding: 5px 11px; font-size: 13px; font-weight: 500; line-height: 18px; border-radius: var(--sg-radius);
  border: 1px solid transparent; box-shadow: none; text-transform: none; letter-spacing: normal; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:focus, .btn:active:focus { outline: 0; box-shadow: 0 0 0 3px var(--sg-focus); }
.btn .fa, .btn .fas, .btn .glyphicon { margin-right: 2px; }
.btn-default, .btn-light, .btn-secondary { background: var(--sg-surface); border-color: var(--sg-line-2); color: var(--sg-ink); }
.btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active,
.btn-light:hover, .btn-light:focus, .btn-secondary:hover, .btn-secondary:focus { background: var(--sg-surface-2); border-color: var(--sg-ink-3); color: var(--sg-ink); }
.btn-light { background: var(--sg-surface-2); border-color: var(--sg-line); color: var(--sg-ink-2); }
.btn-primary { background: var(--sg-accent); border-color: var(--sg-accent); color: #fff; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active { background: #3c7db0; border-color: #3c7db0; color: #fff; }
.btn-success { background: var(--sg-success); border-color: var(--sg-success); color: #fff; }
.btn-success:hover, .btn-success:focus { background: #257347; border-color: #257347; }
.btn-info { background: var(--sg-accent-soft); border-color: var(--sg-accent-soft); color: var(--sg-accent-ink); }
.btn-info:hover, .btn-info:focus { background: #d3e1ee; border-color: #d3e1ee; color: var(--sg-accent-ink); }
.btn-warning { background: var(--sg-warning-soft); border-color: #f0c36d; color: var(--sg-warning-ink); }
.btn-warning:hover, .btn-warning:focus { background: #fbe3c4; border-color: #e8b25a; color: #7a3f08; }
.btn-danger { background: var(--sg-danger-soft); border-color: #f1b9be; color: var(--sg-danger-ink); }
.btn-danger:hover, .btn-danger:focus { background: var(--sg-danger); border-color: var(--sg-danger); color: #fff; }
.btn-link { color: var(--sg-accent-ink); }
.btn-sm, .btn-group-sm > .btn { padding: 3px 9px; font-size: 12px; line-height: 18px; }
.btn-xs, .btn-group-xs > .btn { padding: 1px 6px; font-size: 11px; line-height: 16px; border-radius: var(--sg-radius-sm); }
.btn-lg { padding: 9px 18px; font-size: 14px; }
.btn[disabled], .btn.disabled { opacity: 0.5; }
.btn-group > .btn + .btn { margin-left: -1px; }
/* pill switch between two tables */
.table-toggle { display: inline-flex; padding: 3px; gap: 2px; background: var(--sg-surface-3); border: 1px solid var(--sg-line); border-radius: var(--sg-radius); }
.table-toggle .btn { min-width: 0; border: 0; border-radius: var(--sg-radius-sm); background: transparent; color: var(--sg-ink-2); box-shadow: none; margin: 0; }
.table-toggle .btn:hover { color: var(--sg-ink); background: transparent; }
.table-toggle .btn.active { background: var(--sg-surface); color: var(--sg-ink); font-weight: 600; box-shadow: var(--sg-shadow); }
/* tabs */
.nav-tabs { border-bottom: 1px solid var(--sg-line); margin-bottom: 16px; }
.nav-tabs > li { margin-bottom: -1px; }
.nav-tabs > li > a { padding: 6px 12px; margin-right: 2px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--sg-ink-2); font-weight: 500; }
.nav-tabs > li > a:hover { background: transparent; border-color: transparent; border-bottom-color: var(--sg-line-2); color: var(--sg-ink); }
.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus { border: 0; border-bottom: 2px solid var(--sg-accent); background: transparent; color: var(--sg-accent-ink); font-weight: 600; }
.progress { height: 8px; margin-bottom: 0; border-radius: 999px; background: var(--sg-line); box-shadow: none; }
.progress-bar { background: var(--sg-accent); box-shadow: none; }
.progress-bar-success { background: var(--sg-success); } .progress-bar-danger { background: var(--sg-danger); }

/* 9. overlays -------------------------------------------------------------------------------- */
.modal-content { border: 0; border-radius: 10px; box-shadow: var(--sg-shadow-lg); }
.modal-header { padding: 12px 18px; border-bottom: 1px solid var(--sg-line); }
.modal-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.modal-header .close { margin-top: 0; font-size: 20px; color: var(--sg-ink-2); opacity: 0.7; text-shadow: none; }
.modal-header .close:hover { opacity: 1; }
.modal-body { padding: 14px 18px; max-height: calc(100vh - 170px); overflow-y: auto; }
.modal-footer { padding: 10px 18px; border-top: 1px solid var(--sg-line); }
.modal-footer .btn + .btn { margin-left: 6px; }
.modal { overflow-y: auto !important; }
.modal-backdrop.in { opacity: 0.4; }

.dropdown-menu { padding: 6px 0; border: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg); box-shadow: var(--sg-shadow-lg); font-size: 13px; max-height: calc(100vh - var(--sg-nav-h) - 20px); overflow-y: auto; }
.dropdown-menu > li > a { padding: 5px 12px; color: var(--sg-ink); }
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus { background: var(--sg-surface-2); color: var(--sg-ink); }
.dropdown-menu > .active > a, .dropdown-menu > .active > a:hover { background: var(--sg-accent-soft); color: var(--sg-accent-ink); }
.dropdown-menu .divider { margin: 5px 0; background: var(--sg-line); }
.dropdown-header { padding: 4px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sg-ink-3); }

.popover { border: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg); box-shadow: var(--sg-shadow-lg); font-family: inherit; font-size: 12px; max-width: 350px; }
.popover-title { background: var(--sg-surface-2); border-bottom: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg) var(--sg-radius-lg) 0 0; font-size: 12px; font-weight: 600; }
.tooltip-inner { background: var(--sg-ink); border-radius: var(--sg-radius-sm); font-size: 12px; padding: 5px 9px; }
/* plain css tooltip, used in the contract forms */
.field-tooltip { position: relative; display: inline-block; margin-left: 5px; cursor: help; }
.field-tooltip .tooltip-icon { color: var(--sg-accent); font-size: 12px; }
.field-tooltip .tooltip-content {
  visibility: hidden; opacity: 0; position: absolute; z-index: 9999; bottom: 125%; left: 50%; transform: translateX(-50%);
  width: 280px; padding: 10px 12px; border-radius: var(--sg-radius); background: var(--sg-ink); color: #fff; font-size: 11px; font-weight: 400; line-height: 1.5;
  white-space: pre-wrap; box-shadow: var(--sg-shadow-lg); transition: opacity 0.15s, visibility 0.15s;
}
.field-tooltip .tooltip-content::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--sg-ink); }
.field-tooltip:hover .tooltip-content { visibility: visible; opacity: 1; }
th .field-tooltip .tooltip-content { left: 0; transform: none; }
th .field-tooltip .tooltip-content::after { left: 15px; }

/* select2, prefixed with body so it wins over select2.css whatever the load order */
body .select2-container { font-size: 13px; }
body .select2-container--default .select2-selection--single { height: 32px; border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); background: var(--sg-surface); }
body .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 30px; padding-left: 10px; padding-right: 26px; color: var(--sg-ink); }
body .select2-container--default .select2-selection--single .select2-selection__arrow { height: 30px; }
body .select2-container--default .select2-selection--multiple { min-height: 32px; padding: 1px 4px; border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); }
body .select2-container--default .select2-selection--multiple .select2-selection__choice { margin: 4px 4px 0 0; padding: 1px 6px; border: 0; border-radius: var(--sg-radius-sm); background: var(--sg-accent-soft); color: var(--sg-accent-ink); font-size: 12px; }
body .select2-container--default .select2-selection--multiple .select2-selection__choice__remove { color: var(--sg-accent-ink); margin-right: 4px; }
body .select2-container--default .select2-selection--multiple .select2-selection__choice__display { padding-left: 18px; }
body .select2-container--default.select2-container--open .select2-selection--single,
body .select2-container--default.select2-container--focus .select2-selection--multiple { border-color: var(--sg-accent); box-shadow: 0 0 0 3px var(--sg-focus); }
body .select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--sg-ink-3); }
body .select2-dropdown { border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); box-shadow: var(--sg-shadow-lg); font-size: 13px; }
body .select2-container--default .select2-search--dropdown .select2-search__field { padding: 5px 8px; border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius-sm); }
body .select2-container--default .select2-results__option { padding: 6px 10px; }
body .select2-container--default .select2-results__option--highlighted[aria-selected],
body .select2-container--default .select2-results__option--highlighted { background: var(--sg-accent-soft); color: var(--sg-ink); }
body .select2-container--default .select2-results__option[aria-selected="true"] { background: var(--sg-surface-3); }
/* sweetalert2 (injects its own css at runtime, hence body prefix) */
body .swal2-popup { font-family: var(--sg-font); font-size: 14px; border-radius: 10px; padding: 24px; }
body .swal2-title { font-size: 18px; font-weight: 600; color: var(--sg-ink); }
body .swal2-content, body .swal2-html-container { font-size: 13px; color: var(--sg-ink-2); }
body .swal2-styled.swal2-confirm { border-radius: var(--sg-radius); font-size: 13px; font-weight: 500; background: var(--sg-accent); }
body .swal2-styled.swal2-cancel { border-radius: var(--sg-radius); font-size: 13px; font-weight: 500; }
/* scale the icon through font-size only: SweetAlert draws the ring and the check/x lines in em for its 5em box,
   so a smaller width/height makes them spill over the title */
body .swal2-icon { margin: 0.5em auto 0.3em; font-size: 0.8em; }

/* 10. feedback -------------------------------------------------------------------------------- */
.alert { padding: 8px 12px; margin-bottom: 10px; border: 1px solid transparent; border-radius: var(--sg-radius); font-size: 13px; }
.alert .close { top: 0; right: -4px; }
.alert-success { background: var(--sg-success-soft); border-color: #bfe3cf; color: var(--sg-success-ink); }
.alert-info, .alert-primary { background: var(--sg-info-soft); border-color: #c6d9ea; color: var(--sg-info-ink); }
.alert-warning { background: var(--sg-warning-soft); border-color: #f0c36d; color: var(--sg-warning-ink); }
.alert-danger, .alert-error { background: var(--sg-danger); border-color: var(--sg-danger); color: #fff; }
.alert-danger .label-danger, .alert-error .label-danger { background: transparent; color: inherit; }
.alert a { color: inherit; font-weight: 600; }
.bg-success, .bg-info, .bg-warning, .bg-danger { border-radius: var(--sg-radius); }
.bg-success { background: var(--sg-success-soft); color: var(--sg-success-ink); }
.bg-info { background: var(--sg-info-soft); color: var(--sg-info-ink); }
.bg-warning { background: var(--sg-warning-soft); color: var(--sg-warning-ink); }
.bg-danger { background: var(--sg-danger-soft); color: var(--sg-danger-ink); }

/* badges and labels: soft fill, dark text of the same hue, so they read as text as well as colour */
.label, .badge, .item-card-tag, .item-card-badge, .ds-badge, .sg-tag, .dash-badge, .contract-header-badge, .ps-status, .alert-level-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.4; white-space: nowrap; vertical-align: baseline;
  background: var(--sg-surface-3); color: var(--sg-ink-2);
}
.badge { min-width: 20px; text-align: center; padding: 2px 7px; }
.label-default, .badge { background: var(--sg-surface-3); color: var(--sg-ink-2); }
.label-primary, .label-info, .badge.good, .item-card-new { background: var(--sg-accent-soft); color: var(--sg-accent-ink); }
.label-success, .contract-header-badge-confirmed { background: var(--sg-success-soft); color: var(--sg-success-ink); }
.dash-badge-published { background: #ffc107; color: #000; }
.label-warning, .item-card-badge.is-expiring, .contract-header-badge-open, .map-hidden-badge, .map-access-partly-expired { background: var(--sg-warning-soft); color: var(--sg-warning-ink); }
.label-danger, .item-card-badge.is-expired, .map-access-expired { background: var(--sg-danger-soft); color: var(--sg-danger-ink); }
.dash-badge-hidden, .not-published-badge, .project-page .not-published-badge { background: var(--sg-danger); color: #fff; }
.staff-badge, .sg-tag-staff, .todo-badge, .sidebar-title-badge { margin-left: 6px; padding: 1px 6px; font-size: 9px; letter-spacing: 0.04em; text-transform: uppercase; border-radius: var(--sg-radius-sm); }
.staff-badge, .sg-tag-staff { background: var(--sg-accent-soft); color: var(--sg-accent-ink); }
.todo-badge, .sidebar-title-badge { background: var(--sg-warning-soft); color: var(--sg-warning-ink); }
.not-published-badge { margin-left: 6px; padding: 1px 6px; font-size: 9px; text-transform: uppercase; border-radius: var(--sg-radius-sm); }
/* entity tag above a title */
.entity-tag { display: inline-block; padding: 2px 10px; margin-bottom: 8px; border-radius: var(--sg-radius-sm); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #fff; background: var(--sg-ink-3); }
.entity-tag-project { background: var(--sg-project); }
.entity-tag-contract { background: var(--sg-contract); }
.entity-tag-organization { background: var(--sg-organization); }
.entity-tag-user { background: var(--sg-user); }
/* map alert levels keep their domain colours, text and a shape go with them in the markup */
.alert-level-badge { min-width: 54px; text-align: center; text-transform: uppercase; font-size: 10px; letter-spacing: 0.3px; color: #fff; }
.alert-level-badge.alert-red { background: #d9534f; } .alert-level-badge.alert-orange { background: #e8963c; }
.alert-level-badge.alert-yellow { background: #e5c92a; color: #4a4000; } .alert-level-badge.alert-green { background: #5cb85c; } .alert-level-badge.alert-grey { background: #9aa5b1; }
.alert-banner { margin: 0 0 12px; padding: 6px 12px; border-radius: var(--sg-radius); font-size: 12px; font-weight: 600; color: #fff; }
.alert-banner a { color: #fff; text-decoration: underline; }
.org-alert-dot, .tile-dot, .ds-dot, .calendar-event-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; flex-shrink: 0; }
.tile-dot, .calendar-event-dot { width: 8px; height: 8px; margin-top: 4px; }

.empty-state, .tile-list-empty, .ds-empty, .ps-empty { text-align: center; padding: 20px 16px; color: var(--sg-ink-3); font-size: 13px; }
.empty-state i, .ps-empty i { display: block; font-size: 32px; color: var(--sg-line-2); margin-bottom: 10px; }
.empty-state h4 { font-size: 15px; color: var(--sg-ink-2); margin: 0 0 6px; }
.empty-state p { margin: 0 0 14px; }
.tile-list-empty { padding: 8px 6px; font-size: 12px; }

/* section loading: the old section dims, a spinner box floats over it */
.section-loading { display: none; padding: 32px; font-size: 13px; color: var(--sg-ink-2); }
.htmx-request .section-loading, .htmx-request.section-loading { display: block; }
#project-section-content, #contract-section-content { position: relative; min-height: 120px; }
#project-section-content.htmx-request > *, #contract-section-content.htmx-request > * { opacity: 0.35; pointer-events: none; transition: opacity 0.15s; }
#project-section-content.htmx-request::before, #contract-section-content.htmx-request::before {
  content: ""; position: absolute; z-index: 20; top: 48px; left: 50%; width: 22px; height: 22px; margin-left: -58px;
  border: 3px solid var(--sg-line); border-top-color: var(--sg-accent); border-radius: 50%; animation: sg-spin 0.8s linear infinite;
}
#project-section-content.htmx-request::after, #contract-section-content.htmx-request::after {
  content: "Loading..."; position: absolute; z-index: 19; top: 36px; left: 50%; transform: translateX(-50%);
  padding: 12px 18px 12px 58px; background: var(--sg-surface); border: 1px solid var(--sg-line); border-radius: var(--sg-radius); box-shadow: var(--sg-shadow-lg); font-size: 13px;
}
@keyframes sg-spin { to { transform: rotate(360deg); } }
.loader { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--sg-line); border-top-color: var(--sg-accent); border-radius: 50%; animation: sg-spin 1s linear infinite; }

/* 11. entity accents: the sidebar page takes the colour of what it shows -------------------- */



.contract-page .sidebar-link:hover { background: var(--sg-contract-softer); color: var(--sg-contract-ink); }
.contract-page .sidebar-link.active { background: var(--sg-contract-soft); color: var(--sg-contract-ink); border-left-color: var(--sg-contract); }
.contract-page .tree-link, .contract-page .project-back-link:hover { color: var(--sg-contract-ink); }
.organization-page .sidebar-link:hover, .project-page .mode-organization .sidebar-link:hover { background: var(--sg-organization-softer); color: var(--sg-organization-ink); }
.organization-page .sidebar-link.active, .project-page .mode-organization .sidebar-link.active { background: var(--sg-organization-soft); color: var(--sg-organization-ink); border-left-color: var(--sg-organization); }
.organization-page .dash-banner-title { color: var(--sg-organization-ink); }
.user-page .sidebar-link:hover { background: var(--sg-user-softer); color: var(--sg-user-ink); }
.user-page .sidebar-link.active { background: var(--sg-user-soft); color: var(--sg-user-ink); border-left-color: var(--sg-user); }
.user-page .dash-banner-title { color: var(--sg-user-ink); }
.project-page .org-nav { border-bottom-color: var(--sg-organization); }
.org-nav { margin-top: -8px; padding: 10px 14px; }
.project-page .mode-project .org-nav { border-bottom-color: var(--sg-project); }

/* 12. mobile --------------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .sg-main { padding-left: 12px; padding-right: 12px; }
  nav.navbar-menu .navbar-toggle { display: block; }
  nav.navbar-menu .navbar-collapse {
    position: absolute; top: var(--sg-nav-h); left: 0; right: 0; padding: 6px 0;
    background: var(--sg-surface); border-top: 1px solid var(--sg-line); box-shadow: var(--sg-shadow-lg);
    max-height: calc(100vh - var(--sg-nav-h)); overflow-y: auto;
  }
  nav.navbar-menu > .container-fluid { display: block; height: auto; }
  nav.navbar-menu .navbar-collapse.collapse { display: none !important; }
  nav.navbar-menu .navbar-collapse.collapse.in { display: block !important; }
  nav.navbar-menu .navbar-nav { display: block; height: auto; margin: 0; }
  nav.navbar-menu .navbar-nav > li { margin: 0; }
  nav.navbar-menu .navbar-nav > li > a { border-radius: 0; padding: 10px 16px; }
  nav.navbar-menu .navbar-nav > li.open::after { display: none; }
  nav.navbar-menu .navbar-nav .open .dropdown-menu { position: static; float: none; margin: 0; padding: 0 0 6px; border: 0; box-shadow: none; background: var(--sg-surface-2); max-height: none; }
  nav.navbar-menu .navbar-nav .open .dropdown-menu > li > a { padding: 8px 16px 8px 32px; }
  .sg-page-head { flex-direction: column; align-items: stretch; }
  .sg-page-actions { justify-content: flex-start; min-width: 0; }
  .project-banner { padding: 10px 12px; margin-left: -12px; margin-right: -12px; }
  .project-banner-top { flex-wrap: wrap; gap: 8px; }
  .project-tree .tree-row { white-space: normal; grid-template-columns: 16px 80px minmax(0, 1fr); }
  .project-tree .tree-row-org { grid-template-columns: 0 80px minmax(0, 1fr); }
  .project-tree .tree-row-project { padding-left: 16px; }
  .project-tree .tree-row-contract { padding-left: 32px; }
  .dash-banner-logo { display: none; }
  .dash-banner-title, .contract-header-title { font-size: 21px; letter-spacing: -0.02em; }
  .contract-header-meta { gap: 6px 16px; }
  /* the sidebar becomes a scrolling row of pills above the content */
  .project-page { display: block; }
  .project-page .sidebar { width: auto; min-width: 0; position: static; max-height: none !important; overflow: visible; margin-bottom: 12px; }
  .project-page .sidebar-nav { padding: 6px 8px; }
  .project-page .sidebar-section { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 0 6px 6px 0; vertical-align: top; }
  .project-page .sidebar-section-title { display: none; }
  .project-page .sidebar-link { padding: 6px 12px; border: 1px solid var(--sg-line-2); border-left-width: 1px; border-radius: 999px; background: var(--sg-surface); font-size: 12px; }
  .project-page .sidebar-link i { width: auto; margin-right: 5px; }
  .project-page .sidebar-link.active { border-color: currentColor; border-left-color: currentColor; }
  .project-page .org-nav { margin: -6px -8px 8px; border-radius: var(--sg-radius-lg) var(--sg-radius-lg) 0 0; }
  /* wide tables scroll sideways instead of breaking the page */
  .v2-page .dataTables_wrapper { overflow-x: auto; padding: 6px; }
  .v2-page .dataTables_wrapper table.dataTable thead > tr > th,
  .v2-page .dataTables_wrapper table.dataTable thead > tr > td { position: relative; top: 0; }
  .dataTables_wrapper .dataTables_filter input { width: 160px; }
  .table-toggle .btn { min-width: 0; }
  /* dialogs take the screen, fixed inline widths are dropped */
  .modal-dialog, .modal-dialog[style] { width: auto !important; max-width: none !important; margin: 10px; }
  .modal-body { max-height: none; }
  .edit-user-page, .viewer-edit { padding: 0; }
}
@media (min-width: 768px) and (max-width: 1100px) {
  .modal-dialog[style] { width: auto !important; max-width: calc(100vw - 40px) !important; margin: 20px auto; }
}

/* 13. widgets: layout that no primitive covers. Colours and type come from the tokens above. ----- */

/* sidebar: the organization / project picker block of the customer dashboard */
.org-nav { margin: -12px 0 14px; padding: 14px 16px 12px; background: linear-gradient(180deg, #5b7089 0%, #6a7f99 100%); color: #fff; border-bottom: 3px solid var(--sg-organization); }
.org-nav .org-nav-label { display: block; color: #dde5ee; margin: 0 0 3px; }
.org-nav-name { font-size: 15px; font-weight: 600; line-height: 1.3; word-wrap: break-word; }
.org-nav-select { width: 100%; margin-top: 4px; padding: 6px 8px; font-size: 13px; color: var(--sg-ink); background: #fff; border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius-sm); }
.org-nav-button { display: block; margin-top: 10px; padding: 7px 10px; font-size: 12px; font-weight: 600; text-align: center; color: var(--sg-ink); background: #fff; border-radius: var(--sg-radius-sm); text-decoration: none; }
.org-nav-button:hover { background: var(--sg-surface-3); color: var(--sg-ink); text-decoration: none; }

/* tiles: one figure, a list, a ranking */
.tile-number { text-align: center; margin: 4px 0 12px; }
.tile-number-value, .ds-kpi-value, .staff-dash-figure { font-size: 36px; font-weight: 300; line-height: 1.1; letter-spacing: -0.01em; color: var(--sg-ink); }
.staff-dash-figure { font-size: 18px; }
.tile-number-label, .ds-kpi-label, .staff-dash-label { font-size: 12px; color: var(--sg-ink-2); }
.tile-number-meta, .ds-kpi-meta { font-size: 11px; color: var(--sg-ink-3); margin-top: 2px; }
.tile-list { max-height: 300px; overflow-y: auto; }
.tile-list-item { display: flex; align-items: flex-start; padding: 5px 6px; border-top: 1px solid var(--sg-line); font-size: 12px; color: var(--sg-ink); text-decoration: none; }
a.tile-list-item:hover { background: var(--sg-surface-2); text-decoration: none; }
.tile-list-body { flex: 1; min-width: 0; }
.tile-list-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-list-meta { font-size: 11px; color: var(--sg-ink-2); }
.tile-list-text { font-size: 11px; color: var(--sg-ink-2); margin-top: 2px; }
.insight-table, .rank-table { width: 100%; font-size: 12px; }
.insight-table th, .insight-table td, .rank-table td { padding: 3px 4px; border-top: 1px solid var(--sg-line); vertical-align: top; }
.insight-table th { font-weight: 600; }
.insight-template-row th { background: var(--sg-surface-2); font-size: 11px; white-space: nowrap; }
.insight-count { text-align: right; white-space: nowrap; }
.rank-scroll { max-height: 160px; overflow-y: auto; }
.rank-position { width: 18px; color: var(--sg-ink-3); font-size: 11px; }
.rank-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.rank-bar-cell { width: 45%; }
.rank-bar { display: block; height: 8px; min-width: 2px; border-radius: 2px; background: var(--sg-accent); }
.rank-count { width: 32px; text-align: right; font-weight: 600; }
.staff-dash-chart { position: relative; height: 220px; }
.staff-dash-list { max-height: 220px; overflow-y: auto; font-size: 12px; }
.user-group-card {
  background: var(--sg-surface); border: 1px solid var(--sg-line-2);
  border-radius: var(--sg-radius-lg); padding: 16px; margin-bottom: 24px;
  box-shadow: 0 2px 5px rgba(16, 24, 40, 0.07);
  scroll-margin-top: calc(var(--sg-nav-h) + var(--sg-context-offset, 0px) + 16px);
}
.user-group-card-header {
  background: var(--sg-surface-2); border-bottom: 1px solid var(--sg-line-2);
  border-radius: var(--sg-radius-lg) var(--sg-radius-lg) 0 0;
  margin: -16px -16px 14px; padding: 12px 16px;
}
.user-group-card:last-child { margin-bottom: 0; }
/* A compact status strip keeps the group's users and content prominent. */
.user-group-access {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 6px 16px; padding: 9px 12px; margin-bottom: 14px;
  border: 1px solid var(--sg-line); border-left-width: 3px;
  border-radius: var(--sg-radius-sm); font-size: 12px; line-height: 1.5;
}
.user-group-access-message { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.user-group-access-message > span { color: var(--sg-ink-2); }
.user-group-access-date { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; }
.user-group-access-expired { background: #fff8f8; border-color: #efd3d6; border-left-color: var(--sg-danger); color: var(--sg-danger-ink); }
.user-group-access-active { background: #f5faf7; border-color: #d9e9df; border-left-color: var(--sg-success); color: var(--sg-success-ink); }


/* status timeline: rows of bars on a date axis */
.ctimeline-row { display: flex; align-items: center; height: 26px; }
.ctimeline-row:nth-child(odd) { background: var(--sg-surface-2); }
.ctimeline-label { flex: 0 0 130px; width: 130px; padding-right: 10px; text-align: right; font-size: 12px; color: var(--sg-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctimeline-track { position: relative; flex: 1; height: 100%; border-left: 1px solid var(--sg-line-2); }
.ctimeline-axis { height: 20px; }
.ctimeline-axis .ctimeline-track { border-left: 0; }
.ctimeline-tick { position: absolute; top: 0; transform: translateX(-50%); font-size: 11px; color: var(--sg-ink-3); white-space: nowrap; }
.ctimeline-grid { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--sg-line); }
.ctimeline-today { position: absolute; top: 0; bottom: 0; border-left: 2px dashed var(--sg-danger); z-index: 2; }
.ctimeline-item { position: absolute; top: 50%; z-index: 3; cursor: default; }
.ctimeline-bar { height: 11px; min-width: 3px; margin-top: -5px; border-radius: 2px; }
.ctimeline-point { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; box-shadow: 0 0 0 2px #fff; }
.ctimeline-tip, .calendar-tip { display: none; position: absolute; left: 50%; transform: translateX(-50%); z-index: 20; width: 260px; padding: 8px 10px; background: var(--sg-surface); border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); box-shadow: var(--sg-shadow-lg); white-space: normal; text-align: left; }
.ctimeline-tip { bottom: 18px; }
.ctimeline-item:hover .ctimeline-tip, .calendar-day:hover .calendar-tip { display: block; }
.ctimeline-tip-date, .calendar-tip-line { font-size: 11px; color: var(--sg-ink-2); }
.ctimeline-tip-title { font-size: 13px; font-weight: 600; margin: 2px 0 4px; word-wrap: break-word; }
.ctimeline-tip-line { font-size: 12px; line-height: 1.4; word-wrap: break-word; }
.ctimeline-legend { margin-top: 8px; font-size: 11px; color: var(--sg-ink-3); }
.ctimeline-legend-today { display: inline-block; width: 14px; border-top: 2px dashed var(--sg-danger); vertical-align: middle; margin-right: 4px; }

/* calendar */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--sg-line); border: 1px solid var(--sg-line); border-radius: var(--sg-radius-sm); overflow: hidden; }
.calendar-header { background: var(--sg-ink-2); color: #fff; padding: 4px; text-align: center; font-weight: 600; font-size: 10px; }
.calendar-day { position: relative; min-height: 40px; padding: 4px; background: var(--sg-surface); }
.calendar-day:hover { z-index: 30; }
.calendar-day-number { font-size: 10px; font-weight: 600; color: var(--sg-ink-2); }
.calendar-day.other-month { background: var(--sg-surface-2); }
.calendar-day.today { box-shadow: inset 0 0 0 2px var(--sg-accent); }
.calendar-day.contract-day { background: #f8d7da; } .calendar-day.meeting-day { background: #d1e7dd; } .calendar-day.report-day { background: #e2d9f3; }
.calendar-day.delivery-day { background: #f0f3d9; } .calendar-day.event-day { background: #b4b799; } .calendar-day.file-day { background: #ffe5d0; }
.calendar-day.multiple-events { background: linear-gradient(45deg, #f8d7da 25%, #d1e7dd 25%, #d1e7dd 50%, #e2d9f3 50%, #e2d9f3 75%, #ffe5d0 75%); }
.calendar-tip { top: 100%; width: 240px; }
.calendar-tip-line { display: flex; align-items: flex-start; line-height: 1.4; }
.calendar-month-title { font-weight: 600; font-size: 14px; text-align: center; margin-bottom: 8px; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 6px 8px; margin-bottom: 8px; background: var(--sg-surface-2); border-radius: var(--sg-radius-sm); font-size: 11px; color: var(--sg-ink-2); }
.calendar-legend-item { display: inline-flex; align-items: center; }
.calendar-event-dot.contract { background: #dc3545; } .calendar-event-dot.meeting { background: #198754; } .calendar-event-dot.report { background: #6f42c1; }
.calendar-event-dot.delivery { background: #e5da3a; } .calendar-event-dot.file { background: #fd7e14; } .calendar-event-dot.event { background: #948b0f; }
.announcement-banner { padding: 10px 12px; margin-bottom: 12px; border-radius: var(--sg-radius); background: linear-gradient(135deg, #56ab91 0%, #2d6a4f 100%); color: #fff; }
.announcement-banner h5 { margin: 0 0 4px; color: #fff; font-size: 14px; }
.announcement-banner p { margin: 0; font-size: 12px; opacity: 0.95; }

/* map cards: a preview with the name over its bottom edge */
.map-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 360px; overflow-y: auto; }
.map-grid-wide { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.org-project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; max-height: 240px; overflow-y: auto; }
.map-card, .org-project-card { position: relative; display: block; height: 100px; border-radius: var(--sg-radius-sm); overflow: hidden; background: var(--sg-surface-2); border: 1px solid var(--sg-line); color: #fff; }
.org-project-card { height: 110px; }
.map-card:hover, .org-project-card:hover { box-shadow: var(--sg-shadow-lg); text-decoration: none; color: #fff; }
.map-card .map-preview, .org-project-card img.map-preview { display: block; width: 100%; height: 100%; object-fit: cover; }
.map-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--sg-ink-3); }
.map-overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; background: linear-gradient(to top, rgba(20, 30, 40, 0.9), rgba(20, 30, 40, 0)); color: #fff; }
.map-overlay h6 { margin: 0; font-size: 11px; line-height: 1.2; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-overlay small { display: block; font-size: 10px; color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-updated { position: absolute; top: 4px; right: 4px; padding: 1px 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.9); color: var(--sg-ink); font-size: 10px; }
.map-access-expired { position: absolute; top: 4px; left: 4px; border-radius: 2px; font-size: 10px; }
.map-hidden-badge { position: absolute; bottom: 28px; left: 4px; border-radius: 2px; font-size: 10px; }
.subscription-status { margin-left: 8px; vertical-align: middle; }
.subscription-fact { padding: 8px 0 10px; }
.subscription-fact-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--sg-ink-2); margin-bottom: 2px; }
.subscription-fact-value { font-size: 18px; font-weight: 500; line-height: 1.2; }
.subscription-fact-meta, .subscription-contact-meta { font-size: 12px; color: var(--sg-ink-2); }
.subscription-contact { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 12px 14px; background: var(--sg-accent-softer); border-radius: var(--sg-radius); }
.subscription-contact-name { font-size: 14px; font-weight: 600; }

/* customer dashboard (.ds): grids, figures, bars, timeline, sites, map */
.ds {
  --ds-ink: var(--sg-ink);
  --ds-ink-2: var(--sg-ink-2);
  --ds-ink-3: var(--sg-ink-3);
  --ds-line: var(--sg-line);
  --ds-surface: var(--sg-surface);
  --ds-surface-2: var(--sg-surface-2);
  --ds-accent: var(--sg-accent);
  --ds-accent-soft: var(--sg-accent-soft);
}
.ds a { color: inherit; } .ds a:hover { color: var(--sg-accent-ink); text-decoration: none; }
.ds-card { padding: 12px; margin: 0; }
.ds-card-title { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 10px; }
.ds-card-title a { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--sg-accent-ink); }
.ds-muted { color: var(--sg-ink-2); } .ds-faint { color: var(--sg-ink-3); } .ds-small { font-size: 12px; } .ds-tiny { font-size: 11px; } .ds-nowrap { white-space: nowrap; }
.ds-badge { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--sg-line); background: var(--sg-surface-2); color: var(--sg-ink); }
.ds-badge .ds-dot { margin-right: 0; width: 8px; height: 8px; }
.ds-change { font-weight: 600; font-size: 12px; } .ds-change.up { color: var(--sg-danger); } .ds-change.down { color: var(--sg-success); }
.ds-count { margin-left: 0; height: 24px; min-width: 24px; border-radius: 12px; font-size: 12px; }
.ds .ds-btn {
  display: inline-block; padding: 5px 11px; border-radius: var(--sg-radius); font-size: 12px; font-weight: 600; line-height: 16px;
  background: var(--sg-accent); color: #fff; border: 1px solid var(--sg-accent); text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ds .ds-btn:hover, .ds .ds-btn:focus { background: #3c7db0; border-color: #3c7db0; color: #fff; }
.ds .ds-btn-ghost { background: var(--sg-surface); color: var(--sg-accent-ink); border-color: var(--sg-line-2); }
.ds .ds-btn-ghost:hover, .ds .ds-btn-ghost:focus { background: var(--sg-accent-soft); border-color: var(--sg-accent); color: var(--sg-accent-ink); }
.ds-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--sg-ink-2); }
.ds-legend span { display: inline-flex; align-items: center; gap: 4px; }
.ds-meter { height: 6px; border-radius: 3px; background: var(--sg-line); overflow: hidden; }
.ds-meter i { display: block; height: 100%; background: var(--sg-accent); border-radius: 3px; }
.ds-stack { display: flex; flex-direction: column; gap: 10px; }
.ds-grid { display: grid; gap: 10px; }
.ds-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ds-op-top { grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) minmax(0, 1fr); }
.ds-op-main { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.ds-op-map { height: 560px; } .ds-op-map .ds-map { height: 100%; } .ds-op-map .ds-map-legend { bottom: 26px; }
.ds-op-side { height: 560px; display: flex; flex-direction: column; min-height: 0; }
.ds-op-side > .ds-card-title { flex-shrink: 0; }
.ds-op-side > .ds-tl-scroll, .ds-op-side > .ds-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 6px; }
.ds-op-side > .ds-tl-scroll { padding-left: 10px; padding-top: 4px; }
.ds-an-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ds-an-head h2 { font-size: 18px; margin: 0; }
.ds-kpi { display: flex; flex-direction: column; gap: 2px; }
.ds-kpi-visual { flex-direction: row; gap: 12px; align-items: flex-start; }
.ds-kpi-icon { width: 34px; height: 34px; border-radius: var(--sg-radius-lg); background: var(--sg-accent-soft); color: var(--sg-accent); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.ds-kpi-icon.tone, .ds-status-rows .ds-kpi-icon { background: var(--tone, var(--sg-line-2)); color: #fff; }
.ds-kpi-dots { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 4px; }
.ds-kpi-dots span { width: 12px; height: 12px; border-radius: 50%; display: block; }
.ds-kpi-value { font-size: 28px; } .ds-kpi-big { text-align: center; padding: 8px 0 4px; } .ds-kpi-big .ds-kpi-value { font-size: 40px; }
.ds-status-rows { display: flex; flex-direction: column; gap: 14px; }
.ds-status-rows > div { display: flex; align-items: center; gap: 12px; }
.ds-status-rows .ds-kpi-icon { width: 36px; height: 36px; font-size: 16px; }
.ds-status-rows b { font-size: 24px; font-weight: 300; line-height: 1.1; }
.ds-status-word { font-size: 16px; font-weight: 600; line-height: 1.2; }
.ds-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.ds-filters span { padding: 4px 10px; border: 1px solid var(--sg-line); border-radius: 999px; font-size: 12px; color: var(--sg-ink-2); background: var(--sg-surface); }
.ds-filters span.on { background: var(--sg-ink); color: #fff; border-color: var(--sg-ink); }
.ds-period-chips span { cursor: pointer; user-select: none; } .ds-period-chips span:hover { border-color: var(--sg-ink-3); } .ds-period[hidden] { display: none; }
.ds-stack-bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; }
.ds-stack-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.ds-stack-total { font-size: 10px; color: var(--sg-ink-3); margin-bottom: 2px; }
.ds-stack-col { width: 100%; max-width: 26px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.ds-stack-col i { display: block; width: 100%; border-radius: 2px; min-height: 3px; }
.ds-bars-labels { display: flex; gap: 4px; margin-top: 4px; } .ds-bars-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--sg-ink-3); }
.ds-table { width: 100%; border-collapse: collapse; }
.ds-table th { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--sg-line); white-space: nowrap; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--sg-ink-3); }
.ds-table td { padding: 5px 6px; border-bottom: 1px solid var(--sg-line); vertical-align: middle; } .ds-table tr:last-child td { border-bottom: 0; }
.ds-table tbody tr:hover td { background: var(--sg-surface-2); }
.ds-list { list-style: none; margin: 0; padding: 0; }
.ds-list li { padding: 5px 0; border-bottom: 1px solid var(--sg-line); display: flex; gap: 10px; align-items: flex-start; } .ds-list li:last-child { border-bottom: 0; }
.ds-list .ds-list-body { flex: 1; min-width: 0; }
.ds-list .ds-list-title { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-site-list li { cursor: pointer; } .ds-site-list li:hover .ds-list-title { color: var(--sg-accent-ink); }
.ds-timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--sg-line); }
.ds-timeline li { position: relative; padding: 0 0 14px 12px; }
.ds-timeline li::before { content: ""; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--tone, var(--sg-line-2)); border: 2px solid var(--sg-surface); box-shadow: 0 0 0 2px var(--sg-line); }
.ds-timeline li.future { opacity: 0.85; } .ds-timeline li.future::before { background: var(--sg-surface); box-shadow: 0 0 0 2px var(--sg-accent); }
.ds-timeline .ds-tl-date { font-size: 11px; color: var(--sg-ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.ds-timeline .ds-tl-title { font-weight: 500; } .ds-timeline .ds-tl-text { color: var(--sg-ink-2); font-size: 12px; }
.ds-timeline li.ds-timeline-today { font-size: 11px; font-weight: 600; color: var(--sg-accent); text-transform: uppercase; letter-spacing: 0.06em; padding: 0 0 10px 12px; }
.ds-timeline li.ds-timeline-today::before { width: 8px; height: 8px; left: -23px; top: 3px; background: var(--sg-accent); box-shadow: none; border: 0; }
.ds-sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ds-site { position: relative; display: block; height: 180px; border-radius: var(--sg-radius-lg); overflow: hidden; border: 1px solid var(--sg-line); background: var(--sg-surface-2); }
.ds-site img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ds-site .ds-site-placeholder { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--sg-ink-3); font-size: 36px; }
.ds-site-ribbon { position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--tone, var(--sg-line-2)); }
.ds-site-tags { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.ds-site-tags .ds-badge { background: rgba(255, 255, 255, 0.92); }
.ds-site-foot { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 10px; background: linear-gradient(to top, rgba(20, 30, 40, 0.92), rgba(20, 30, 40, 0)); color: #fff; }
.ds-site-foot b { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ds-site-foot span { font-size: 11px; opacity: 0.85; }
.ds-site-expired { position: absolute; inset: 0; background: rgba(255, 255, 255, 0.6); display: flex; align-items: center; justify-content: center; color: var(--sg-danger); font-weight: 600; }
.ds-map { height: 520px; background: var(--sg-surface-2); }
.ds-map .leaflet-popup-content { font-size: 12px; line-height: 1.4; margin: 10px 12px; } .ds-map .leaflet-popup-content b { display: block; font-size: 13px; }
.ds-map-legend { position: absolute; right: 10px; bottom: 10px; z-index: 500; display: flex; flex-direction: column; gap: 3px; padding: 6px 10px; border-radius: var(--sg-radius); background: rgba(255, 255, 255, 0.94); font-size: 11px; color: var(--sg-ink-2); }
.ds-map-wrap { position: relative; z-index: 0; isolation: isolate; overflow: hidden; border-radius: var(--sg-radius-lg); }
.ds-map-wrap .leaflet-control-attribution { font-size: 10px; }
@media (max-width: 1100px) { .ds-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ds-op-top { grid-template-columns: 1fr 1fr; } .ds-op-top > :nth-child(2) { grid-column: span 2; order: -1; } }
@media (max-width: 900px) { .ds-op-main { grid-template-columns: minmax(0, 1fr); } .ds-op-map { height: 320px; } .ds-op-side { height: auto; max-height: 420px; } .ds-site { height: 160px; } }
@media (max-width: 700px) { .ds-grid-3, .ds-op-top { grid-template-columns: minmax(0, 1fr); } .ds-op-top > :nth-child(2) { grid-column: auto; } }
@media (max-width: 480px) { .ds-card { padding: 12px; } .ds-kpi-value { font-size: 24px; } .ds-kpi-big .ds-kpi-value { font-size: 32px; } .ds-table th, .ds-table td { padding: 6px; } .ds-bars-labels span:nth-child(even) { visibility: hidden; } }

/* maps and reports page: filter column, toolbar of segments, cards */
/* Listing titles stay compact; the count is supporting information. */
.items-page .sg-page-head h1, .org-select-head h1 { font-size: 20px; letter-spacing: -0.015em; }
.items-page .items-result-count { margin-left: 4px; font-size: 13px; font-weight: 400; letter-spacing: normal; color: var(--sg-ink-2); }
.items-page .item-col { position: relative; margin-bottom: 14px; }
.items-page .item-card { display: block; overflow: hidden; background: var(--sg-surface); border: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg); color: var(--sg-ink); text-decoration: none; transition: box-shadow 0.15s; }
.items-page a.item-card:hover { box-shadow: var(--sg-shadow-lg); color: var(--sg-accent-ink); }
.items-page .item-card.is-expired { opacity: 0.7; }
.items-page .item-card-preview { position: relative; height: 180px; background: var(--sg-surface-3); border-bottom: 1px solid var(--sg-line); }
.items-page .item-card:not(.is-report) .item-card-preview { height: 218px; }
.items-page .item-card-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.items-page .item-card-body { display: flex; flex-direction: column; height: 100px; padding: 8px 10px 10px; overflow: hidden; }
.items-page .item-card.is-report .item-card-body { height: 169px; }
.items-page .item-card-title { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 600; line-height: 1.3; }
.items-page .item-card-name { flex: 1; min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.items-page .item-card-title .alert-icon { margin-top: 2px; }
.items-page .item-card-description { margin-top: 4px; font-size: 12px; line-height: 1.4; color: var(--sg-ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.items-page .item-card-tags { margin-top: 8px; white-space: nowrap; overflow: hidden; }
.items-page .item-card-tag { padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 500; border: 1px solid var(--sg-line); background: var(--sg-surface-2); }
.items-page .item-card-tag.is-more { font-weight: 600; }
.items-page .item-card-meta { margin-top: auto; flex-shrink: 0; padding-top: 4px; font-size: 12px; color: var(--sg-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.items-page .item-card-new { margin-left: 4px; padding: 1px 5px; border-radius: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.items-page .item-card-badges { position: absolute; top: 8px; left: 8px; right: 42px; }
.items-page .item-card-badges .item-card-badge { margin-bottom: 4px; box-shadow: var(--sg-shadow); border-radius: 3px; }
.items-page .item-card-actions { position: absolute; top: 8px; right: 23px; display: flex; gap: 6px; }
.items-page .item-card-info, .items-page .item-card-projects-toggle { display: inline-block; height: 26px; min-width: 26px; padding: 0 8px; border-radius: 13px; background: rgba(255, 255, 255, 0.92); color: var(--sg-accent-ink); font-size: 12px; line-height: 26px; text-align: center; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), var(--sg-shadow); }
.items-page .item-card-info:hover, .items-page .item-card-projects-toggle:hover, .items-page .item-card-projects-toggle:focus { background: #fff; text-decoration: none; }
.items-page .item-card-projects { position: relative; }
.items-page .items-filters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.items-page .items-filters-title { font-size: 15px; font-weight: 600; }
.items-page .items-filters-label { display: block; margin: 10px 0 4px; }
.items-page .items-filters-option { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; cursor: pointer; }
.items-page .items-filters-option input { margin: 0; }
.items-page .items-filters-link { padding: 0; border: 0; background: none; font-size: 12px; color: var(--sg-accent-ink); }
.items-page .items-filters-link:hover { text-decoration: underline; }
.items-page .items-filters-staff { margin-top: 18px; padding: 10px 12px 12px; background: var(--sg-accent-softer); border: 1px solid var(--sg-line); border-radius: var(--sg-radius); }
.items-page .items-filters-staff-title { margin-bottom: 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sg-accent-ink); }
.items-page .items-filters-map { width: 100%; height: 160px; margin-bottom: 4px; border: 1px solid var(--sg-line); border-radius: var(--sg-radius-sm); }
.items-page .items-filters-reset, .items-page .items-filters-search { display: block; width: 100%; padding: 5px 10px; border-radius: var(--sg-radius); font-size: 13px; font-weight: 600; text-align: center; text-decoration: none; }
.items-page .items-filters-reset { background: var(--sg-surface); border: 1px solid var(--sg-line-2); color: var(--sg-ink-2); }
.items-page .items-filters-reset:hover { background: var(--sg-surface-2); color: var(--sg-ink); text-decoration: none; }
.items-page .items-filters-search { margin-top: 12px; border: 0; background: var(--sg-accent); color: #fff; }
.items-page .items-filters-search:hover { background: #3c7db0; }
.items-page .items-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin-bottom: 10px; font-size: 12px; }
.items-page .items-toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.items-page .items-toolbar-right .items-toolbar-label { margin-left: 8px; }
.items-page .items-segments { display: inline-flex; background: var(--sg-surface); border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); overflow: hidden; }
.items-page .items-segment { padding: 3px 8px; color: var(--sg-ink-2); text-decoration: none; white-space: nowrap; border-left: 1px solid var(--sg-line); }
.items-page .items-segment:first-child { border-left: 0; }
.items-page a.items-segment:hover { background: var(--sg-surface-2); color: var(--sg-ink); }
.items-page .items-segment.selected { background: var(--sg-accent-soft); color: var(--sg-accent-ink); font-weight: 600; }
.items-page .items-segment.disabled, .items-page a.items-segment.disabled:hover { color: var(--sg-ink-3); background: transparent; cursor: default; }
.items-page .items-segment .glyphicon { font-size: 11px; }
.items-page .items-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 0 0 10px; font-size: 12px; }
.items-page .items-pagination .items-segment { min-width: 28px; text-align: center; }
.items-page .items-toolbar .items-pagination { margin: 0; flex-wrap: nowrap; gap: 4px; }
.items-page .items-toolbar .items-pagination .items-pagination-text { display: none; }
.items-page .items-toolbar .items-pagination .items-segment { min-width: 26px; padding: 5px 7px; }
.items-page .items-table-wrap { overflow-x: auto; background: var(--sg-surface); border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius-lg); }
.items-page .items-table { margin: 0; background: var(--sg-surface); width: 100%; }
.items-page .items-table > thead > tr > th { padding: 12px 16px; background: var(--sg-surface-2); color: var(--sg-ink-2); font-size: 12px; border-bottom: 1px solid var(--sg-line-2); white-space: nowrap; }
.items-page .items-table > tbody > tr > th,
.items-page .items-table > tbody > tr > td { padding: 12px 16px; vertical-align: middle; border-top: 1px solid var(--sg-line); }
.items-page .items-table > tbody > tr:first-child > * { border-top: 0; }
.items-page .items-table > tbody > tr:hover { background: var(--sg-accent-softer); }
.items-table-name { width: 100%; min-width: 260px; }
.items-table-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.items-table-title > a { color: var(--sg-ink); font-weight: 600; }
.items-table-title > a:hover { color: var(--sg-accent); }
.items-table-tag { display: inline-block; padding: 2px 6px; border: 1px solid var(--sg-line); border-radius: var(--sg-radius-sm); background: var(--sg-surface-2); color: var(--sg-ink-2); font-size: 10px; font-weight: 400; line-height: 1.4; white-space: nowrap; }
.items-table-date { min-width: 140px; white-space: nowrap; color: var(--sg-ink-2); font-variant-numeric: tabular-nums; }
.items-table-status, .items-table-summary { margin-top: 4px; font-size: 12px; font-weight: 400; }
.items-table-summary { color: var(--sg-ink-2); max-width: 760px; }
.items-table-actions { width: 88px; min-width: 88px; }
.items-table-action-group { display: flex; justify-content: flex-end; gap: 4px; }
.items-table-action-group > a { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1px solid transparent; border-radius: var(--sg-radius-sm); color: var(--sg-ink-2); text-decoration: none; }
.items-table-action-group > a:hover, .items-table-action-group > a:focus-visible { color: var(--sg-accent); background: var(--sg-surface); border-color: var(--sg-line-2); }

.items-page #map { height: 666px; margin-bottom: 15px; border-radius: var(--sg-radius-lg); }
.map-label { border-radius: 0; box-shadow: none; padding: 3px; pointer-events: auto; width: auto; height: auto; color: #fff; border-left: 0; border-right: 0; }
.map-alert-level { border-top: 4px solid #fff; }
div.alert-green { border-top: 4px solid #90d375; } div.alert-grey { border-top: 4px solid #d8dcd6; } div.alert-yellow { border-top: 4px solid #e5c92a; } div.alert-orange { border-top: 4px solid #f97306; } div.alert-red { border-top: 4px solid #e50000; }
.expired-label { color: var(--sg-danger-ink); font-weight: 600; } .expired-soon-label { color: var(--sg-warning-ink); font-weight: 600; }
a.map-metadata-link, a.map-edit-link { color: var(--sg-accent-ink); margin-left: 4px; }
.editable-field { transition: background 0.15s; background: transparent; }
.editable-field:hover { background: var(--sg-accent-softer); }
.editable-field:focus { background: #fff; outline: 0; border-color: var(--sg-accent) !important; }
/* metadata dialog of a map or report */
.item-metadata { font-size: 13px; }
.item-metadata-type { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sg-ink-3); }
.item-metadata .modal-title { margin-top: 2px; overflow-wrap: anywhere; }
.item-metadata-top { display: flex; gap: 20px; align-items: flex-start; }
.item-metadata-fields { flex: 1; min-width: 0; margin: 0; }
.item-metadata-fields dt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sg-ink-3); }
.item-metadata-fields dd { margin: 2px 0 12px; overflow-wrap: anywhere; } .item-metadata-fields dd:last-child { margin-bottom: 0; }
.item-metadata-muted { color: var(--sg-ink-3); }
.item-metadata-preview { flex: 0 0 260px; height: 180px; border-radius: var(--sg-radius); overflow: hidden; background: var(--sg-surface-3); border: 1px solid var(--sg-line); }
.item-metadata-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-metadata-section { margin-top: 20px; }
.item-metadata-section h5 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sg-ink-3); }
.item-metadata-scroll, .metadata-layer-scroll { max-height: 260px; overflow: auto; border: 1px solid var(--sg-line); border-radius: var(--sg-radius); }
.item-metadata-table, .metadata-layers table { width: 100%; margin: 0; font-size: 12px; table-layout: fixed; }
.item-metadata-table th, .item-metadata-table td, .metadata-layers th, .metadata-layers td { padding: 6px 10px; border-top: 1px solid var(--sg-line); vertical-align: top; overflow-wrap: anywhere; }
.item-metadata-table thead th, .metadata-layers .layer-type th { position: sticky; top: 0; background: var(--sg-surface-2); border-top: 0; font-size: 11px; font-weight: 600; color: var(--sg-ink-2); }
.item-metadata-table tbody tr:first-child td { border-top: 0; }
@media (max-width: 767px) { .item-metadata-top { flex-direction: column-reverse; } .item-metadata-preview { flex: none; width: 100%; } }

/* processing schedule: a week grid, one column per person */
.ps-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.ps-controls select { height: 32px; padding: 4px 10px; border: 1px solid var(--sg-line-2); border-radius: var(--sg-radius); background: var(--sg-surface); font-size: 13px; }
.ps-count { padding: 6px 12px; border-radius: var(--sg-radius); background: var(--sg-surface-3); font-size: 12px; color: var(--sg-ink-2); }
.ps-legend { display: flex; gap: 16px; margin-left: auto; }
.ps-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.ps-legend-box { width: 20px; height: 20px; border-radius: var(--sg-radius-sm); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; }
.ps-table-wrapper { overflow: auto; max-height: calc(100vh - var(--sg-nav-h) - 190px); background: var(--sg-surface); border: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg); }
.ps-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.ps-table th, .ps-table td { border: 1px solid var(--sg-line); padding: 6px 8px; text-align: center; }
.ps-table thead { position: sticky; top: 0; z-index: 10; }
.ps-table th { background: var(--sg-surface-2); font-weight: 600; }
.ps-table th.ps-fixed-col, .ps-table td.ps-fixed-col { text-align: left; }
.ps-table td.ps-fixed-col { white-space: nowrap; }
.ps-table th.ps-user-col { width: 30px; min-width: 30px; max-width: 30px; padding: 4px; vertical-align: bottom; height: 120px; }
.ps-user-name { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: 11px; font-weight: 500; }
.ps-table td.ps-user-cell { width: 30px; min-width: 30px; max-width: 30px; padding: 4px; font-weight: 700; }
.ps-role-p { background: #d4edda; color: #155724; } .ps-role-q { background: #cce5ff; color: #004085; } .ps-role-pq { background: #f8d7da; color: #721c24; }
.ps-status-request-needs-approval, .ps-status-acquisition-issue, .ps-status-sales-input-required { background: #f8d7da; color: #721c24; }
.ps-status-queued { background: var(--sg-surface-3); color: var(--sg-ink-2); }
.ps-status-coregistration { background: #bee5eb; color: #0c5460; } .ps-status-processing { background: #fff3cd; color: #856404; }
.ps-status-ready-for-qc { background: #b8daff; color: #004085; } .ps-status-qc\'ed, .ps-status-report-review, .ps-status-report-in-progress { background: #c3e6cb; color: #155724; }
.ps-status-done { background: var(--sg-success); color: #fff; } .ps-status-stuck { background: var(--sg-danger); color: #fff; }
.ps-date-row { background: var(--sg-surface-3); }
.ps-date-cell { font-weight: 700; font-size: 14px; text-align: left !important; padding: 8px 12px; }
.ps-loading { text-align: center; padding: 60px 20px; color: var(--sg-ink-2); }

/* SkyWire: upload dialog and the files table */
#uploadModal .modal-header { display: flex; align-items: center; gap: 8px; }
#uploadModal .modal-header::before, #uploadModal .modal-header::after, #uploadModal .modal-footer::before, #uploadModal .modal-footer::after { display: none; }
#uploadModal .modal-header .modal-title { flex: 1; margin: 0; } #uploadModal .modal-header .modal-title i { margin-right: 6px; color: var(--sg-accent); }
#uploadModal .modal-header .close { float: none; order: 2; margin: 0; }
#uploadModal .modal-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
#uploadModal #overallUploadProgress { flex: 0 0 100%; text-align: left; } #uploadModal #overallUploadProgress .progress { margin-top: 4px; }
#uploadModal .footer-right { display: flex; gap: 6px; } #uploadModal .modal-footer .btn + .btn { margin-left: 0; }
#uploadModal .upload-field { margin-bottom: 12px; }
#uploadModal .upload-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; } #uploadModal .upload-grid .project-hint { grid-column: 1 / -1; margin: -6px 0 10px; }
#uploadModal .upload-add { display: block; width: 100%; padding: 12px; border: 1px dashed var(--sg-line-2); border-radius: var(--sg-radius); background: var(--sg-surface-2); color: var(--sg-ink); text-align: center; font-size: 12px; font-weight: 600; }
#uploadModal .upload-add:hover, #uploadModal .upload-add:focus { background: var(--sg-surface-3); border-color: var(--sg-ink-3); outline: 0; }
#uploadModal .upload-add:disabled { opacity: 0.5; cursor: not-allowed; }
#uploadModal .upload-add.drag-over { border-style: solid; border-color: var(--sg-accent); background: var(--sg-accent-softer); }
#uploadModal .upload-add i { margin-right: 6px; color: inherit; }
#uploadModal .upload-add-hint { display: block; font-weight: 400; color: var(--sg-ink-3); font-size: 11px; margin-top: 2px; }
#uploadModal #pickedFilesList { margin: 6px 0 0; max-height: 220px; overflow-y: auto; }
#uploadModal #pickedFilesList .list-group-item { padding: 4px 8px; font-size: 12px; border-color: var(--sg-line); }
#uploadModal #pickedFilesList .remove-picked-file { padding: 0 6px; line-height: 18px; }
#uploadModal #pickedFilesSummary { display: block; text-align: right; font-size: 11px; color: var(--sg-ink-3); margin-top: 4px; }
#uploadModal .staff-section { border-top: 1px solid var(--sg-line); padding-top: 10px; margin-top: 2px; } #uploadModal .staff-section-title { margin-bottom: 6px; }
#shared_files_Table .downloadColumn { white-space: nowrap; }
#shared_files_Table .download-file, #shared_files_Table .download-batch { box-sizing: border-box; width: 34px; min-width: 34px; max-width: 34px; padding-left: 0; padding-right: 0; }
#shared_files_Table .row-actions { display: inline-flex; gap: 4px; white-space: nowrap; }
#shared_files_Table .download-batch .download-all-label { display: block; font-size: 9px; line-height: 1; margin-top: 2px; }
.numberColumn { text-align: center; }

/* The project overview has thirteen columns: wrap labels and budget widths explicitly. */
.v2-page .dataTables_wrapper #projectTable { table-layout: fixed; width: 100% !important; }
.v2-page #projectTable.dataTable thead > tr > th {
  /* no space kept free on the right, the sort arrows are in the text flow behind the column name */
  white-space: normal; overflow-wrap: anywhere; padding: 9px 6px;
  font-size: 11px; vertical-align: bottom;
}
.v2-page #projectTable.dataTable tbody > tr > td {
  min-width: 0; max-width: none; padding: 7px 6px;
  overflow-wrap: anywhere; white-space: normal; font-size: 12px;
}

.v2-page #projectTable.dataTable tbody > tr > td.count-col { text-align: center; padding-left: 2px; padding-right: 2px; }
.v2-page #projectTable.dataTable thead > tr > th.count-col { text-align: center; padding-left: 2px; padding-right: 2px; }
.v2-page #projectTable.dataTable thead > tr > th.count-col:after { margin-left: 3px; }

/* Counts share the same alignment in header and body, independent of table width. */
table.dataTable tbody .count-col { text-align: center; padding: 9px 12px; font-variant-numeric: tabular-nums; }
table.dataTable thead .count-col { text-align: center; padding-left: 12px; padding-right: 24px; }
.org-search { max-width: 640px; }
.org-search .list-group-item { border-color: var(--sg-line); padding: 10px 14px; }
.org-search .list-group-item:first-child { border-radius: var(--sg-radius-lg) var(--sg-radius-lg) 0 0; }
.org-search .list-group-item:last-child { border-radius: 0 0 var(--sg-radius-lg) var(--sg-radius-lg); }
a.list-group-item:hover { background: var(--sg-surface-2); }

/* contracts: editable cells, the edit form tables */
#contractsTable td.editable, #contractsTable td:not(.non-editable) { cursor: pointer; }
#contractsTable td:not(.non-editable):hover { background: var(--sg-accent-softer); }
#deliveries-bar { width: 60%; height: 8px; vertical-align: middle; }
.contract-info-table { margin-bottom: 10px; }
.contract-info-table th { width: auto; font-weight: 600; color: var(--sg-ink-2); background: var(--sg-surface-2); border-right: 1px solid var(--sg-line); font-size: 11px; padding: 4px 8px !important; vertical-align: middle; white-space: nowrap; }
.contract-info-table td { font-size: 12px; padding: 4px 8px !important; vertical-align: middle; }
.section-divider, .legacy-sub-header, .invoice-section-title { font-size: 13px; font-weight: 600; margin: 16px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--sg-line); }
.legacy-sub-header, .invoice-section-title { margin-top: 24px; }
.contract-link-value { word-break: break-word; font-size: 11px; }
.hide-field { display: none !important; }
.zoho-opportunity-toggle { display: block; padding: 8px 0 28px; color: var(--sg-ink); font-size: 14px; }
.zoho-opportunity-toggle:hover, .zoho-opportunity-toggle:focus { color: var(--sg-contract-ink); text-decoration: none; }
.zoho-opportunity-caret { width: 12px; margin-right: 6px; color: var(--sg-ink-3); }
.zoho-opportunity-toggle:not(.collapsed) .zoho-opportunity-caret { transform: rotate(90deg); }
.zoho-opportunity + .zoho-opportunity { border-top: 1px solid var(--sg-line); }
.invoice-details th { width: 180px; color: var(--sg-ink-2); font-weight: 600; }
.invoice-items-table th { background: var(--sg-surface-2); }
.invoice-total-row td { font-weight: 700; border-top: 2px solid var(--sg-line-2); background: var(--sg-surface-2); }

/* processing stats */
.metric { display: inline-block; vertical-align: top; width: 300px; margin: 0 16px 16px 0; background: var(--sg-surface); border: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg); overflow: hidden; }
.metric-header { padding: 10px 14px; border-bottom: 1px solid var(--sg-line); }
.metric-title, .metric-header h1 { margin: 0; font-size: 13px; font-weight: 600; color: var(--sg-ink-2); text-align: center; }
.metric-body { padding: 16px 14px; text-align: center; }
.metric-body h1, .metric-body h2, .metric-body h3, .metric-body h4 { margin: 0; text-align: center; }
.metric-body h1 { font-size: 40px; font-weight: 300; } .metric-body h1.primary-value { color: var(--sg-accent); }
.metric-body h3 { font-size: 14px; font-weight: 500; color: var(--sg-ink-2); } .metric-body h4 { font-size: 12px; color: var(--sg-ink-3); }
.comparison_wrapper { display: flex; padding-top: 12px; }
.left_comparison, .right_comparison { flex: 1; }
.green { color: var(--sg-success) !important; } .red { color: var(--sg-danger) !important; }
.chart-container { width: 100%; max-width: 640px; height: 380px; }
.stepdark, .stepmissing { display: inline-block; width: 18px; height: 18px; margin-right: 5px; border-radius: 50%; background: var(--sg-ink-2); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.cal-heatmap-container .subdomain-text { fill: var(--sg-ink); }

/* viewer visits (Piwik) */
[data-tooltip]:hover::after { display: block; position: absolute; content: attr(data-tooltip); padding: 4px 8px; border-radius: var(--sg-radius-sm); background: var(--sg-ink); color: #fff; font-size: 11px; z-index: 10; }
.bold_class { font-weight: 600; }
.hover_img a { position: relative; } .hover_img a span { position: absolute; display: none; z-index: 99; } .hover_img a:hover span { display: block; }
.top-left { position: absolute; top: 8px; left: 30px; word-wrap: break-word; max-width: 250px; }

/* announcements timeline */
.cbp_tmtimeline { margin: 0; padding: 0; list-style: none; position: relative; }
.cbp_tmtimeline::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--sg-line); left: 20%; margin-left: -6px; }
.cbp_tmtimeline > li { position: relative; }
.cbp_tmtimeline > li .cbp_tmtime { display: block; width: 23%; padding-right: 70px; position: absolute; }
.cbp_tmtimeline > li .cbp_tmtime span { display: block; text-align: right; font-size: 12px; color: var(--sg-ink-2); }
.cbp_tmtimeline > li .cbp_tmlabel { position: relative; margin: 0 0 15px 25%; padding: 14px 16px; background: var(--sg-surface); border: 1px solid var(--sg-line); border-radius: var(--sg-radius-lg); }
.cbp_tmtimeline > li .cbp_tmlabel h2 { margin: 0; padding: 0 0 8px; font-size: 15px; font-weight: 600; }
.cbp_tmtimeline > li .cbp_tmlabel p { color: var(--sg-ink-2); }
.cbp_tmtimeline > li .cbp_tmicon { position: absolute; left: 21%; top: 0; width: 24px; height: 24px; margin: 6px 0 0 -25px; border-radius: 50%; background: var(--sg-accent); color: #fff; font-size: 12px; line-height: 24px; text-align: center; box-shadow: 0 0 0 4px var(--sg-bg); }
.bg-green { background: var(--sg-success) !important; color: #fff; } .bg-blush { background: var(--sg-danger) !important; color: #fff; } .bg-orange { background: var(--sg-warning) !important; color: #fff; }
@media (max-width: 767px) {
  .cbp_tmtimeline::before { display: none; }
  .cbp_tmtimeline > li .cbp_tmtime { width: 100%; position: relative; padding: 0 0 6px; } .cbp_tmtimeline > li .cbp_tmtime span { text-align: left; }
  .cbp_tmtimeline > li .cbp_tmlabel { margin: 0 0 24px; }
  .cbp_tmtimeline > li .cbp_tmicon { position: relative; float: right; left: auto; margin: -54px 0 0; }
}

/* edit map: the boundary map widget */
.boundary-field .dj_map_wrapper { float: none; width: 780px; max-width: 100%; margin: 0 auto; }
.boundary-field .dj_map { width: 100%; height: 400px; }
.current-preview img, .current-file img { max-width: 160px; max-height: 100px; border-radius: var(--sg-radius-sm); display: block; margin-bottom: 4px; }

/* the Django admin multi select widget, used by the delivery and image procurement forms */
.selector .selector-available select[multiple], .selector .selector-chosen select[multiple] { height: 17.2em !important; background: #fff !important; }
.selector .selector-chosen select[multiple] { height: 267px !important; }
.selector h2 { background: var(--sg-surface-2) !important; color: var(--sg-ink-2) !important; margin: 0 !important; height: 30px; font-size: 13px; }
.selector .help-icon { background: url("../admin/img/icon-unknown.a18cb4398978.svg") 0 0 no-repeat !important; }
.selector select[multiple] option { font-size: 13px; line-height: 20px; white-space: normal; width: 100%; padding: 8px; border-bottom: 1px solid var(--sg-line); }
.form-row { border-bottom: none !important; }

/* public pages: login, signup, reset, errors. One card on the splash image */
.public { background: #0f1f2e url("../img/splash.63f901ceaac8.jpg") center center / cover fixed; }
.public .modal-dialog, .public .modal-dialog.modal-sm { width: auto; max-width: 420px; margin: 48px auto; }
.signup .modal-dialog, .error .modal-dialog, .contact .modal-dialog, .permian-signup .modal-dialog { max-width: 680px; }
.public .modal-content { border-radius: 12px; overflow: hidden; }
.public .modal-header { padding: 26px 28px 6px; border: 0; text-align: center; }
.public .logo { width: 60%; max-height: 56px; }
.public .modal-body { padding: 10px 28px 28px; max-height: none; overflow: visible; }
.public .modal-body .modal-body { padding: 0; }
.public legend { font-size: 18px; text-align: center; margin-bottom: 6px; }
.public h1, .public h3 { font-size: 18px; text-align: center; }
.public p { color: var(--sg-ink-2); }
.public .btn { padding: 8px 14px; }
.public .btn-primary { min-width: 120px; }
.public .login .btn-primary, .login .form-group .btn-primary { width: 100%; }
.public .password-reset-link { font-size: 12px; margin: -6px 0 14px; }
.public .login-separator { display: flex; align-items: center; gap: 10px; color: var(--sg-ink-3); font-size: 12px; margin: 14px 0; }
.public .login-separator hr { flex: 1; margin: 0; border-color: var(--sg-line); }
.public .separator-text { flex: 0 0 auto; }
.public p.login-signup { margin-top: 20px; text-align: center; }
.public .alert { text-align: left; }
.permian-signup-intro { margin-bottom: 22px; }
.permian-signup-actions { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--sg-line); }

/* announcement popup */
.modal-announcement { max-width: 700px; }
.announcement .modal-content-center { text-align: center; padding: 4px; }
.announcement .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Sync status sits outside the table so hidden columns cannot shorten the footer. */
.zoho-sync-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 20px; padding: 12px 16px; margin-top: 12px;
  border: 1px solid var(--sg-line); border-radius: var(--sg-radius);
  background: var(--sg-surface-2); font-size: 12px;
}
.zoho-sync-details { display: flex; flex-direction: column; gap: 3px; flex: 1 1 300px; min-width: 0; }
.zoho-sync-footer .btn { flex-shrink: 0; white-space: nowrap; }

/* Shared files: long filenames, groups and email addresses wrap within a width budget. */
.v2-page .dataTables_wrapper #shared_files_Table { table-layout: fixed; width: 100% !important; }
.v2-page #shared_files_Table.dataTable > thead > tr > th {
  white-space: normal; overflow-wrap: anywhere; padding: 9px 18px 9px 6px;
  font-size: 11px; vertical-align: bottom;
}
.v2-page #shared_files_Table.dataTable > tbody > tr > td {
  min-width: 0; max-width: none; padding: 7px 6px; white-space: normal;
  overflow-wrap: anywhere; font-size: 12px;
}
#shared_files_Table .row-actions { flex-wrap: wrap; }
#shared_files_Table .row-actions .btn,
#shared_files_Table .download-file,
#shared_files_Table .download-batch { width: 28px; min-width: 28px; max-width: 28px; padding-left: 0; padding-right: 0; }

#shared_files_Table .shared-file-status {
  display: inline-block; box-sizing: border-box; max-width: 100%;
  padding: 3px 6px; border-radius: var(--sg-radius-sm); color: #fff;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.35; font-size: 11px;
}

/* Standalone edit forms need breathing room beneath their shared context bar. */
.sg-main:has(.edit-page-banner) .edit-user-page,
.sg-main:has(.edit-page-banner) .viewer-edit { margin-top: 20px; }

/* All dialog headers use the same readable surface, including loaded edit forms. */
.modal-header { background: var(--sg-surface); color: var(--sg-ink); }
.modal-header .modal-title { color: inherit; padding-right: 24px; overflow-wrap: anywhere; }
#editContractModalV2 .contract-edit-panel { border-color: var(--sg-line-2); margin-bottom: 16px; }
#editContractModalV2 .contract-edit-panel > .panel-heading { background: var(--sg-surface-2); border-color: var(--sg-line); padding: 10px 14px; }
#editContractModalV2 .contract-edit-panel .panel-title { font-size: 14px; color: var(--sg-ink); line-height: 1.5; }
#editContractModalV2 .contract-edit-panel .panel-title::after { content: ""; display: table; clear: both; }

/* Contract actions and the confirmation notice stay legible at every dialog width. */
#editContractModalV2 .modal-content { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
#editContractModalV2 .modal-header, #editContractModalV2 .modal-footer { flex: 0 0 auto; }
#editContractModalV2 .modal-body { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; }
.contract-edit-footer { background: var(--sg-surface); text-align: left; }
.contract-confirm-note { padding: 0; margin-bottom: 14px; color: var(--sg-ink-2); font-size: 12px; line-height: 1.5; }
.contract-confirm-note > strong { display: block; margin-bottom: 2px; }
.contract-confirm-note > p { margin: 0; }
.contract-edit-footer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.contract-edit-updated { color: var(--sg-ink-2); font-size: 11px; }
.contract-edit-footer-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-left: auto; }
.contract-edit-footer .contract-edit-footer-actions > .btn { margin: 0; white-space: nowrap; }

.sg-section-heading-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.sg-section-heading-row .btn { margin-top: 0; }
.sg-section-description { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: var(--sg-ink-2); }

/* Keep meeting details within their columns, including long attendee addresses. */
#meetings-table, .meeting-table { table-layout: fixed; width: 100%; }
#meetings-table th, #meetings-table td, .meeting-table th, .meeting-table td { white-space: normal; overflow-wrap: anywhere; }
.v2-page #meetings-table tbody > tr > td:first-child { min-width: 0; }
#meetings-table th:nth-child(1), .meeting-table th:nth-child(1) { width: 10%; }
#meetings-table th:nth-child(2), .meeting-table th:nth-child(2) { width: 10%; }
#meetings-table th:nth-child(3), .meeting-table th:nth-child(3) { width: 18%; }
#meetings-table th:nth-child(4), .meeting-table th:nth-child(4) { width: 18%; }
#meetings-table th:nth-child(5), .meeting-table th:nth-child(5),
#meetings-table th:nth-child(6), .meeting-table th:nth-child(6) { width: 16%; }
#meetings-table th:nth-child(7), .meeting-table th:nth-child(7) { width: 5%; }
#meetings-table th:nth-child(8) { width: 64px; }
.meeting-table th:nth-child(8) { width: 36px; }
#meetings-table td:nth-child(8), .meeting-table td:nth-child(8) { white-space: nowrap; }

.project-details-table > tbody > tr:first-child > th,
.project-details-table > tbody > tr:first-child > td { border-top: 0; }
