/* RiskMap base stylesheet */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f7fa;
    color: #1a202c;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    background: #1e293b;
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.navbar-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
}

.navbar-subtitle {
    margin-left: 0.75rem;
    color: #94a3b8;
    font-size: 0.875rem;
}

.navbar-menu {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.navbar-menu a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.navbar-menu a:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

.card h1 {
    margin-bottom: 1rem;
    color: #1e293b;
}

.card p {
    margin-bottom: 0.75rem;
    color: #475569;
}

.link {
    color: #3b82f6;
    text-decoration: none;
}

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

.footer {
    text-align: center;
    padding: 1rem;
    color: #94a3b8;
    font-size: 0.875rem;
    border-top: 1px solid #e2e8f0;
    background: white;
}

/* Admin tiles */
.admin-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.admin-tile {
    display: block;
    padding: 1.25rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    text-decoration: none;
    color: #1e293b;
    transition: all 0.15s;
}
.admin-tile:hover { border-color: #3b82f6; background: white; }
.admin-tile strong { display: block; margin-bottom: 0.25rem; font-size: 1.05rem; }
.admin-tile small { color: #64748b; }

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
.data-table th, .data-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}
.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
}
.row-inactive { opacity: 0.55; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}
.badge-super_admin { background: #dc2626; }
.badge-admin { background: #ea580c; }
.badge-category_owner { background: #2563eb; }
.badge-viewer { background: #64748b; }

/* Forms */
.form-row { margin-bottom: 1.25rem; }
.form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: #334155;
}
.form-row input[type="text"],
.form-row input[type="email"],
.form-row select {
    width: 100%;
    max-width: 500px;
    padding: 0.5rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font: inherit;
}
.form-row input[readonly] { background: #f1f5f9; color: #64748b; }
.muted { color: #94a3b8; font-weight: normal; font-size: 0.85rem; }
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0;
}
.checkbox-label {
    display: inline-flex !important;
    align-items: center;
    gap: 0.4rem;
    font-weight: normal !important;
    cursor: pointer;
    padding: 0.4rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    margin: 0 !important;
}
.checkbox-label:has(input:checked) {
    background: #dbeafe;
    border-color: #3b82f6;
}
.category-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 0.2rem;
}
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
}
.btn-primary {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}
.btn-primary:hover { background: #2563eb; }
.btn-secondary {
    background: white;
    color: #475569;
    border-color: #cbd5e1;
}
.btn-secondary:hover { background: #f8fafc; }
.link-button {
    background: none;
    border: none;
    color: #3b82f6;
    cursor: pointer;
    padding: 0;
    font: inherit;
}
.link-button:hover { text-decoration: underline; }

/* Error box */
.error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.nav-user { color: #cbd5e1; margin-right: 0.5rem; }

/* Import preview */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}
.stat-tile {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}
.stat-tile strong {
    display: block;
    margin-bottom: 0.5rem;
    color: #475569;
}
.stat-tile ul { list-style: none; padding: 0; }
.stat-tile li { padding: 0.2rem 0; color: #1e293b; }

.preview-table { font-size: 0.85rem; }
.preview-table td { vertical-align: top; }
.row-skipped { opacity: 0.5; background: #f1f5f9; }
.row-warning { background: #fffbeb; }

.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.badge-status {
    background: #64748b;
    font-size: 0.7rem;
}
.badge-status-open { background: #3b82f6; }
.badge-status-wip { background: #f59e0b; }
.badge-status-mitigated { background: #22c55e; }
.badge-status-accepted { background: #8b5cf6; }
.badge-status-transferred { background: #06b6d4; }
.badge-status-needs_assessment { background: #ef4444; }

.success-box {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
    padding: 1rem 1.25rem;
    border-radius: 6px;
    font-size: 1rem;
}

/* ============================================================
   Phase 2D — Risk list & detail pages
   ============================================================ */

/* --- Home actions row --- */
.home-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.btn-secondary {
    background: #e5e7eb;
    color: #1f2937;
    border: 1px solid #d1d5db;
}
.btn-secondary:hover {
    background: #d1d5db;
}

/* --- Page header --- */
.page-header {
    margin-bottom: 1.5rem;
}
.page-header h1 {
    margin: 0 0 0.25rem 0;
}
.page-subtitle {
    color: #6b7280;
    margin: 0;
    font-size: 0.95rem;
}
.needs-attention {
    color: #b91c1c;
    font-weight: 600;
}

/* --- Stats bar --- */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}
.stat-num {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}
.stat-label {
    font-size: 0.85rem;
    color: #6b7280;
}
.stat-open .stat-num { color: #2563eb; }
.stat-wip .stat-num { color: #d97706; }
.stat-needs .stat-num { color: #dc2626; }
.stat-mitigated .stat-num { color: #16a34a; }

/* --- Filter bar --- */
.filter-bar {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: end;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 160px;
}
.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
}
.filter-group select,
.filter-group input[type="search"] {
    padding: 0.4rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
}
.filter-group select:disabled,
.filter-group input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}
.filter-search { flex: 1 1 240px; }
.filter-toggle { align-self: end; }
.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    cursor: pointer;
}

/* --- Risk table --- */
.risk-table-wrap {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}
.risk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.risk-table thead {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}
.risk-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-weight: 600;
    color: #4b5563;
    font-size: 0.85rem;
}
.risk-table td {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid #f3f4f6;
    vertical-align: top;
}
.risk-row.clickable {
    cursor: pointer;
    transition: background 0.1s;
}
.risk-row.clickable:hover {
    background: #f9fafb;
}
.col-code { width: 60px; font-weight: 600; }
.col-code a { color: #2563eb; text-decoration: none; }
.col-code a:hover { text-decoration: underline; }
.col-cat { width: 140px; white-space: nowrap; }
.col-issue { min-width: 280px; }
.col-owner { width: 160px; }
.col-num { width: 40px; text-align: center; }
.col-status { width: 140px; }

.cat-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 0.4rem;
    vertical-align: middle;
}

/* --- Rating cell colors --- */
.rating-cell {
    display: inline-block;
    min-width: 28px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-align: center;
}
.rating-low  { background: #dcfce7; color: #166534; }
.rating-med  { background: #fef3c7; color: #92400e; }
.rating-high { background: #fed7aa; color: #9a3412; }
.rating-crit { background: #fecaca; color: #991b1b; }
.rating-none { background: #f3f4f6; color: #6b7280; }

/* --- Status pills --- */
.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}
.status-open       { background: #dbeafe; color: #1e40af; }
.status-wip        { background: #fed7aa; color: #9a3412; }
.status-mitigated  { background: #dcfce7; color: #166534; }
.status-needs-assessment { background: #fecaca; color: #991b1b; }
.status-accepted   { background: #e0e7ff; color: #3730a3; }
.status-transferred { background: #f3e8ff; color: #6b21a8; }

.status-pill-lg {
    font-size: 0.95rem;
    padding: 4px 12px;
}

/* --- Muted / inactive --- */
.muted { color: #9ca3af; font-size: 0.85rem; }

/* --- Pager --- */





.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

/* ============================================================
   Detail page
   ============================================================ */

.breadcrumbs {
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.breadcrumbs a {
    color: #6b7280;
    text-decoration: none;
}
nav.breadcrumbs a:hover {
    color: #2563eb;
    text-decoration: underline;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}
.detail-header-main {
    flex: 1;
    min-width: 0;
}
.detail-code-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #6b7280;
}
.detail-code {
    font-weight: 700;
    color: #111827;
    font-size: 1rem;
}
.detail-cat {
    font-weight: 500;
}
.detail-cat-secondary {
    color: #9ca3af;
}
.detail-title {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.3;
}
.detail-header-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}
.rating-block {
    text-align: center;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    min-width: 80px;
}
.rating-block .rating-num {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}
.rating-block .rating-label {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    opacity: 0.8;
}
.rating-block.rating-low  { background: #dcfce7; color: #166534; }
.rating-block.rating-med  { background: #fef3c7; color: #92400e; }
.rating-block.rating-high { background: #fed7aa; color: #9a3412; }
.rating-block.rating-crit { background: #fecaca; color: #991b1b; }
.rating-block.rating-none { background: #f3f4f6; color: #6b7280; }

.detail-body {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
@media (max-width: 768px) {
    .detail-body { grid-template-columns: 1fr; }
    .detail-header { flex-direction: column; }
}

.detail-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.detail-section h2 {
    font-size: 0.95rem;
    margin: 0 0 0.5rem 0;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.detail-prose {
    white-space: pre-wrap;
    color: #1f2937;
    line-height: 1.5;
}

.detail-meta-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.detail-meta-card h3 {
    font-size: 0.85rem;
    margin: 0 0 0.5rem 0;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.detail-meta-card .meta-subheader {
    margin-top: 1rem;
}
.meta-row {
    font-size: 0.9rem;
    color: #1f2937;
    padding: 0.2rem 0;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}
.meta-row-sub {
    color: #6b7280;
    font-size: 0.85rem;
}
.meta-key {
    color: #6b7280;
    font-size: 0.85rem;
}
.meta-val {
    color: #1f2937;
    text-align: right;
}

/* --- History timeline --- */
.detail-history {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}
.detail-history h2 {
    font-size: 1.1rem;
    margin: 0 0 1rem 0;
}
.history-timeline {
    list-style: none;
    padding: 0;
    margin: 0;
}
.history-entry {
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border-left: 3px solid #d1d5db;
    border-radius: 0 6px 6px 0;
    margin-bottom: 0.5rem;
}
.history-import { border-left-color: #2563eb; }
.history-update { border-left-color: #f59e0b; }
.history-create { border-left-color: #16a34a; }
.history-delete { border-left-color: #dc2626; }

.history-head {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}
.history-type {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.75rem;
    color: #4b5563;
}
.history-when {
    color: #6b7280;
}
.history-who {
    color: #6b7280;
    margin-left: auto;
}
.history-payload {
    font-size: 0.85rem;
    color: #4b5563;
    margin-top: 0.25rem;
}
.payload-key {
    font-weight: 600;
    color: #4b5563;
}
.payload-warnings ul {
    margin: 0.25rem 0 0 0;
    padding-left: 1.25rem;
}
.payload-warnings li {
    margin: 0.1rem 0;
}

/* ============================================================
   Phase 3A — Filter wiring: chips, actions, enabled controls
   ============================================================ */

/* Re-enable styling on previously-disabled controls (override Phase 2D's
   :disabled rule by being more specific or because :disabled no longer applies) */
.filter-group select,
.filter-group input[type="search"] {
    background: #fff;
    color: #1f2937;
    cursor: text;
}
.filter-group select { cursor: pointer; }
.filter-group select:focus,
.filter-group input[type="search"]:focus {
    outline: 2px solid #2563eb;
    outline-offset: -1px;
    border-color: #2563eb;
}

/* Apply button + Clear link */
.filter-actions {
    display: flex;
    align-items: end;
    gap: 0.5rem;
    min-width: auto;
}
.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}
.btn-link {
    color: #6b7280;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.4rem 0;
}
.btn-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* Active filter chips */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0 0.25rem;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #dbeafe;
    color: #1e3a8a;
    padding: 0.25rem 0.6rem;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.4;
}
.filter-chip-auto {
    background: #ede9fe;
    color: #5b21b6;
}
.chip-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1;
    font-weight: 600;
    transition: background 0.1s;
}
.chip-clear:hover {
    background: rgba(0, 0, 0, 0.2);
    color: inherit;
}

/* ============================================================
   Phase 3B — Edit form, flash banners, detail edit button
   ============================================================ */

/* --- Flash banners --- */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    border: 1px solid transparent;
}
.flash-success {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}
.flash-info {
    background: #dbeafe;
    color: #1e3a8a;
    border-color: #bfdbfe;
}
.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Edit button position in detail header */
.detail-edit-btn {
    align-self: flex-start;
    text-decoration: none;
}

/* --- Edit form layout --- */
.risk-edit-page {
    max-width: 900px;
}
.risk-form {
    background: transparent;
}
.form-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 0 0 1.25rem 0;
}
.form-section legend {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #4b5563;
    padding: 0 0.5rem;
    margin-left: -0.5rem;
}
.form-row {
    margin-bottom: 1rem;
}
.form-row:last-child {
    margin-bottom: 0;
}
.form-row label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.35rem;
}
.form-row .req {
    color: #dc2626;
    font-weight: 700;
}
.form-row input[type="text"],
.form-row input[type="search"],
.form-row input[type="date"],
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: #1f2937;
    box-sizing: border-box;
}
.form-row textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: 2px solid #2563eb;
    outline-offset: -1px;
    border-color: #2563eb;
}
.form-row .muted {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Inline row (L + I side by side, with helper text) */
.form-row-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-start;
}
.form-field-small {
    /* Label can be wider than the select; let label dictate column width. */
    flex: 0 0 auto;
    min-width: 100px;
}
.form-field-small label {
    white-space: nowrap;
}
.form-field-small select {
    width: 110px;
}
.form-helper {
    flex: 1 1 220px;
    padding-top: 1.5rem;
}

/* Locked input (for non-admin showing primary category) */
.locked-input {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 0.95rem;
    box-sizing: border-box;
}

/* Checkbox grids (secondary categories + co-owners) */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.4rem;
    padding: 0.5rem 0;
}
.checkbox-grid-coowner {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    background: #fafafa;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    font-weight: normal;
    cursor: pointer;
    padding: 0.2rem 0;
    margin-bottom: 0;
    color: #1f2937;
}
.checkbox-item input[type="checkbox"] {
    width: auto;
    margin: 0;
}
.checkbox-item .cat-swatch {
    margin-left: 0.1rem;
}

/* Co-owner filter input above the checkbox list */
.coowner-filter-input {
    margin-bottom: 0.5rem;
}

/* Field error message */
.field-error {
    color: #b91c1c;
    font-size: 0.85rem;
    margin: 0.35rem 0 0 0;
}

/* Alert (validation summary at top of form) */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}
.alert ul {
    margin: 0.25rem 0 0 0;
    padding-left: 1.25rem;
}

/* Form actions (Save / Cancel) */
.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e5e7eb;
}

/* Phase 3C — page header with right-aligned action button */
.page-header-with-action {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header-with-action .page-header-text {
  flex: 1 1 auto;
  min-width: 0;
}
.page-header-with-action .page-header-text h1 {
  margin: 0 0 .25rem 0;
}
.page-header-with-action .page-header-text .page-subtitle {
  margin: 0;
}
.page-header-with-action .page-header-actions {
  flex: 0 0 auto;
  padding-top: .25rem;
}

/* ============================================================ */
/* Phase 3D — Navbar logo + version + user menu */
/* ============================================================ */
.navbar-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.navbar-logo {
  height: 32px;
  width: 32px;
  object-fit: contain;
  display: block;
}
.navbar-app-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2px;
}
.navbar-version {
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}
.navbar-subtitle {
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.15);
  color: #94a3b8;
  font-size: 13px;
}
.navbar-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.navbar-user {
  position: relative;
}
.navbar-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #e2e8f0;
  padding: 6px 10px 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease;
}
.navbar-user-btn:hover {
  background: rgba(255,255,255,0.14);
}
.navbar-user-caret {
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.15s ease;
}
.navbar-user.open .navbar-user-caret {
  transform: rotate(180deg);
}
.navbar-user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
  padding: 8px 0;
  display: none;
  z-index: 1000;
}
.navbar-user.open .navbar-user-menu {
  display: block;
}
.navbar-user-info {
  padding: 8px 14px 10px;
  border-bottom: 1px solid #f1f5f9;
}
.navbar-user-name-full {
  font-weight: 600;
  font-size: 13px;
  color: #0f172a;
}
.navbar-user-email {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}
.navbar-user-role {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #475569;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
}
.navbar-user-menu .navbar-user-link,
.navbar-user-menu .navbar-user-link:link,
.navbar-user-menu .navbar-user-link:visited {
  display: block;
  padding: 8px 14px;
  font-size: 13px;
  color: #475569;
  text-decoration: none;
  margin-top: 4px;
}
.navbar-user-menu .navbar-user-link:hover,
.navbar-user-menu .navbar-user-link:focus {
  background: #f8fafc;
  color: #1e293b;
  text-decoration: none;
}
.navbar-user-menu .navbar-user-signout,
.navbar-user-menu .navbar-user-signout:link,
.navbar-user-menu .navbar-user-signout:visited {
  display: block;
  padding: 8px 14px;
  font-size: 13px;
  color: #b91c1c;
  text-decoration: none;
  margin-top: 4px;
}
.navbar-user-menu .navbar-user-signout:hover,
.navbar-user-menu .navbar-user-signout:focus {
  background: #fef2f2;
  color: #991b1b;
  text-decoration: none;
}

/* ============================================================ */
/* Phase 3D — Subtle table link styling (matches AssetDesk) */
/* ============================================================ */
/* Risk code chip — first column of the risk table */
.risk-table td.col-code a:link,
.risk-table td.col-code a:visited {
  display: inline-block;
  padding: 2px 10px;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  color: #1e40af;
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.risk-table td.col-code a:hover {
  background-color: #dbeafe;
  border-color: #93c5fd;
  text-decoration: none;
}

/* Pager links — subtle text style, hover underline */
.pager-links a:link,
.pager-links a:visited {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}
.pager-links a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}




/* Clickable rows in risk table — JS adds cursor:pointer too; this is the hover state */
.risk-table tbody tr[data-href] {
  transition: background-color 0.08s ease;
}
.risk-table tbody tr[data-href]:hover {
  background-color: #f8fafc;
}


/* ============================================================ */
/* Phase 3D — Numbered pager (top + bottom) */
/* ============================================================ */
.pager {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 20px 0;
}
.pager.pager-top {
  margin: 4px 0 16px;
}
.pager-info {
  font-size: 13px;
  color: #64748b;
}
.pager-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
  color: #334155;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.pager-btn:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
  text-decoration: none;
}
.pager-btn.pager-current {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #fff;
  cursor: default;
}
.pager-btn.pager-current:hover {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.pager-btn.pager-disabled {
  color: #cbd5e1;
  background: #f8fafc;
  border-color: #f1f5f9;
  cursor: not-allowed;
}
.pager-ellipsis {
  padding: 0 4px;
  color: #94a3b8;
  font-size: 14px;
  user-select: none;
}
.pager-keyboard-hint {
  font-size: 12px;
  color: #94a3b8;
}
.pager-keyboard-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 1px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-bottom-width: 2px;
  border-radius: 3px;
  line-height: 1.4;
}

/* Phase 3D — breadcrumb back-links: pill button style */
.breadcrumbs {
  margin-bottom: 1.25rem;
}
.breadcrumbs a,
.breadcrumbs a:link,
.breadcrumbs a:visited {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  padding: 0.4rem 0.85rem !important;
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  color: #475569 !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  line-height: 1.2 !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transition: all 0.15s ease !important;
}
.breadcrumbs a:hover {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
  text-decoration: none !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08) !important;
}
.breadcrumbs a:active {
  background: #f1f5f9 !important;
  transform: translateY(1px) !important;
}

/* Error pages (403/404/500) */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem 1rem;
}
.error-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 3rem 2.5rem;
  text-align: center;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.error-code {
  font-size: 4rem;
  font-weight: 700;
  color: #cbd5e1;
  line-height: 1;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}
.error-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 0.75rem 0;
}
.error-detail {
  color: #64748b;
  font-size: 0.95rem;
  margin: 0 0 1.75rem 0;
  line-height: 1.5;
}
.error-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

/* ============================================================ */

/* ============================================================ */
/* Assessment scoring guide v2 — slide-in / pinnable side panel */
.assessment-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  margin-left: 0.75rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: all 0.15s ease;
}
.assessment-open-btn::before {
  content: "?";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-weight: 700;
  font-size: 11px;
}
.assessment-open-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #1e293b;
}

/* Backdrop only shown when panel is in modal (unpinned) mode */
.assessment-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.assessment-backdrop.open { opacity: 1; }
/* When pinned, no backdrop */
body.assessment-pinned .assessment-backdrop { display: none !important; }



.assessment-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}
.assessment-panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}
.assessment-panel-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.assessment-panel-pin {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}
.assessment-panel-pin:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #1e293b;
}
.assessment-panel-pin[aria-pressed="true"] {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.assessment-panel-pin .pin-icon { font-size: 0.85rem; }
.assessment-panel-close {
  background: transparent;
  border: 0;
  color: #94a3b8;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 0.3rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.12s ease;
}
.assessment-panel-close:hover {
  background: #f1f5f9;
  color: #475569;
}

.assessment-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem 1.5rem;
}
.assessment-axis { margin-bottom: 1.4rem; }
.assessment-axis h3 {
  margin: 0 0 0.25rem 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: #0f172a;
}
.assessment-axis-help {
  margin: 0 0 0.6rem 0;
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.45;
}

.assessment-table-scroll {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.assessment-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  background: #ffffff;
}
.assessment-table-likelihood {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}
.assessment-table thead th {
  background: #1e293b;
  color: #f8fafc;
  font-weight: 600;
  text-align: left;
  padding: 0.45rem 0.55rem;
  font-size: 0.75rem;
  vertical-align: middle;
  border-right: 1px solid #334155;
}
.assessment-table thead th:last-child { border-right: 0; }
.assessment-table thead th.col-group { text-align: center; }
.assessment-table thead th.col-score,
.assessment-table thead th.col-descriptor { background: #1e293b; }
.assessment-table thead th.col-type-active {
  background: #1e40af;
  color: #ffffff;
}

.assessment-table tbody td {
  padding: 0.5rem 0.6rem;
  border-top: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  vertical-align: top;
  color: #334155;
  line-height: 1.4;
}
.assessment-table tbody td:last-child { border-right: 0; }
.assessment-table tbody tr:nth-child(even) td { background: #f8fafc; }
.assessment-table tbody td.cell-active {
  background: #eff6ff !important;
  color: #0f172a;
}
.assessment-table tbody td.cell-active strong { color: inherit; }

.assessment-descriptor {
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
}
.assessment-score-cell {
  text-align: center;
  width: 50px;
}
.assessment-score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-weight: 600;
  font-size: 0.82rem;
}
.assessment-row-score-1 .assessment-score-badge { border-color: #22c55e; color: #15803d; }
.assessment-row-score-2 .assessment-score-badge { border-color: #84cc16; color: #4d7c0f; }
.assessment-row-score-3 .assessment-score-badge { border-color: #eab308; color: #a16207; }
.assessment-row-score-4 .assessment-score-badge { border-color: #f97316; color: #c2410c; }
.assessment-row-score-5 .assessment-score-badge { border-color: #ef4444; color: #b91c1c; }

.assessment-rating-info {
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}
.assessment-rating-info h3 {
  margin: 0 0 0.4rem 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: #0f172a;
}
.assessment-rating-info p {
  margin: 0;
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.5;
}

/* Tighten legend so the "View scoring guide" button sits inline */
.form-section legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  body.assessment-pinned .main-content { padding-right: 0; }
  body.assessment-pinned .assessment-panel { width: 100%; }
}


/* Impact table: tighter cells so all 5 type columns fit comfortably */
.assessment-table-impact { font-size: 0.72rem; }
.assessment-table-impact tbody td,
.assessment-table-impact thead th {
  padding: 0.4rem 0.45rem;
  line-height: 1.35;
}
.assessment-table-impact .col-type,
.assessment-table-impact .col-descriptor,
.assessment-table-impact .col-score { white-space: nowrap; }
.assessment-table-impact tbody .assessment-desc { min-width: 90px; }


/* L/I dropdowns now show full descriptor label — need more width than form-field-small default */
#f-l, #f-i {
  width: 100%;
  min-width: 180px;
}
.form-section .form-field-small:has(#f-l),
.form-section .form-field-small:has(#f-i) {
  min-width: 200px;
  flex: 0 0 auto;
}

/* ============================================================ */
/* Risk Assessment Heat Map (scoring guide) */
.heatmap-wrap {
  display: block;
  margin-top: 0.4rem;
}
.heatmap-grid {
  border-collapse: collapse;
  font-size: 0.78rem;
  width: 100%;
  table-layout: fixed;
}
.heatmap-grid th,
.heatmap-grid td {
  border: 1px solid #e2e8f0;
  text-align: center;
  vertical-align: middle;
  padding: 0.4rem 0.3rem;
  line-height: 1.2;
}
.heatmap-axis-y {
  background: #1e293b;
  color: #f8fafc;
  font-weight: 600;
  font-size: 0.75rem;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  width: 28px;
  letter-spacing: 0.04em;
}
.heatmap-descriptor {
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 500;
  font-size: 0.72rem;
  text-align: left;
  padding-left: 0.55rem;
  white-space: nowrap;
  width: 90px;
}
.heatmap-score-label {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 0.78rem;
  width: 28px;
}
.heatmap-cell {
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}

/* Band colors (matching BBTC Excel) */
/* BBTC 4-band scheme: matrix lookup defines per-cell band (not pure rating range) */
.band-monitor  { background: #3b82f6; }                                          /* blue: Monitor */
.band-manage   { background: #22c55e; }                                          /* green: Manage */
.band-treat    { background: #eab308; color: #1e293b; text-shadow: none; }       /* yellow: Treat */
.band-escalate { background: #ef4444; }                                          /* red: Escalate */

/* X-axis bottom labels */
.heatmap-x-scores th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 0.78rem;
  border-color: #e2e8f0;
}
.heatmap-x-labels th {
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 500;
  font-size: 0.7rem;
  border-color: #e2e8f0;
  padding: 0.35rem 0.2rem;
}
.heatmap-x-axis-title th {
  background: #1e293b;
  color: #f8fafc;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  border-color: #334155;
  padding: 0.4rem;
}

/* Legend */
.heatmap-legend {
  list-style: none;
  margin: 0.75rem 0 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 1rem;
  font-size: 0.74rem;
  color: #475569;
}
.heatmap-legend li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ============================================================ */
/* Dashboard layout */
.dashboard-page { padding: 0; }
.dashboard-header {
  margin-bottom: 1.5rem;
}
.dashboard-header h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: #0f172a;
}
.dashboard-subtitle {
  margin: 0;
  color: #64748b;
  font-size: 0.95rem;
}
.dashboard-empty-state {
  padding: 2rem;
  text-align: center;
  color: #64748b;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}
.dashboard-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  grid-column: span 6;
}
.dashboard-section h2 {
  margin: 0 0 0.6rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
}
.dashboard-section-wide { grid-column: span 12; }

.dashboard-placeholder p { font-size: 0.85rem; }

@media (max-width: 900px) {
  .dashboard-section { grid-column: span 12; }
}

/* ============================================================ */
/* Dashboard — section header (title + filters) */
.dashboard-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.dashboard-section-header h2 { margin: 0; }
.dashboard-filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.dashboard-toggle {
  display: inline-flex;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  padding: 2px;
  gap: 2px;
}
.dashboard-toggle-btn {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #64748b;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.12s ease;
}
.dashboard-toggle-btn:hover {
  background: #ffffff;
  color: #1e293b;
}
.dashboard-toggle-btn.is-active {
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.dashboard-heatmap-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: #475569;
  margin-bottom: 0.5rem;
}
.dashboard-heatmap-meta a {
  color: #b91c1c;
  text-decoration: none;
  font-weight: 600;
}
.dashboard-heatmap-meta a:hover { text-decoration: underline; }

/* Dashboard heatmap grid — larger than the scoring-guide grid, clickable cells */
.dashboard-heatmap-wrap { width: 100%; }
.dashboard-heatmap-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.85rem;
}
.dashboard-heatmap-grid th,
.dashboard-heatmap-grid td {
  border: 1px solid #e2e8f0;
  text-align: center;
  vertical-align: middle;
  padding: 0;
  line-height: 1.2;
}
.dashboard-heatmap-grid .heatmap-axis-y,
.dashboard-heatmap-grid .heatmap-descriptor,
.dashboard-heatmap-grid .heatmap-score-label,
.dashboard-heatmap-grid .heatmap-x-scores th,
.dashboard-heatmap-grid .heatmap-x-labels th,
.dashboard-heatmap-grid .heatmap-x-axis-title th {
  padding: 0.4rem 0.4rem;
}

.dashboard-heatmap-cell {
  height: 64px;
  padding: 0;
}
.dashboard-heatmap-cell .cell-count {
  display: block;
  font-weight: 700;
  font-size: 1.4rem;
  color: #ffffff;
  line-height: 1.05;
  text-shadow: 0 1px 1px rgba(0,0,0,0.18);
}
.dashboard-heatmap-cell .cell-rating {
  display: block;
  margin-top: 2px;
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
}
.dashboard-heatmap-cell.band-treat .cell-count { color: #1e293b; text-shadow: none; }
.dashboard-heatmap-cell.band-treat .cell-rating { color: rgba(30,41,59,0.7); }

.dashboard-heatmap-cell.is-empty { opacity: 0.45; }
.dashboard-heatmap-cell.is-empty .cell-count {
  font-size: 1.1rem;
  font-weight: 500;
  color: #ffffff;
}

.dashboard-heatmap-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 0.45rem 0.3rem;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}
.dashboard-heatmap-cell.has-risks .dashboard-heatmap-link:hover {
  filter: brightness(1.08);
  transform: scale(1.02);
}
.dashboard-heatmap-cell.has-risks .dashboard-heatmap-link:focus-visible {
  outline: 3px solid #1e40af;
  outline-offset: -3px;
}

@media (max-width: 768px) {
  .dashboard-heatmap-cell { height: 52px; }
  .dashboard-heatmap-cell .cell-count { font-size: 1.05rem; }
  .dashboard-heatmap-cell .cell-rating { font-size: 0.55rem; }
}

/* ============================================================ */
/* Dashboard — hero counts row */
.dashboard-hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.dashboard-stat {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
a.dashboard-stat:hover {
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}
.dashboard-stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.dashboard-stat-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.05;
}
.dashboard-stat-help {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.35rem;
}
.dashboard-stat-primary .dashboard-stat-value { color: #1d4ed8; }
.dashboard-stat-warn .dashboard-stat-value { color: #b91c1c; }

@media (max-width: 900px) {
  .dashboard-hero { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .dashboard-hero { grid-template-columns: 1fr; }
}

/* ============================================================ */
/* Dashboard — bar lists (by status, by category) */
.dashboard-barlist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.dashboard-barlist-link {
  display: grid;
  grid-template-columns: 130px 1fr 40px;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s ease;
}
.dashboard-barlist-link:hover { background: #f8fafc; }
.dashboard-barlist-bar-wrap {
  background: #f1f5f9;
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
}
.dashboard-barlist-bar {
  display: block;
  height: 100%;
  background: #94a3b8;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.dashboard-barlist-bar.status-open { background: #3b82f6; }
.dashboard-barlist-bar.status-wip { background: #eab308; }
.dashboard-barlist-bar.status-needs-assessment { background: #b91c1c; }
.dashboard-barlist-bar.status-mitigated { background: #22c55e; }
.dashboard-barlist-bar.status-accepted { background: #64748b; }
.dashboard-barlist-bar.status-transferred { background: #a855f7; }
.dashboard-barlist-count {
  text-align: right;
  font-weight: 600;
  color: #1e293b;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

/* Generic status pill (reused in dashboard + risks list) */
.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-open { background: #dbeafe; color: #1e40af; }
.status-wip { background: #fef3c7; color: #92400e; }
.status-needs-assessment { background: #fee2e2; color: #991b1b; }
.status-mitigated { background: #dcfce7; color: #166534; }
.status-accepted { background: #e2e8f0; color: #334155; }
.status-transferred { background: #f3e8ff; color: #6b21a8; }

/* Category chip */
.cat-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.cat-chip-sm { padding: 1px 7px; font-size: 0.7rem; border: 0 !important; }

/* Rating chip in tables */
.rating-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
}
.rating-chip.band-treat { color: #1e293b; }

/* ============================================================ */
/* Dashboard tables */
.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.dashboard-table thead th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #e2e8f0;
}
.dashboard-table thead th.num { text-align: right; }
.dashboard-table tbody td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: #334155;
}
.dashboard-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dashboard-table tbody tr:hover { background: #f8fafc; }
.dashboard-table-issue {
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.overdue-days { color: #b91c1c; font-weight: 600; }

/* Risk code chip (link form) */
.risk-code-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #1d4ed8;
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.12s ease;
}
.risk-code-chip:hover {
  background: #dbeafe;
  text-decoration: none;
}

/* ============================================================ */
/* Dashboard list (recent activity) */
.dashboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.dashboard-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.6rem;
  align-items: center;
  padding: 0.5rem 0.55rem;
  border-radius: 6px;
  border: 1px solid #f1f5f9;
}
.dashboard-list li .risk-code-chip { grid-row: 1 / 3; align-self: center; }
.dashboard-list-issue {
  font-size: 0.85rem;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dashboard-list-meta {
  font-size: 0.72rem;
  color: #64748b;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* ============================================================ */
/* Admin assessments edit form */
.admin-edit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.admin-edit-table thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #e2e8f0;
}
.admin-edit-table thead th.num { text-align: center; }
.admin-edit-table tbody td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.admin-edit-table tbody td.num { text-align: center; width: 60px; }
.admin-edit-table input[type="text"] {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #ffffff;
}
.admin-edit-table input[type="text"]:focus {
  outline: 2px solid #2563eb;
  outline-offset: -1px;
  border-color: transparent;
}
.admin-edit-table textarea {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  background: #ffffff;
  resize: vertical;
  line-height: 1.4;
}
.admin-edit-table textarea:focus {
  outline: 2px solid #2563eb;
  outline-offset: -1px;
  border-color: transparent;
}

/* Impact score block (per-score grid of 5 type columns) */
.admin-impact-score-block {
  margin: 0.5rem 0 1.5rem 0;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.admin-impact-score-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.admin-impact-label-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  font-size: 0.85rem;
}
.admin-impact-label-input input[type="text"] {
  flex: 1;
  max-width: 280px;
}
.admin-impact-grid { background: #ffffff; }

/* Category mapping table — checkbox grid */
.admin-category-mapping td.num { width: 90px; }
.admin-category-mapping input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Admin home — link cards */
.admin-link-card {
  display: block;
  padding: 1rem 1.2rem;
  margin-top: 0.6rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
}
.admin-link-card:hover {
  border-color: #93c5fd;
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}
.admin-link-card strong {
  display: block;
  color: #1e293b;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}
.admin-link-card small { color: #64748b; font-size: 0.8rem; }

/* Success/error alerts */
.alert {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.alert-success {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

/* Standalone assessments page wrap */
.assessments-page .assessments-content {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
}




/* ============================================================ */
/* Scoring guide edge tab — docked vertical trigger on right side */
.assessment-edge-tab {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 0.45rem;
  background: #1e293b;
  color: #f8fafc;
  border: 0;
  border-radius: 10px 0 0 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  box-shadow: -2px 0 10px rgba(15, 23, 42, 0.15);
  transition: all 0.18s ease;
}
.assessment-edge-tab .edge-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f8fafc;
  color: #1e293b;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}
.assessment-edge-tab .edge-tab-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.05em;
}
.assessment-edge-tab:hover {
  background: #0f172a;
  padding-right: 0.7rem;
  box-shadow: -4px 0 14px rgba(15, 23, 42, 0.22);
}
.assessment-edge-tab:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

/* Hide the edge tab when the panel is open (modal or pinned) */
body.assessment-pinned .assessment-edge-tab,
body.assessment-panel-open .assessment-edge-tab {
  display: none;
}

/* Mobile: smaller edge tab */
@media (max-width: 600px) {
  .assessment-edge-tab {
    padding: 0.7rem 0.35rem;
    font-size: 0.7rem;
  }
  .assessment-edge-tab .edge-tab-icon { width: 18px; height: 18px; font-size: 0.75rem; }
}





/* ============================================================ */
/* SCORING GUIDE PANEL — canonical positioning (consolidated) */
/* Replaces multiple conflicting rules across the file. */

.navbar {
  position: relative;
  z-index: 200;
}

.assessment-backdrop {
  position: fixed;
  top: 64px;             /* clear navbar */
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.assessment-backdrop.open { opacity: 1; }
body.assessment-pinned .assessment-backdrop { display: none !important; }

.assessment-panel {
  position: fixed;
  top: 64px;             /* clear navbar */
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100%;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.08);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}
.assessment-panel.open { transform: translateX(0); }

body.assessment-pinned .assessment-panel {
  box-shadow: -1px 0 0 #e2e8f0;
}
body.assessment-pinned .main-content {
  padding-right: 500px;
  transition: padding-right 0.22s ease;
}

@media (max-width: 900px) {
  body.assessment-pinned .main-content { padding-right: 0; }
  body.assessment-pinned .assessment-panel { width: 100%; }
  .assessment-panel, .assessment-backdrop { top: 56px; }
}

/* ============================================================ */
/* RiskMap Export Submenu */
.navbar-user-submenu-wrap {
  position: relative;
}
.navbar-user-submenu-trigger {
  /* Inherit .navbar-user-link styling, but as a button */
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  color: #475569;
}
.navbar-user-submenu-trigger:hover,
.navbar-user-submenu-trigger:focus {
  background: #f8fafc;
  color: #1e293b;
  outline: none;
}
.navbar-user-submenu-caret {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 8px;
  transition: transform 0.15s ease;
}
.navbar-user-submenu-wrap.open .navbar-user-submenu-caret {
  transform: rotate(90deg);
}
.navbar-user-submenu {
  position: absolute;
  right: calc(100% + 6px);
  top: -8px;
  min-width: 200px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
  padding: 8px 0;
  display: none;
  z-index: 1001;
}
.navbar-user-submenu-wrap.open .navbar-user-submenu {
  display: block;
}
.navbar-user-submenu-heading {
  padding: 6px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #94a3b8;
}
.navbar-user-submenu-sep {
  height: 1px;
  background: #f1f5f9;
  margin: 6px 0;
}
.navbar-user-submenu .navbar-user-link {
  margin-top: 0;
}

/* Mobile: submenu opens below instead of beside, since right-of-parent
   would push off-screen on narrow viewports */
@media (max-width: 640px) {
  .navbar-user-submenu {
    position: static;
    box-shadow: none;
    border: none;
    border-top: 1px solid #f1f5f9;
    border-radius: 0;
    margin: 4px 0 0;
    padding: 4px 0 4px 8px;
  }
}

/* Filter indicator on export entries */
.export-filter-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2563eb;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.navbar-user-submenu-wrap.has-filter .navbar-user-submenu-trigger {
  font-weight: 500;
}

/* Danger button (delete, destructive actions) */
.btn-danger,
.btn.btn-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.btn-danger:hover,
.btn.btn-danger:hover {
  background: #fecaca;
  color: #7f1d1d;
  border-color: #fca5a5;
}

/* Actions cell — keep inline forms on one row with consistent spacing */
.actions-cell {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}
.actions-cell form {
  margin: 0;
}

/* Primary navigation in navbar — Dashboard + Risk Register */
.navbar-primary-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 24px;
}
.navbar-nav-link,
.navbar-nav-link:link,
.navbar-nav-link:visited {
  color: #cbd5e1;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.navbar-nav-link:hover,
.navbar-nav-link:focus {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.navbar-nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}



/* === Branded login page === */
.login-page {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}
.login-card {
    background: white;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    padding: 48px 40px 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}
.login-logo img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 20px;
}
.login-title {
    font-size: 32px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 12px;
}
.login-subtitle {
    color: #64748b;
    font-size: 15px;
    line-height: 1.5;
    margin: 0 0 32px;
}
.login-subtitle .login-org {
    color: #475569;
    font-weight: 500;
}
.btn-microsoft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    background: #2f2f2f;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 15px;
    transition: background 0.15s ease;
    border: 1px solid #2f2f2f;
}
.btn-microsoft:hover,
.btn-microsoft:focus {
    background: #1f1f1f;
    border-color: #1f1f1f;
    color: white;
    text-decoration: none;
}
.btn-microsoft svg {
    flex-shrink: 0;
}
.login-help {
    margin-top: 28px;
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.5;
}
/* ============================================================ */
/* Phase 4 — Mobile responsive layer
   Targets real selectors in RiskMap. Append to end of app.css.
   Breakpoints: 900px (tablet), 640px (phone), 480px (small phone)
   ============================================================ */

/* --- Hamburger button (hidden on desktop) --- */
.navbar-hamburger {
    display: none;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #e2e8f0;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    align-items: center;
    justify-content: center;
}
.navbar-hamburger:hover {
    background: rgba(255,255,255,0.14);
}
.navbar-hamburger:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}
.navbar-hamburger .hamburger-icon {
    display: inline-block;
    line-height: 1;
}

/* ============================================================ */
/* TABLET (<= 900px)                                              */
/* ============================================================ */
@media (max-width: 900px) {

    /* --- Navbar layout: stack hamburger on right, collapse menu --- */
    .navbar {
        padding: 0.6rem 1rem;
        flex-wrap: wrap;
    }
    .navbar-version {
        display: none;  /* save space; brand + app name only */
    }
    .navbar-hamburger {
        display: inline-flex;
        order: 2;
    }
    .navbar-brand {
        order: 1;
    }
    .navbar-menu {
        order: 3;
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        margin-left: 0;
        margin-top: 0.6rem;
        padding-top: 0.6rem;
        border-top: 1px solid rgba(255,255,255,0.12);
    }
    .navbar-menu.is-open {
        display: flex;
    }

    /* Primary nav: stack vertically inside collapsed menu */
    .navbar-primary-nav {
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
        gap: 2px;
        width: 100%;
    }
    .navbar-nav-link {
        padding: 0.7rem 0.9rem;
        border-radius: 6px;
    }

    /* User dropdown: full width inside collapsed menu */
    .navbar-user {
        width: 100%;
    }
    .navbar-user-btn {
        width: 100%;
        justify-content: space-between;
    }
    .navbar-user-menu {
        position: static;
        width: 100%;
        margin-top: 4px;
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }

    /* Main content padding */
    .main-content {
        padding: 1.25rem 1rem;
    }

    /* Detail header already stacks (existing rule); ensure rating block fits */
    .detail-header-meta {
        width: 100%;
        justify-content: flex-start;
    }

    /* Page header w/ action — let the button drop to a new line */
    .page-header-with-action {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header-with-action .page-header-actions {
        padding-top: 0.5rem;
    }

    /* Stats bar tighter */
    .stats-bar {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 0.5rem;
    }
    .stat-num { font-size: 1.5rem; }
    .stat-card { padding: 0.75rem; }
}

/* ============================================================ */
/* PHONE (<= 640px)                                               */
/* ============================================================ */
@media (max-width: 640px) {

    /* --- Risk register table: convert rows to cards --- */
    /* Hide table header */
    .risk-table thead {
        display: none;
    }
    .risk-table,
    .risk-table tbody,
    .risk-table tr,
    .risk-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    .risk-table tbody tr {
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 0.6rem;
        padding: 0.6rem 0.8rem;
        background: #fff;
    }
    .risk-table tbody tr[data-href]:hover {
        background: #f8fafc;
    }
    .risk-table td {
        padding: 0.25rem 0;
        border-top: 0;
        text-align: left;
    }
    /* Column-specific cell layout */
    .risk-table td.col-code {
        width: auto;
        margin-bottom: 0.35rem;
    }
    .risk-table td.col-cat {
        width: auto;
        white-space: normal;
    }
    .risk-table td.col-issue {
        font-weight: 500;
        color: #1e293b;
        min-width: 0;
        padding: 0.35rem 0;
    }
    .risk-table td.col-num,
    .risk-table td.col-status,
    .risk-table td.col-owner {
        width: auto;
        text-align: left;
    }
    /* Inline label/value layout via data-label="..." (added in templates) */
    .risk-table td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #64748b;
        font-size: 0.8rem;
        margin-right: 0.4rem;
    }
    /* Code + Issue cells don't need labels — they're the headline */
    .risk-table td.col-code[data-label]::before,
    .risk-table td.col-issue[data-label]::before {
        content: none;
    }
    .risk-table-wrap {
        border: 0;
        background: transparent;
        overflow: visible;
    }

    /* --- Filter bar: stack vertically, wider inputs --- */
    .filter-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }
    .filter-group {
        min-width: 0;
        width: 100%;
    }
    .filter-search {
        flex: 1 1 auto;
    }
    .filter-actions {
        flex-direction: row;
        justify-content: flex-start;
    }

    /* --- Stats bar: 2-up --- */
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    /* --- Form inline rows stack --- */
    .form-row-inline {
        flex-direction: column;
        gap: 0.75rem;
    }
    .form-field-small select {
        width: 100%;
    }
    .form-helper {
        padding-top: 0;
    }

    /* --- Dashboard barlist: wider label column on small screens --- */
    .dashboard-barlist-link {
        grid-template-columns: 100px 1fr 36px;
        gap: 0.4rem;
    }
    .dashboard-table-issue {
        max-width: 200px;
    }

    /* --- Pager: tighter spacing, smaller buttons --- */
    .pager-btn {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 13px;
    }
    .pager-keyboard-hint {
        display: none;  /* no keyboard on mobile */
    }

    /* --- Page header --- */
    .page-header h1,
    .dashboard-header h1 {
        font-size: 1.3rem;
    }

    /* --- Detail page: rating block goes full row --- */
    .detail-header-meta {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .rating-block {
        min-width: 70px;
        padding: 0.4rem 0.75rem;
    }
    .rating-block .rating-num {
        font-size: 1.5rem;
    }

    /* --- Card padding --- */
    .card {
        padding: 1.25rem;
    }
    .form-section {
        padding: 1rem 1.1rem;
    }

    /* --- Assessment edge tab: smaller on phone --- */
    .assessment-edge-tab {
        padding: 0.6rem 0.3rem;
    }
    .assessment-edge-tab .edge-tab-label {
        font-size: 0.65rem;
    }

    /* --- Dashboard table issue column: ellipsis works in narrow viewport --- */
    .dashboard-table thead th,
    .dashboard-table tbody td {
        padding: 0.4rem 0.45rem;
        font-size: 0.8rem;
    }
}

/* ============================================================ */
/* SMALL PHONE (<= 480px)                                         */
/* ============================================================ */
@media (max-width: 480px) {

    .main-content {
        padding: 1rem 0.75rem;
    }

    /* Hide app name to save room — logo + version-less */
    .navbar {
        padding: 0.5rem 0.75rem;
    }
    .navbar-app-name {
        font-size: 16px;
    }

    /* Single-column stats */
    .stats-bar {
        grid-template-columns: 1fr;
    }

    /* Risk table cards more compact */
    .risk-table tbody tr {
        padding: 0.5rem 0.65rem;
    }

    /* Filter chips wrap cleanly */
    .active-filters {
        gap: 0.35rem;
    }

    /* Buttons in form-actions stack */
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .form-actions .btn {
        width: 100%;
        text-align: center;
    }

    /* Breadcrumbs stay compact */
    .breadcrumbs a {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.8rem !important;
    }

    /* Heatmap stays readable */
    .heatmap-grid { font-size: 0.62rem; }
    .heatmap-descriptor { width: 70px; font-size: 0.6rem; }
}

/* ============================================================ */
/* Touch-friendly form inputs everywhere (prevent iOS zoom)       */
/* ============================================================ */
@media (max-width: 900px) {
    .form-row input[type="text"],
    .form-row input[type="search"],
    .form-row input[type="email"],
    .form-row input[type="date"],
    .form-row select,
    .form-row textarea,
    .filter-group select,
    .filter-group input[type="search"],
    .form-field-small select,
    #f-l, #f-i {
        font-size: 16px;  /* iOS Safari does not auto-zoom on >= 16px */
    }
}
/* ============================================================ */
/* Phase 4 — Mobile responsive layer
   Targets real selectors in RiskMap. Append to end of app.css.
   Breakpoints: 900px (tablet), 640px (phone), 480px (small phone)
   ============================================================ */

/* --- Hamburger button (hidden on desktop) --- */
.navbar-hamburger {
    display: none;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #e2e8f0;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    align-items: center;
    justify-content: center;
}
.navbar-hamburger:hover {
    background: rgba(255,255,255,0.14);
}
.navbar-hamburger:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}
.navbar-hamburger .hamburger-icon {
    display: inline-block;
    line-height: 1;
}

/* ============================================================ */
/* TABLET (<= 900px)                                              */
/* ============================================================ */
@media (max-width: 900px) {

    /* --- Navbar layout: stack hamburger on right, collapse menu --- */
    .navbar {
        padding: 0.6rem 1rem;
        flex-wrap: wrap;
    }
    .navbar-version {
        display: none;  /* save space; brand + app name only */
    }
    .navbar-hamburger {
        display: inline-flex;
        order: 2;
    }
    .navbar-brand {
        order: 1;
    }
    .navbar-menu {
        order: 3;
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        margin-left: 0;
        margin-top: 0.6rem;
        padding-top: 0.6rem;
        border-top: 1px solid rgba(255,255,255,0.12);
    }
    .navbar-menu.is-open {
        display: flex;
    }

    /* Primary nav: stack vertically inside collapsed menu */
    .navbar-primary-nav {
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
        gap: 2px;
        width: 100%;
    }
    .navbar-nav-link {
        padding: 0.7rem 0.9rem;
        border-radius: 6px;
    }

    /* User dropdown: full width inside collapsed menu */
    .navbar-user {
        width: 100%;
    }
    .navbar-user-btn {
        width: 100%;
        justify-content: space-between;
    }
    .navbar-user-menu {
        position: static;
        width: 100%;
        margin-top: 4px;
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }

    /* Main content padding */
    .main-content {
        padding: 1.25rem 1rem;
    }

    /* Detail header already stacks (existing rule); ensure rating block fits */
    .detail-header-meta {
        width: 100%;
        justify-content: flex-start;
    }

    /* Page header w/ action — let the button drop to a new line */
    .page-header-with-action {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header-with-action .page-header-actions {
        padding-top: 0.5rem;
    }

    /* Stats bar tighter */
    .stats-bar {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 0.5rem;
    }
    .stat-num { font-size: 1.5rem; }
    .stat-card { padding: 0.75rem; }
}

/* ============================================================ */
/* PHONE (<= 640px)                                               */
/* ============================================================ */
@media (max-width: 640px) {

    /* --- Risk register table: convert rows to cards --- */
    /* Hide table header */
    .risk-table thead {
        display: none;
    }
    .risk-table,
    .risk-table tbody,
    .risk-table tr,
    .risk-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    .risk-table tbody tr {
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 0.6rem;
        padding: 0.6rem 0.8rem;
        background: #fff;
    }
    .risk-table tbody tr[data-href]:hover {
        background: #f8fafc;
    }
    .risk-table td {
        padding: 0.25rem 0;
        border-top: 0;
        text-align: left;
    }
    /* Column-specific cell layout */
    .risk-table td.col-code {
        width: auto;
        margin-bottom: 0.35rem;
    }
    .risk-table td.col-cat {
        width: auto;
        white-space: normal;
    }
    .risk-table td.col-issue {
        font-weight: 500;
        color: #1e293b;
        min-width: 0;
        padding: 0.35rem 0;
    }
    .risk-table td.col-num,
    .risk-table td.col-status,
    .risk-table td.col-owner {
        width: auto;
        text-align: left;
    }
    /* Inline label/value layout via data-label="..." (added in templates) */
    .risk-table td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #64748b;
        font-size: 0.8rem;
        margin-right: 0.4rem;
    }
    /* Code + Issue cells don't need labels — they're the headline */
    .risk-table td.col-code[data-label]::before,
    .risk-table td.col-issue[data-label]::before {
        content: none;
    }
    .risk-table-wrap {
        border: 0;
        background: transparent;
        overflow: visible;
    }

    /* --- Filter bar: stack vertically, wider inputs --- */
    .filter-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }
    .filter-group {
        min-width: 0;
        width: 100%;
    }
    .filter-search {
        flex: 1 1 auto;
    }
    .filter-actions {
        flex-direction: row;
        justify-content: flex-start;
    }

    /* --- Stats bar: 2-up --- */
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    /* --- Form inline rows stack --- */
    .form-row-inline {
        flex-direction: column;
        gap: 0.75rem;
    }
    .form-field-small select {
        width: 100%;
    }
    .form-helper {
        padding-top: 0;
    }

    /* --- Dashboard barlist: wider label column on small screens --- */
    .dashboard-barlist-link {
        grid-template-columns: 100px 1fr 36px;
        gap: 0.4rem;
    }
    .dashboard-table-issue {
        max-width: 200px;
    }

    /* --- Pager: tighter spacing, smaller buttons --- */
    .pager-btn {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 13px;
    }
    .pager-keyboard-hint {
        display: none;  /* no keyboard on mobile */
    }

    /* --- Page header --- */
    .page-header h1,
    .dashboard-header h1 {
        font-size: 1.3rem;
    }

    /* --- Detail page: rating block goes full row --- */
    .detail-header-meta {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .rating-block {
        min-width: 70px;
        padding: 0.4rem 0.75rem;
    }
    .rating-block .rating-num {
        font-size: 1.5rem;
    }

    /* --- Card padding --- */
    .card {
        padding: 1.25rem;
    }
    .form-section {
        padding: 1rem 1.1rem;
    }

    /* --- Assessment edge tab: smaller on phone --- */
    .assessment-edge-tab {
        padding: 0.6rem 0.3rem;
    }
    .assessment-edge-tab .edge-tab-label {
        font-size: 0.65rem;
    }

    /* --- Dashboard table issue column: ellipsis works in narrow viewport --- */
    .dashboard-table thead th,
    .dashboard-table tbody td {
        padding: 0.4rem 0.45rem;
        font-size: 0.8rem;
    }
}

/* ============================================================ */
/* SMALL PHONE (<= 480px)                                         */
/* ============================================================ */
@media (max-width: 480px) {

    .main-content {
        padding: 1rem 0.75rem;
    }

    /* Hide app name to save room — logo + version-less */
    .navbar {
        padding: 0.5rem 0.75rem;
    }
    .navbar-app-name {
        font-size: 16px;
    }

    /* Single-column stats */
    .stats-bar {
        grid-template-columns: 1fr;
    }

    /* Risk table cards more compact */
    .risk-table tbody tr {
        padding: 0.5rem 0.65rem;
    }

    /* Filter chips wrap cleanly */
    .active-filters {
        gap: 0.35rem;
    }

    /* Buttons in form-actions stack */
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .form-actions .btn {
        width: 100%;
        text-align: center;
    }

    /* Breadcrumbs stay compact */
    .breadcrumbs a {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.8rem !important;
    }

    /* Heatmap stays readable */
    .heatmap-grid { font-size: 0.62rem; }
    .heatmap-descriptor { width: 70px; font-size: 0.6rem; }
}

/* ============================================================ */
/* Touch-friendly form inputs everywhere (prevent iOS zoom)       */
/* ============================================================ */
@media (max-width: 900px) {
    .form-row input[type="text"],
    .form-row input[type="search"],
    .form-row input[type="email"],
    .form-row input[type="date"],
    .form-row select,
    .form-row textarea,
    .filter-group select,
    .filter-group input[type="search"],
    .form-field-small select,
    #f-l, #f-i {
        font-size: 16px;  /* iOS Safari does not auto-zoom on >= 16px */
    }
}
/* ============================================================ */
/* Phase 4.1 — Mobile fixes for dashboard overflow
   Append after the Phase 4 mobile block.
   Addresses: dashboard tables, barlist, recent activity, hero
   stats — all bleeding off-screen on phones because their
   grid widths assume desktop viewport.
   ============================================================ */

@media (max-width: 640px) {

    /* --- Prevent any element from forcing horizontal scroll --- */
    html, body {
        overflow-x: hidden;
    }

    /* --- Dashboard section padding: tighter on phone --- */
    .dashboard-section {
        padding: 0.85rem 0.9rem;
        grid-column: span 12;
    }
    .dashboard-grid {
        gap: 0.6rem;
    }

    /* --- Hero stats: single column on small phones (already at 520px,
           but keep here for clarity) --- */
    .dashboard-hero {
        gap: 0.6rem;
    }
    .dashboard-stat {
        padding: 0.75rem 0.9rem;
    }
    .dashboard-stat-value {
        font-size: 1.6rem;
    }

    /* --- Barlist (Risks by Status / by Category): tighter grid --- */
    .dashboard-barlist-link {
        grid-template-columns: minmax(0, 1fr) 60px;
        grid-template-rows: auto auto;
        gap: 0.25rem 0.5rem;
        padding: 0.5rem 0.4rem;
    }
    .dashboard-barlist-link > :first-child {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        font-size: 0.85rem;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .dashboard-barlist-bar-wrap {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
        width: 100%;
    }
    .dashboard-barlist-count {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        text-align: right;
    }

    /* --- Dashboard tables (Top-rated risks, Oldest open, etc.):
           wrap in horizontal scroll so they don't overflow page --- */
    .dashboard-section .dashboard-table {
        font-size: 0.8rem;
        min-width: 100%;
    }
    /* Hide low-priority columns on phone; keep code/issue + rating */
    .dashboard-table .col-hide-mobile,
    .dashboard-table th.col-hide-mobile,
    .dashboard-table td.col-hide-mobile {
        display: none;
    }
    /* Issue column: allow wrapping so it doesn't overflow */
    .dashboard-table-issue {
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.3;
        font-size: 0.8rem;
    }
    .dashboard-table thead th,
    .dashboard-table tbody td {
        padding: 0.4rem 0.4rem;
    }
    /* Make category column compact */
    .dashboard-table .cat-chip {
        font-size: 0.7rem;
        padding: 1px 6px;
    }

    /* --- Recent activity list: tighter row layout --- */
    .dashboard-list li {
        grid-template-columns: auto 1fr;
        column-gap: 0.5rem;
        padding: 0.45rem 0.5rem;
    }
    .dashboard-list-issue {
        font-size: 0.82rem;
    }
    .dashboard-list-meta {
        font-size: 0.7rem;
        flex-wrap: wrap;
    }

    /* --- Dashboard section header (title + Active/All toggle):
           let toggle wrap below title on phone --- */
    .dashboard-section-header {
        gap: 0.5rem;
    }
    .dashboard-toggle-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    /* --- Heatmap meta line wraps cleanly --- */
    .dashboard-heatmap-meta {
        flex-wrap: wrap;
        gap: 0.25rem;
        font-size: 0.78rem;
    }

    /* --- Heatmap grid: smaller cells on phone --- */
    .dashboard-heatmap-grid {
        font-size: 0.7rem;
    }
    .dashboard-heatmap-grid th,
    .dashboard-heatmap-grid td {
        padding: 0;
    }
    .dashboard-heatmap-grid .heatmap-axis-y,
    .dashboard-heatmap-grid .heatmap-descriptor,
    .dashboard-heatmap-grid .heatmap-score-label,
    .dashboard-heatmap-grid .heatmap-x-scores th,
    .dashboard-heatmap-grid .heatmap-x-labels th,
    .dashboard-heatmap-grid .heatmap-x-axis-title th {
        padding: 0.25rem;
        font-size: 0.62rem;
    }
    .dashboard-heatmap-grid .heatmap-descriptor {
        width: auto;
        padding-left: 0.3rem;
        white-space: normal;
    }
    .dashboard-heatmap-cell {
        height: 46px;
    }
    .dashboard-heatmap-cell .cell-count {
        font-size: 0.95rem;
    }
    .dashboard-heatmap-cell .cell-rating {
        display: none; /* save vertical room — colour conveys rating */
    }
}

/* ============================================================ */
/* Safety net: wrap dashboard tables in scroll containers if they
   somehow still overflow. Works at all sizes.
   ============================================================ */
.dashboard-section .dashboard-table-wrap,
.dashboard-section .dashboard-list,
.dashboard-section .dashboard-barlist {
    max-width: 100%;
    overflow-x: hidden;
}

/* Edge tab on phone: tuck it tighter so it doesn't overlap content */
@media (max-width: 640px) {
    .assessment-edge-tab {
        font-size: 0.65rem;
        padding: 0.55rem 0.3rem;
    }
    .assessment-edge-tab .edge-tab-icon {
        width: 16px;
        height: 16px;
        font-size: 0.7rem;
    }
}
/* ============================================================ */
/* Phase 4.2 — Extend mobile rules up to tablet/fold range
   The Phase 4 rules used 640px for table-card transform and
   col-hide-mobile. That left a gap from 641px to 900px where
   navbar collapsed but tables still overflowed (iPad portrait,
   fold unfolded). This block re-applies the same rules at 900px.
   ============================================================ */

@media (max-width: 900px) {

    /* --- Risk register table: convert to cards --- */
    .risk-table thead {
        display: none;
    }
    .risk-table,
    .risk-table tbody,
    .risk-table tr,
    .risk-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    .risk-table tbody tr {
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 0.6rem;
        padding: 0.6rem 0.8rem;
        background: #fff;
    }
    .risk-table tbody tr[data-href]:hover {
        background: #f8fafc;
    }
    .risk-table td {
        padding: 0.25rem 0;
        border-top: 0;
        text-align: left;
    }
    .risk-table td.col-code {
        width: auto;
        margin-bottom: 0.35rem;
    }
    .risk-table td.col-cat {
        width: auto;
        white-space: normal;
    }
    .risk-table td.col-issue {
        font-weight: 500;
        color: #1e293b;
        min-width: 0;
        padding: 0.35rem 0;
    }
    .risk-table td.col-num,
    .risk-table td.col-status,
    .risk-table td.col-owner {
        width: auto;
        text-align: left;
    }
    .risk-table td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #64748b;
        font-size: 0.8rem;
        margin-right: 0.4rem;
    }
    .risk-table td.col-code[data-label]::before,
    .risk-table td.col-issue[data-label]::before {
        content: none;
    }
    .risk-table-wrap {
        border: 0;
        background: transparent;
        overflow: visible;
    }

    /* --- Dashboard tables: hide low-priority columns --- */
    .dashboard-table .col-hide-mobile,
    .dashboard-table th.col-hide-mobile,
    .dashboard-table td.col-hide-mobile {
        display: none;
    }
    .dashboard-table-issue {
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.3;
        font-size: 0.85rem;
    }
    .dashboard-table thead th,
    .dashboard-table tbody td {
        padding: 0.5rem 0.5rem;
    }

    /* --- Dashboard barlist: stacked label/bar/count --- */
    .dashboard-barlist-link {
        grid-template-columns: minmax(0, 1fr) 60px;
        grid-template-rows: auto auto;
        gap: 0.25rem 0.5rem;
        padding: 0.5rem 0.4rem;
    }
    .dashboard-barlist-link > :first-child {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        font-size: 0.85rem;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .dashboard-barlist-bar-wrap {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
        width: 100%;
    }
    .dashboard-barlist-count {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        text-align: right;
    }

    /* --- Recent activity list --- */
    .dashboard-list-issue {
        font-size: 0.85rem;
        white-space: normal;
    }
    .dashboard-list-meta {
        font-size: 0.72rem;
        flex-wrap: wrap;
    }

    /* --- Filter form stack --- */
    .filter-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }
    .filter-group {
        min-width: 0;
        width: 100%;
    }

    /* --- Prevent any rogue overflow --- */
    html, body {
        overflow-x: hidden;
    }
    .main-content {
        max-width: 100%;
        overflow-x: hidden;
    }
}
/* ============================================================ */
/* Phase 4.3 — Mobile card layout for admin .data-table
   Targets .data-table-cards (an opt-in class added to specific
   admin tables) so we don't break tables that wouldn't card well.
   Also stacks the Active/Show-all filter buttons on mobile.
   ============================================================ */

@media (max-width: 900px) {

    /* --- .filter-form buttons (admin pages): wrap onto separate lines --- */
    .filter-form {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .filter-form .btn {
        flex: 0 1 auto;
    }

    /* --- .data-table card-transform (opt-in via .data-table-cards) --- */
    .data-table-cards thead {
        display: none;
    }
    .data-table-cards,
    .data-table-cards tbody,
    .data-table-cards tr,
    .data-table-cards td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    .data-table-cards tbody tr {
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 0.6rem;
        padding: 0.75rem 0.9rem;
        background: #fff;
    }
    .data-table-cards tbody tr.row-inactive {
        opacity: 0.55;
    }
    .data-table-cards td {
        padding: 0.3rem 0;
        border-bottom: 0;
        text-align: left !important;
        font-size: 0.88rem;
        white-space: normal;
        width: auto !important;
    }
    /* Inline label/value via data-label attr — skipped if data-label="" */
    .data-table-cards td[data-label]:not([data-label=""])::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #64748b;
        font-size: 0.8rem;
        margin-right: 0.4rem;
        display: inline-block;
    }
    /* Name cell becomes the card headline (no label, bigger text) */
    .data-table-cards td.td-name {
        font-size: 1.05rem;
        margin-bottom: 0.35rem;
        padding-bottom: 0.4rem;
        border-bottom: 1px solid #f1f5f9;
    }
    /* Color swatch sits inline with the name */
    .data-table-cards td.td-swatch {
        display: inline-block !important;
        width: auto !important;
        padding-right: 0.4rem;
        vertical-align: middle;
    }
    .data-table-cards td.td-swatch + td.td-name {
        display: inline-block !important;
        width: auto !important;
    }
    /* Order field gets demoted to small muted text */
    .data-table-cards td.td-meta {
        font-size: 0.78rem;
        color: #94a3b8;
    }
    /* Actions row sits at bottom, flex with wrap */
    .data-table-cards td.td-actions {
        padding-top: 0.6rem;
        margin-top: 0.4rem;
        border-top: 1px solid #f1f5f9;
    }
    .data-table-cards .actions-cell {
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    .data-table-cards .actions-cell .btn {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center;
    }
}
