/* Civadelia Design System V2.3 — legibility, contrast and scale.
   Intentional scope: authenticated workspace. No data, routing or permission changes.
   Loaded AFTER V1 navigation and V2 design styles. */

/* Core palette and predictable type. Local/system fonts only; no font downloads. */
body.co-ui-v1 .co-app-shell {
  --civa23-ink: var(--text);
  --civa23-muted: var(--text-muted);
  --civa23-border: var(--border);
  --civa23-surface: var(--surface);
  --civa23-hover: var(--surface-hover);
  --civa23-focus: var(--brand-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.48;
}
body.co-ui-v1 .co-app-shell .co-page { max-width: 1280px; }
body.co-ui-v1 .co-app-shell .co-page-header p,
body.co-ui-v1 .co-app-shell .co-panel p { line-height: 1.55; }

/* Keep the nav's existing hierarchy, improve legibility and line wrapping. */
body.co-ui-v1 .civa-nav-refresh .co-side-nav a {
  font-size: 13.5px !important;
  line-height: 1.42 !important;
  min-height: 38px;
}
body.co-ui-v1 .civa-nav-refresh .civa-operation-group > summary {
  color: #394453;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.36;
  min-height: 41px;
  gap: 9px;
  padding: 9px 10px;
}
body.co-ui-v1 .civa-nav-refresh .civa-operation-group > summary span {
  min-width: 0;
  overflow-wrap: normal;
}
body.co-ui-v1 .civa-nav-refresh .civa-operation-links > a {
  font-size: 13px !important;
  line-height: 1.38 !important;
  min-height: 36px !important;
  padding: 8px 10px !important;
}
body.co-ui-v1 .civa-nav-refresh .co-nav-label {
  font-size: var(--fs-xs) !important;
  letter-spacing: .085em !important;
}
body.co-ui-v1 .civa-nav-refresh .civa-operation-chevron { flex: 0 0 14px; }

/* Dashboard statistics — actual values must remain readable. */
body.co-ui-v1 .co-app-shell .co-stat { padding: 16px 17px; }
body.co-ui-v1 .co-app-shell .co-stat > span,
body.co-ui-v1 .co-app-shell .co-stat > small {
  color: var(--civa23-muted) !important;
  font-size: 12.5px !important;
  font-weight: 500;
  line-height: 1.45;
}
body.co-ui-v1 .co-app-shell .co-stat > strong {
  color: var(--civa23-ink) !important;
  font-size: clamp(21px, 1.6vw, 26px) !important;
  line-height: 1.15;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}
body.co-ui-v1 .co-app-shell .co-panel-head h2 {font-size: 15.5px;}

/* Responsive operation cards: same information, far less dead space. */
body.co-ui-v1 .co-app-shell .co-module-grid.civa-v2-operations-grid {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 10px !important;
}
body.co-ui-v1 .co-app-shell .civa-v2-operations-grid > a.civa-v2-operation-card {
  display: grid !important;
  grid-template-columns: 33px minmax(0, 1fr);
  grid-template-rows: auto;
  align-items: start !important;
  column-gap: 12px;
  row-gap: 0;
  padding: 15px !important;
  min-height: 108px;
  border-color: var(--civa23-border);
  position: relative;
}
body.co-ui-v1 .co-app-shell .civa-v2-operation-card .co-action-icon {
  width: 33px;
  height: 33px;
  flex: none;
  background: #eef1f5;
  color: #536175;
  border-radius: 8px;
}
body.co-ui-v1 .co-app-shell .civa-v2-operation-copy {gap: 5px;}
body.co-ui-v1 .co-app-shell .civa-v2-operation-copy strong {
  color: var(--civa23-ink) !important;
  font-size: 14px !important;
  line-height: 1.35;
  font-weight: 680;
}
body.co-ui-v1 .co-app-shell .civa-v2-operation-copy small {
  color: var(--civa23-muted) !important;
  font-size: 13px !important;
  line-height: 1.45;
  font-weight: 400;
}
body.co-ui-v1 .co-app-shell .civa-v2-card-arrow {display: none;}
body.co-ui-v1 .co-app-shell .civa-v2-operation-card:hover {
  border-color: #b6c0ca !important;
  background: var(--civa23-hover) !important;
}
body.co-ui-v1 .co-app-shell .civa-v2-recent-grid {gap: 10px;}
body.co-ui-v1 .co-app-shell .civa-v2-recent-card {min-height: 70px;padding: 13px 15px;}
body.co-ui-v1 .co-app-shell .civa-v2-recent-card strong {font-size: 14px !important;}
body.co-ui-v1 .co-app-shell .civa-v2-recent-card small {font-size: 12.5px !important;line-height:1.4;}
body.co-ui-v1 .co-app-shell .civa-v2-recents-empty {font-size:14px;}

/* Shared form and table sizing. Do not affect radios, checkboxes or file controls. */
body.co-ui-v1 .co-app-shell .co-panel label,
body.co-ui-v1 .civa-nav-refresh .cg-form label {
  font-size: 13.5px;
  line-height: 1.5;
}
body.co-ui-v1 .co-app-shell .co-panel input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
body.co-ui-v1 .co-app-shell .co-panel select,
body.co-ui-v1 .co-app-shell .co-panel textarea,
body.co-ui-v1 .civa-nav-refresh .cg-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
body.co-ui-v1 .civa-nav-refresh .cg-form select,
body.co-ui-v1 .civa-nav-refresh .cg-form textarea {
  font-size: 14px !important;
  line-height: 1.45;
  min-height: 42px;
  border-radius: 8px;
}
body.co-ui-v1 .civa-nav-refresh .cg-form small,
body.co-ui-v1 .civa-nav-refresh .cg-panel small,
body.co-ui-v1 .co-app-shell .co-panel .helptext { font-size: 12.5px;line-height:1.5; }
body.co-ui-v1 .civa-nav-refresh .cg-button,
body.co-ui-v1 .co-app-shell .co-btn {font-size:13.5px;min-height:38px;}
body.co-ui-v1 .civa-nav-refresh .cg-table th,
body.co-ui-v1 .co-app-shell .co-panel th {font-size:12px;line-height:1.45;}
body.co-ui-v1 .civa-nav-refresh .cg-table td,
body.co-ui-v1 .co-app-shell .co-panel td {font-size:13.5px;line-height:1.5;}
body.co-ui-v1 .civa-nav-refresh .cg-page {max-width:1280px;}
body.co-ui-v1 .civa-nav-refresh .cg-hero {padding: 22px 24px;}
body.co-ui-v1 .civa-nav-refresh .cg-hero h1 {font-size: clamp(24px,2vw,29px);line-height:1.2;}
body.co-ui-v1 .civa-nav-refresh .cg-tabs a {font-size:13.5px;line-height:1.4;}
body.co-ui-v1 .civa-nav-refresh .cg-narrow {max-width:960px;}

/* Keyboard access across themes. */
body.co-ui-v1 .co-app-shell :is(a,button,summary,input,textarea,select):focus-visible {
  outline: 2px solid var(--civa23-focus);
  outline-offset: 2px;
}

/* Dark surfaces: stronger, verifiable text hierarchy; colour must not encode status alone. */
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell {
  --civa23-ink: var(--text);
  --civa23-muted: var(--text-muted);
  --civa23-border: var(--border);
  --civa23-surface: var(--surface);
  --civa23-hover: var(--surface-hover);
  --civa23-focus: var(--brand-text);
  --co-heading: var(--text);
  --co-ink: var(--text);
  --civa-v2-text: var(--text);
  --civa-v2-muted: var(--text-muted);
}
/* V1 operation summary colours were too dark; the V2 override missed closed summaries. */
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .civa-operation-group > summary {
  color: #e0e6ee !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .civa-operation-group > summary > .co-icon,
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .civa-operation-chevron {
  color: #bcc8d7 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-side-nav a {
  color: #dbe3ed !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .civa-operation-links > a {
  color: #ced8e4 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .civa-operation-links > a.is-active {
  color: var(--brand-text) !important;
  background: color-mix(in srgb, var(--brand) 34%, var(--surface)) !important; /* institution colour, as in light mode */
  font-weight: 700 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .civa-operation-group[open] > summary,
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-side-nav a.is-active {
  color: var(--brand-text) !important;
  background: color-mix(in srgb, var(--brand) 34%, var(--surface)) !important; /* institution colour, as in light mode */
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-nav-label,
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-brand-copy small,
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-context-title small {
  color: #b6c2d0 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-stat > span,
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-stat > small {
  color: #c4ceda !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-stat > strong {
  color: #f7f9fb !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .civa-v2-operation-copy strong,
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .civa-v2-recent-card strong {
  color: #f3f6fa !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .civa-v2-operation-copy small,
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .civa-v2-recent-card small {
  color: #c0cad7 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .civa-v2-operation-card .co-action-icon {
  background: #353d49 !important;
  color: #e0e7ef !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .civa-v2-operation-card:hover {
  background: #303743 !important;
  border-color: #677182 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-page,
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-page p,
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-panel p {
  color: #dce3ec;
}
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-form small,
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-panel small,
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-panel .helptext {
  color: #bcc7d4 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-form label,
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-panel label {
  color: #edf1f6 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-panel input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-panel select,
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-panel textarea,
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-form select,
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-form textarea {
  background: #292f39 !important;
  border-color: #657081 !important;
  color: #f3f5f8 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-user-popover .civa-v2-theme-label {
  color: #f3f5f8 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-panel th,
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-table th {
  color: #e8edf4 !important;
}
html[data-civa-theme="dark"] body.co-ui-v1 .co-app-shell .co-panel td,
html[data-civa-theme="dark"] body.co-ui-v1 .civa-nav-refresh .cg-table td {
  color: #dee6ef;
}

/* 125%-200% zoom and smaller viewports: reflow rather than shrinking fonts. */
@media (max-width: 1380px) {
  body.co-ui-v1 .co-app-shell .co-module-grid.civa-v2-operations-grid {
    grid-template-columns: repeat(3,minmax(0,1fr)) !important;
  }
}
@media (max-width: 1040px) {
  body.co-ui-v1 .co-app-shell .co-module-grid.civa-v2-operations-grid {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
  }
  body.co-ui-v1 .co-app-shell .civa-v2-recent-grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
}
@media (max-width: 700px) {
  body.co-ui-v1 .co-app-shell .co-module-grid.civa-v2-operations-grid,
  body.co-ui-v1 .co-app-shell .civa-v2-recent-grid {
    grid-template-columns: minmax(0,1fr) !important;
  }
  body.co-ui-v1 .co-app-shell .civa-v2-operations-grid > a.civa-v2-operation-card {min-height: 90px;}
  body.co-ui-v1 .civa-nav-refresh .cg-hero {padding: 18px 16px;}
  body.co-ui-v1 .co-app-shell .co-stat {padding: 14px;}
}
@media (prefers-reduced-motion: reduce) {
  body.co-ui-v1 .co-app-shell .civa-v2-operation-card {transition: none !important;}
}
