/**
 * Process Flows – IBM Carbon Design System theme.
 */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

/* ========== Design tokens – IBM Carbon palette ========== */
:root {
  /* Surfaces */
  --bg: #ffffff;
  --bg-subtle: #f4f4f4;
  --bg-hover: #e8e8e8;
  --border: #e0e0e0;
  --border-muted: #e8e8e8;

  /* Text */
  --text-primary: #161616;
  --text-secondary: #525252;
  --text-muted: #6f6f6f;
  --text-on-accent: #ffffff;

  /* Header — Carbon uses a dark shell */
  --header-bg: #161616;
  --header-border: #393939;
  --header-height: 48px;

  /* Accent – Carbon Interactive Blue */
  --accent: #0f62fe;
  --accent-hover: #0353e9;
  --accent-subtle: #edf5ff;
  --accent-glow: rgba(15, 98, 254, 0.25);
  --focus-ring: 0 0 0 2px #ffffff, 0 0 0 4px #0f62fe;

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-right-width: 200px;

  /* Radius – Carbon uses no radius by default; we keep light rounding */
  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;
  --radius-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.12);

  /* Motion – Carbon cubic-bezier */
  --ease: cubic-bezier(0.2, 0, 0.38, 0.9);
  --duration: 0.11s;

  --font-sans:
    "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
    Arial, sans-serif;
  --font-mono:
    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ========== Base ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body.app-body {
  margin: 0;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.16px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ========== Header ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-right-width);
  align-items: center;
  gap: 0;
}

.header-start {
  display: flex;
  align-items: center;
  gap: 0;
  height: var(--header-height);
  padding: 0 1rem;
  border-right: 1px solid var(--header-border);
}

.hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: transparent;
  border: none;
  color: #f4f4f4;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  margin-left: -1rem;
  transition: background var(--duration) var(--ease);
}

.hamburger-btn:hover {
  background: #353535;
  color: #f4f4f4;
}

.site-logo {
  font-weight: 400;
  font-size: 0.875rem;
  color: #f4f4f4;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.1px;
  padding-left: 0.25rem;
}

.site-logo:hover {
  text-decoration: none;
  color: #f4f4f4;
  opacity: 0.9;
}

.header-center {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 1rem;
}

.header-search {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.header-search-icon {
  position: absolute;
  left: 0.75rem;
  color: #8d8d8d;
  pointer-events: none;
  display: flex;
  align-items: center;
  z-index: 1;
}

.header-search input[type="search"] {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 0.5rem 0 2.25rem;
  background: #393939;
  border: none;
  border-bottom: 1px solid #6f6f6f;
  border-radius: 0;
  font-size: 0.875rem;
  color: #f4f4f4;
  font-family: var(--font-sans);
  outline: none;
  -webkit-appearance: none;
  letter-spacing: 0.16px;
  transition: border-color var(--duration) var(--ease);
}

.header-search input[type="search"]::placeholder {
  color: #8d8d8d;
}

.header-search input[type="search"]:hover {
  border-bottom-color: #a8a8a8;
}

.header-search input[type="search"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: #4c4c4c;
}

/* Scope chip: shown inside the search bar when a process is active */
.header-search-scope {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.5rem 0 2.25rem;
  height: 32px;
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 0.75rem;
  font-family: var(--font-sans);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.16px;
  line-height: 1;
  border-bottom: 1px solid var(--accent);
}

.header-search-scope-clear {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.1rem;
  display: flex;
  align-items: center;
}

.header-search-scope-clear:hover {
  color: #ffffff;
  text-decoration: none;
}

/* When scope chip is present, remove the icon-clearance padding from input */
.header-search:has(.header-search-scope) input[type="search"] {
  padding-left: 0.5rem;
}

/* Submit button inside the search bar */
.header-search-submit {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid #6f6f6f;
  border-radius: 0;
  color: #8d8d8d;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.header-search-submit:hover {
  background: #4c4c4c;
  color: #f4f4f4;
}

.header-search-submit:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.header-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: var(--header-height);
  padding: 0;
  border-left: 1px solid var(--header-border);
}

.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 48px;
  height: 48px;
  padding: 0 1rem;
  background: transparent;
  border: none;
  border-radius: 0;
  color: #f4f4f4;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration) var(--ease);
}

.header-icon-btn:hover {
  background: #353535;
  color: #f4f4f4;
  text-decoration: none;
}

.header-icon-btn-label {
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.16px;
}

/* ========== Site layout – three columns ========== */
.site-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-right-width);
  grid-template-areas: "sidebar-left main sidebar-right";
  gap: 2rem;
  align-items: start;
  min-height: calc(100vh - var(--header-height));
}

.sidebar-left {
  grid-area: sidebar-left;
  padding: 1.5rem 0;
  position: sticky;
  top: calc(var(--header-height) + 0.5rem);
  max-height: calc(100vh - var(--header-height) - 1rem);
  overflow-y: auto;
}

.site-main {
  grid-area: main;
  padding: 1.5rem 0;
  min-width: 0;
}

.sidebar-right {
  grid-area: sidebar-right;
  padding: 1.5rem 0;
  position: sticky;
  top: calc(var(--header-height) + 0.5rem);
  max-height: calc(100vh - var(--header-height) - 1rem);
  overflow-y: auto;
}

/* Viewer: stretch to fill height */
.site-layout--viewer {
  height: calc(100vh - var(--header-height));
  align-items: stretch;
}

.site-layout--viewer .site-main {
  display: flex;
  flex-direction: column;
  padding-bottom: 1.5rem;
}

/* Wide: main spans into right-sidebar column (used by admin) */
.site-layout--wide {
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas: "sidebar-left main";
}

.site-layout--wide .sidebar-right {
  display: none;
}

/* ========== Left sidebar nav ========== */
.sidebar-nav-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.32px;
  color: var(--text-muted);
  margin: 0 0 0.25rem 0;
  padding: 1rem 1rem 0.25rem;
}

.sidebar-nav-list {
  list-style: none;
  margin: 0 0 0.5rem 0;
  padding: 0;
}

.sidebar-nav-item > a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6875rem 1rem;
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1.25;
  letter-spacing: 0.16px;
  border-left: 3px solid transparent;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

.sidebar-nav-item > a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-nav-item.active > a {
  font-weight: 600;
  color: var(--text-primary);
  background: #e8e8e8;
  border-left: 3px solid var(--accent);
}

.sidebar-nav-children {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav-children .sidebar-nav-item > a {
  padding-left: 2rem;
  font-size: 0.8125rem;
}

/* ========== Right sidebar ========== */
.sidebar-right-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.32px;
  color: var(--text-muted);
  margin: 0 0 0.25rem 0;
  padding: 1rem 0 0.25rem;
}

.sidebar-right-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-right-list li {
  margin-bottom: 0;
}

.sidebar-right-list a {
  display: block;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.16px;
  transition: color var(--duration) var(--ease);
}

.sidebar-right-list li:last-child a {
  border-bottom: none;
}

.sidebar-right-list a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Separator between Library and Admin sections in right sidebar */
.sidebar-right-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0 0;
}

/* Primary "New diagram" action button in right sidebar */
.sidebar-right-new-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.4375rem 0.75rem;
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-sans);
  letter-spacing: 0.16px;
  text-decoration: none;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
  margin-top: 0.5rem;
}

.sidebar-right-new-btn:hover {
  background: var(--accent-hover);
  color: var(--text-on-accent);
  text-decoration: none;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 1rem;
  font-size: 0.875rem;
  font-weight: 400;
  border-radius: 0;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.125rem;
  letter-spacing: 0.16px;
  font-family: var(--font-sans);
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease),
    outline var(--duration) var(--ease);
  -webkit-appearance: none;
}

.btn:focus,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: none;
}

.btn:hover {
  text-decoration: none;
}

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

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

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--accent);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.btn-danger {
  background: #da1e28;
  color: #ffffff;
}

.btn-danger:hover {
  background: #ba1b23;
  color: #ffffff;
}

.btn-sm {
  padding: 0.3125rem 0.75rem;
  font-size: 0.8125rem;
}

/* ========== Cards ========== */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
}

.card-header {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 0.625rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  letter-spacing: 0.16px;
}

.card-body {
  padding: 1rem;
}

/* ========== Tables ========== */
.table {
  color: var(--text-primary);
  font-size: 0.875rem;
  border-collapse: collapse;
  width: 100%;
}

.table thead th {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.32px;
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.875rem;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-hover tbody tr:hover td {
  background: var(--bg-subtle);
}

.table code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--bg-subtle);
  padding: 0.125rem 0.375rem;
  border-radius: 0;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ========== Forms ========== */
.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 0.6875rem 1rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: none;
  border-bottom: 1px solid var(--text-muted);
  border-radius: 0;
  outline: none;
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
  -webkit-appearance: none;
}

.form-control:focus,
.form-select:focus {
  border-bottom: 2px solid var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: none;
  background: var(--bg);
}

.form-control::placeholder {
  color: var(--text-muted);
}
textarea.form-control {
  resize: vertical;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  letter-spacing: 0.32px;
}

/* ========== Home page ========== */

.home-page {
  padding: 1.5rem 1.5rem 3rem;
}

.home-heading {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.home-heading-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.home-heading-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

.home-empty {
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 2.5rem 0;
  text-align: center;
}

.home-empty a {
  color: var(--accent);
}

/* ── Unified item list ── */
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-row {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border-muted);
  min-width: 0;
}

.item-row:last-child {
  border-bottom: none;
}

.item-type-badge {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.1875rem 0.4375rem;
  border-radius: 0;
  margin-top: 0.1875rem;
  min-width: 4.5rem;
  text-align: center;
}

.item-type-badge--pdf {
  background: #fff1f1;
  color: #da1e28;
  border: 1px solid #ffd7d9;
}

.item-type-badge--diagram {
  background: #edf5ff;
  color: #0043ce;
  border: 1px solid #d0e2ff;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  display: block;
  margin-bottom: 0.125rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-title:hover {
  color: var(--accent);
  text-decoration: none;
}

.item-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0 0 0.375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60ch;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.item-meta-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.16px;
}

/* Legacy hero styles (kept for backward compat) */
.home-hero {
  text-align: center;
  padding: 3rem 2rem 1.75rem;
}

.home-hero-visual {
  width: 96px;
  height: 96px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-hero-visual img,
.home-hero-visual svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.home-hero-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.home-hero-sub {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0 auto 1.75rem;
  max-width: 380px;
  line-height: 1.5;
}

.home-hero-actions {
  display: flex;
  gap: 0.625rem;
  justify-content: center;
  flex-wrap: wrap;
}

.home-feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2rem;
  padding: 0 2rem 2rem;
}

.home-feature-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: left;
}

.home-feature-icon {
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 0.625rem;
  display: block;
}

.home-feature-card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.375rem;
}

.home-feature-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0 0 0.875rem;
  line-height: 1.5;
}

.home-feature-card .learn-more {
  font-size: 0.8125rem;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.home-feature-card .learn-more:hover {
  text-decoration: underline;
}

.home-footer {
  text-align: center;
  padding: 1rem 2rem 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-muted);
}

.home-footer a {
  color: var(--text-muted);
}
.home-footer a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ========== Search / Browse results ========== */
.results-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1rem;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.results-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-muted);
  gap: 1rem;
}

.results-item:last-child {
  border-bottom: none;
}

.results-item-title a {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent);
}

.results-item-title a:hover {
  text-decoration: underline;
}

.results-item-process {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.results-badge {
  font-size: 0.75rem;
  font-weight: 400;
  padding: 0.125rem 0.5rem;
  border-radius: 0;
  background: var(--bg-subtle);
  border: none;
  color: var(--text-secondary);
  letter-spacing: 0.32px;
  white-space: nowrap;
  flex-shrink: 0;
}

.results-empty {
  color: var(--text-muted);
  font-size: 0.9375rem;
  padding: 2rem 0;
}

/* ========== PDF viewer ========== */
.pdf-viewer-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.pdf-viewer-toolbar {
  flex-shrink: 0;
  padding: 0.5625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.pdf-viewer-toolbar .doc-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pdf-viewer-wrapper {
  flex: 1;
  min-height: 0;
  background: #374151;
}

.pdf-iframe {
  width: 100%;
  height: 100%;
  min-height: 400px;
  border: none;
  display: block;
}

/* ========== Admin ========== */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.admin-header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}

.admin-edit h1 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Upload form */
.admin-upload-card {
  margin-bottom: 1.25rem;
}

.admin-upload-form {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-upload-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 180px;
  flex: 1;
}

.admin-upload-action {
  flex-shrink: 0;
  padding-bottom: 1px; /* align button with input bottom */
}

.form-label-hint {
  font-weight: 400;
  color: var(--text-muted);
}

.form-field-hint {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Table — auto layout, actions column shrinks to fit its content */
.admin-table {
  width: 100%;
  table-layout: auto;
}

/* Actions: shrink-wrap to buttons, never wrap */
.admin-table-actions-col,
.admin-table-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  padding-right: 0.875rem;
}

.admin-table-actions a + a {
  margin-left: 0.375rem;
}

.admin-table-title {
  font-weight: 500;
}

.admin-table-path {
  display: block;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 0.125rem;
  max-width: 30ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-table-tags {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0;
  border: none;
  border-left: 3px solid;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  margin-bottom: 1rem;
}

.alert-success {
  background: #defbe6;
  border-left-color: #24a148;
  color: var(--text-primary);
}

.alert-danger,
.alert-error {
  background: #fff1f1;
  border-left-color: #da1e28;
  color: var(--text-primary);
}

.alert-warning {
  background: #fcf4d6;
  border-left-color: #f1c21b;
  color: var(--text-primary);
}

.alert-info {
  background: #edf5ff;
  border-left-color: #0043ce;
  color: var(--text-primary);
}

/* ========== Utilities ========== */
.text-muted {
  color: var(--text-muted) !important;
}
.text-end {
  text-align: right;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 400;
  border-radius: 0;
  letter-spacing: 0.32px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: none;
}

main h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

/* ========== Browse page ========== */
.browse-header {
  margin-bottom: 1.5rem;
}

.browse-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.browse-breadcrumb a {
  color: var(--accent);
}
.browse-breadcrumb a:hover {
  text-decoration: underline;
}
.browse-breadcrumb-sep {
  color: var(--border);
}

.browse-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.browse-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

.browse-group {
  margin-bottom: 2rem;
}

.browse-group-header {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.browse-group-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.browse-group-unassigned {
  color: var(--text-muted);
}

.browse-group-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========== Doc list (browse + search) ========== */
.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-item {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.625rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease);
}

.doc-item:hover {
  background: var(--bg-hover);
}

.doc-item-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.doc-item-body {
  flex: 1;
  min-width: 0;
}

.doc-item-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  display: block;
}

.doc-item-title:hover {
  text-decoration: underline;
}

.doc-item-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0.1875rem 0 0.375rem;
  line-height: 1.45;
}

.doc-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.doc-tag {
  font-size: 0.75rem;
  font-weight: 400;
  padding: 0.125rem 0.5rem;
  border-radius: 0;
  background: var(--accent-subtle);
  color: var(--accent);
  border: none;
  letter-spacing: 0.32px;
  text-decoration: none;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.doc-tag:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.doc-item-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  margin-top: 0.25rem;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

.doc-item:hover .doc-item-arrow {
  opacity: 1;
}

/* ========== Search results (richer layout) ========== */
.results-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1rem;
}

.results-title em {
  font-style: normal;
  color: var(--accent);
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.results-item {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease);
}

.results-item:hover {
  background: var(--bg-hover);
}
.results-item:last-child {
  border-bottom: none;
}

.results-item-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  margin-top: 0.1875rem;
}

.results-item-body {
  flex: 1;
  min-width: 0;
}

.results-item-title a {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent);
}

.results-item-title a:hover {
  text-decoration: underline;
}

.results-item-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0.375rem;
  line-height: 1.45;
}

.results-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.375rem;
}

.results-item-process {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
}

.results-item-process:hover {
  color: var(--accent);
  text-decoration: none;
}

.results-badge {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.4375rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 0.125rem;
}

.results-empty {
  text-align: center;
  padding: 3rem 1rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 2;
}

.results-empty a {
  color: var(--accent);
}

/* ── Process management list (admin_processes.php) ─────────────────────────── */
.proc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.proc-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border-muted);
}

.proc-list-item:last-child {
  border-bottom: none;
}

.proc-list-text {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding-left: calc(var(--depth, 0) * 1.25rem);
}

.proc-list-parent {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.proc-list-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.btn-danger-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: 0;
  cursor: pointer;
  font-family: var(--font-sans);
  letter-spacing: 0.16px;
  transition:
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.btn-danger-ghost:hover {
  background: #fff1f1;
  border-color: #da1e28;
  color: #da1e28;
}

/* ── File meta row (size, date, extension badge) ─────────────────────────── */
.doc-item-file-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

.doc-file-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.32px;
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
}

.doc-file-size,
.doc-file-modified {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.doc-file-size::before {
  content: "";
}

.doc-file-modified::before {
  content: "· ";
  opacity: 0.5;
}

/* Admin table description sub-line */
.admin-table-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
  font-weight: 400;
  white-space: normal;
  max-width: 36ch;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Compress alerts ────────────────────────────────────────────────────────── */
.alert-compress-ok {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.alert-compress-warn {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.compress-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: #16a34a;
  color: #fff;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.compress-quality-label {
  font-size: 0.75rem;
  color: #15803d;
  text-transform: capitalize;
  background: #dcfce7;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
}

/* ── Compress modal ─────────────────────────────────────────────────────────── */
.compress-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compress-modal[hidden] {
  display: none;
}

.compress-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.compress-modal-box {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1.5rem;
  width: min(480px, 94vw);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.compress-modal-heading {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.compress-modal-file {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compress-quality-label-text {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.compress-quality-options {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1.25rem;
}

.compress-quality-option {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.5rem;
  align-items: start;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
  transition:
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.compress-quality-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.compress-quality-option input[type="radio"] {
  grid-row: 1 / 3;
  margin-top: 0.125rem;
  accent-color: var(--accent);
}

.compress-quality-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.compress-quality-recommended {
  font-size: 0.7rem;
  background: var(--accent);
  color: #fff;
  padding: 0.1rem 0.375rem;
  border-radius: 0;
  vertical-align: middle;
  margin-left: 0.25rem;
  letter-spacing: 0.32px;
}

.compress-quality-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  grid-column: 2;
}

.compress-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DIAGRAM LIST PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.diagram-list-page {
  padding: 0 0 2rem;
}

.diagram-list-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.diagram-list-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.1875rem;
}

.diagram-list-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
}

.diagram-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Diagram card grid ──────────────────────────────────────────────── */
.diagram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.diagram-card {
  border: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    box-shadow var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

.diagram-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 98, 254, 0.14);
}

/* Preview thumbnail */
.diagram-card-preview {
  background: #f8f9fc;
  border-bottom: 1px solid var(--border-muted);
  height: 160px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.diagram-card-preview-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.diagram-card-preview-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.diagram-card-svg-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

.diagram-card-svg-wrap svg {
  max-width: 100%;
  max-height: 140px;
  width: auto;
  height: auto;
}

/* Card body */
.diagram-card-body {
  padding: 0.875rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex: 1;
}

.diagram-card-name {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.diagram-card-name a {
  color: var(--text-primary);
  text-decoration: none;
}

.diagram-card-name a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.diagram-card-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.diagram-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

.diagram-card-actions {
  display: flex;
  gap: 0.375rem;
  margin-top: auto;
  padding-top: 0.625rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DIAGRAM VIEWER PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.viewer-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height) - 1px);
  overflow: hidden;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-muted);
  flex-shrink: 0;
}

.viewer-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex-wrap: wrap;
}

.viewer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.viewer-name {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 28ch;
}

.viewer-zoom-label {
  font-size: 0.75rem;
  min-width: 3.5ch;
  text-align: center;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.viewer-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
  flex-shrink: 0;
}

.viewer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.375rem 0 0.125rem;
  flex-shrink: 0;
}

/* ── Canvas (pan+zoom container) ─────────────────────────────────── */
.viewer-canvas-outer {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  background: #fff;
  border: 1px solid var(--border-muted);
  border-radius: 8px;
  margin: 0.5rem 0;
  position: relative;
}

.viewer-canvas-outer:active {
  cursor: grabbing;
}

.viewer-canvas-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: 0 0;
  will-change: transform;
}

.viewer-canvas-inner svg {
  display: block;
  max-width: none;
}

.viewer-meta-bar {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.25rem 0 0.5rem;
  flex-shrink: 0;
}

/* ── Full-width layout toggle ─────────────────────────────────────── */
.site-layout--fullview {
  grid-template-columns: 1fr !important;
  grid-template-areas: "main" !important;
  max-width: 100% !important;
  padding: 0 1rem !important;
}

.site-layout--fullview .sidebar-left,
.site-layout--fullview .sidebar-right {
  display: none;
}

.site-layout--fullview .site-main {
  grid-area: main;
}

/* ========== Mobile sidebar backdrop ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-height);
  background: rgba(0, 0, 0, 0.45);
  z-index: 199;
}

body.sidebar-open .sidebar-overlay {
  display: block;
}

/* ========== Responsive – Tablet (768px – 1023px) ========== */
@media (max-width: 1023px) {
  .header-inner {
    grid-template-columns: var(--sidebar-width) 1fr 48px;
  }

  .site-layout {
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas: "sidebar-left main";
  }

  .site-layout--wide {
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas: "sidebar-left main";
  }

  .sidebar-right {
    display: none;
  }

  .diagram-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

/* ========== Responsive – Mobile (< 768px) ========== */
@media (max-width: 767px) {
  /* Header: collapse grid to flex */
  .header-inner {
    display: flex;
    align-items: center;
    padding: 0;
  }

  .header-start {
    border-right: none;
    flex-shrink: 0;
  }

  .header-center {
    flex: 1;
    padding: 0 0.375rem;
    min-width: 0;
  }

  .header-end {
    border-left: none;
    flex-shrink: 0;
  }

  .header-search {
    max-width: none;
  }

  /* Single-column layout */
  .site-layout,
  .site-layout--wide,
  .site-layout--viewer {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
    padding: 0 0.75rem;
    gap: 0;
  }

  .sidebar-right {
    display: none;
  }

  /* Off-canvas sidebar drawer */
  .sidebar-left {
    position: fixed;
    top: var(--header-height);
    left: calc(-1 * var(--sidebar-width) - 2px);
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    max-height: none;
    background: var(--bg);
    border-right: 1px solid var(--border);
    z-index: 200;
    padding: 0.75rem 0;
    overflow-y: auto;
    transition:
      left 0.2s var(--ease),
      box-shadow 0.2s var(--ease);
    box-shadow: none;
  }

  body.sidebar-open .sidebar-left {
    left: 0;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.18);
  }

  /* Main content */
  .site-main {
    padding: 1rem 0;
    grid-area: main;
  }

  /* Viewer: full height single column */
  .site-layout--viewer {
    height: calc(100vh - var(--header-height));
  }

  /* Home page */
  .home-page {
    padding: 1rem 0 2rem;
  }

  .home-feature-grid {
    grid-template-columns: 1fr;
    padding: 0 0 1.5rem;
  }

  .item-desc {
    max-width: 100%;
  }

  /* Tables: horizontal scroll */
  .card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Admin upload form: stack vertically */
  .admin-upload-form {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-upload-field {
    min-width: 0;
    width: 100%;
  }

  .admin-upload-action {
    width: 100%;
    padding-bottom: 0;
  }

  .admin-upload-action .btn {
    width: 100%;
    justify-content: center;
  }

  /* Admin header: stack title and button */
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  /* Diagram list header */
  .diagram-list-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }

  /* Diagram grid: single column */
  .diagram-grid {
    grid-template-columns: 1fr;
  }

  /* Viewer toolbar */
  .viewer-name {
    max-width: 16ch;
  }

  /* Compress modal */
  .compress-modal-box {
    width: 96vw;
    padding: 1.25rem;
  }

  /* Browse header */
  .browse-header {
    margin-bottom: 1rem;
  }
}

/* ========================================================================
   HOME DASHBOARD  – IBM Carbon + code.html inspired
   ======================================================================== */

.home-dashboard {
  padding: 1.5rem 0 3rem;
}

.home-welcome {
  font-size: 1.75rem;
  font-weight: 300;
  color: var(--text-primary);
  margin: 0 0 1.25rem;
  letter-spacing: -0.02em;
}

/* ── Bento hero ── */
.home-bento {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  margin-bottom: 2rem;
}

.home-bento-feature {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1.75rem;
  min-height: 200px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.home-bento-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.1875rem 0.5rem;
  margin-bottom: 0.875rem;
  position: relative;
  z-index: 1;
}

.home-bento-badge--pdf {
  background: #fff1f1;
  color: #da1e28;
  border: 1px solid #ffd7d9;
}
.home-bento-badge--diagram {
  background: #edf5ff;
  color: #0043ce;
  border: 1px solid #d0e2ff;
}
.home-bento-badge--empty {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.home-bento-title {
  font-size: 1.375rem;
  font-weight: 400;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
  line-height: 1.3;
  position: relative;
  z-index: 1;
  max-width: 500px;
}

.home-bento-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
  max-width: 500px;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

.home-bento-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

/* Grid-dot decoration on right of featured card */
.home-bento-decoration {
  position: absolute;
  right: 0;
  top: 0;
  width: 40%;
  height: 100%;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 29px,
      var(--border-muted) 29px,
      var(--border-muted) 30px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 29px,
      var(--border-muted) 29px,
      var(--border-muted) 30px
    );
  opacity: 0.7;
  pointer-events: none;
}

/* Stats card */
.home-bento-stats {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.home-stats-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.32px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
}

.home-stat {
  margin-bottom: 1.125rem;
}

.home-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.home-stat-row strong {
  font-weight: 600;
  color: var(--text-primary);
}

.home-stat-bar {
  height: 4px;
  background: var(--bg-hover);
  width: 100%;
}

.home-stat-bar-fill {
  height: 4px;
  min-width: 4px;
  transition: width 0.4s var(--ease);
}

.home-stat-bar-fill--blue {
  background: var(--accent);
}
.home-stat-bar-fill--red {
  background: #da1e28;
}
.home-stat-bar-fill--green {
  background: #24a148;
}

.home-stats-link {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.home-stats-link:hover {
  text-decoration: underline;
}

/* ── Section heading ── */
.home-section-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.home-section-title {
  font-size: 1.125rem !important;
  font-weight: 600 !important;
  color: var(--text-primary);
  margin: 0 !important;
  letter-spacing: -0.01em;
}

.home-section-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.home-section-clear,
.home-section-link {
  margin-left: auto;
  font-size: 0.8125rem;
  color: var(--accent);
  text-decoration: none;
}

.home-section-clear:hover,
.home-section-link:hover {
  text-decoration: underline;
}

/* ── Item cards grid ── */
.item-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.item-card {
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}

.item-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 98, 254, 0.12);
}

.item-card-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.item-card-thumb--pdf {
  background: #fff1f1;
  color: #da1e28;
}
.item-card-thumb--diagram {
  background: #edf5ff;
  color: #0043ce;
}

.item-card-icon {
  opacity: 0.55;
  transition:
    opacity var(--duration) var(--ease),
    transform 0.2s var(--ease);
}

.item-card:hover .item-card-icon {
  opacity: 0.75;
  transform: scale(1.08);
}

.item-card-overlay {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.4rem;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

.item-card:hover .item-card-overlay {
  opacity: 1;
}

.item-card-body {
  padding: 0.75rem;
}

.item-card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.item-card-title:hover {
  color: var(--accent);
  text-decoration: none;
}

.item-card-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0 0 0.25rem;
  flex-wrap: wrap;
}

.item-card-type {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.125rem 0.375rem;
  flex-shrink: 0;
}

.item-card-type--pdf {
  background: #fff1f1;
  color: #da1e28;
  border: 1px solid #ffd7d9;
}
.item-card-type--diagram {
  background: #edf5ff;
  color: #0043ce;
  border: 1px solid #d0e2ff;
}

.item-card-date {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.item-card-process-link {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.item-card-process-link:hover {
  color: var(--accent);
}

/* ── Bottom split ── */
.home-split {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  margin-top: 0.5rem;
}

.home-split-col {
}

.home-split-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

/* Process suggestion cards */
.home-process-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.home-process-card {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  text-decoration: none;
  color: var(--text-primary);
  transition:
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

.home-process-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  text-decoration: none;
  color: var(--text-primary);
}

.home-process-icon {
  width: 40px;
  height: 40px;
  background: #edf5ff;
  color: #0043ce;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.home-process-info {
  flex: 1;
  min-width: 0;
}

.home-process-name {
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-process-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.125rem 0 0;
}

.home-process-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.doc-process-chip {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.1rem 0.4rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14ch;
}

.doc-process-chip:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .home-bento {
    grid-template-columns: 1fr;
  }
  .home-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .item-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* ========================================================================
   ADMIN INDEX PAGE  (ai- prefix = admin-index)
   ======================================================================== */

.ai-page {
  padding: 1.5rem 0 3rem;
}

/* Header */
.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.ai-header-left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.ai-title {
  font-size: 1.375rem;
  font-weight: 400;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.ai-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.ai-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Stats strip */
.ai-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 1.75rem;
}

.ai-stat {
  background: var(--bg);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ai-stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.ai-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.32px;
}

/* Body: table + panel */
.ai-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  align-items: start;
}

.ai-main {
  min-width: 0;
  overflow-x: auto;
}

.ai-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem !important;
  font-size: 0.875rem;
}

.ai-process-chip {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.1rem 0.45rem;
  text-decoration: none;
  white-space: nowrap;
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.ai-process-chip:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Upload panel */
.ai-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1.25rem;
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  display: block;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.ai-panel-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.32px;
}

.ai-panel-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0 0.25rem;
  display: none; /* shown only in mobile-toggle mode */
}

.ai-upload-form {
  width: 100%;
}

.ai-upload-form .form-control {
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

.ai-field {
  margin-bottom: 1rem;
}

.ai-upload-toggle-btn {
  display: none; /* hidden on wide screens, shown on narrow */
}

.ai-panel-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.32px;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.ai-quick-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ai-quick-links li {
  border-bottom: 1px solid var(--border);
}

.ai-quick-links li:last-child {
  border-bottom: none;
}

.ai-quick-links a {
  display: block;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}

.ai-quick-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Responsive: collapse panel behind a toggle button on narrow screens */
@media (max-width: 960px) {
  .ai-body {
    grid-template-columns: 1fr;
  }

  .ai-panel {
    position: fixed;
    top: 0;
    right: -340px;
    width: 320px;
    height: 100vh;
    z-index: 200;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    transition: right 0.2s var(--ease);
    padding-top: 2rem;
  }

  .ai-panel.ai-panel--open {
    right: 0;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  }

  .ai-panel-close {
    display: flex;
  }

  .ai-upload-toggle-btn {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .ai-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Custom file input */
.file-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.file-input-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Process autocomplete (proc-ac) ── */
.proc-ac {
  position: relative;
}

.proc-ac-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  max-height: 220px;
  overflow-y: auto;
  z-index: 300;
  list-style: none;
  margin: 0;
  padding: 0;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.proc-ac-option {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}

.proc-ac-option:hover,
.proc-ac-option.proc-ac-active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.proc-ac-new {
  color: var(--accent);
  border-top: 1px solid var(--border);
  font-style: italic;
}
