/* ============================================================
   ISO 27001 Compliance Tracker - Dark Theme Stylesheet
   Matches adamhomenet.com / CIS dashboard style
   ============================================================ */

/* ----------------------------------------------------------
   Custom Properties (Theming)
   ---------------------------------------------------------- */
:root {
    /* Base palette */
    --bg-primary:       #0a0a0f;
    --bg-secondary:     #12121a;
    --bg-card:          #1a1a2e;
    --bg-input:         #0f0f1a;
    --bg-hover:         #222240;
    --bg-nav:           #0e0e18;

    /* Text */
    --text-primary:     #e0e0e0;
    --text-secondary:   #9ca3af;
    --text-muted:       #6b7280;
    --text-heading:     #f0f0f0;

    /* Accent */
    --accent:           #60a5fa;
    --accent-hover:     #93c5fd;
    --accent-dim:       rgba(96, 165, 250, 0.15);

    /* Status colors */
    --color-success:    #34d399;
    --color-warning:    #fbbf24;
    --color-danger:     #f87171;
    --color-info:       #60a5fa;
    --color-muted:      #6b7280;

    /* Status badge backgrounds */
    --bg-success:       rgba(52, 211, 153, 0.15);
    --bg-warning:       rgba(251, 191, 36, 0.15);
    --bg-danger:        rgba(248, 113, 113, 0.15);
    --bg-info:          rgba(96, 165, 250, 0.15);
    --bg-muted:         rgba(107, 114, 128, 0.15);

    /* Borders */
    --border-color:     #2a2a3e;
    --border-light:     #333350;

    /* Sizing */
    --nav-height:       56px;
    --container-max:    1280px;
    --radius:           6px;
    --radius-sm:        4px;
    --radius-lg:        10px;

    /* Shadows */
    --shadow-sm:        0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md:        0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg:        0 8px 24px rgba(0, 0, 0, 0.6);

    /* Transitions */
    --transition:       0.2s ease;
}


/* ----------------------------------------------------------
   Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5em;
}
h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

img { max-width: 100%; }
hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}


/* ----------------------------------------------------------
   Container
   ---------------------------------------------------------- */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1.25rem;
    width: 100%;
}

main.container {
    flex: 1;
    padding-top: 1.5rem;
    padding-bottom: 3rem;
}


/* ----------------------------------------------------------
   Navigation Bar
   ---------------------------------------------------------- */
.main-nav {
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border-color);
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.nav-inner {
    display: flex;
    align-items: center;
    height: var(--nav-height);
    gap: 1rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-heading);
    text-decoration: none;
    white-space: nowrap;
}
.nav-brand:hover { color: var(--accent); text-decoration: none; }
.brand-icon { font-size: 1.3rem; }

.nav-links {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.nav-links a {
    display: block;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}
.nav-links a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-links a.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    white-space: nowrap;
}
.nav-username { color: var(--text-secondary); }
.nav-profile-link {
    color: var(--text-muted);
    font-size: 1.1rem;
    text-decoration: none;
}
.nav-profile-link:hover { color: var(--accent); text-decoration: none; }
.nav-logout {
    color: var(--text-muted);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    text-decoration: none;
}
.nav-logout:hover {
    color: var(--color-danger);
    background: var(--bg-danger);
    text-decoration: none;
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}
.hamburger,
.hamburger::before,
.hamburger::after {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    position: relative;
    transition: var(--transition);
}
.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    left: 0;
}
.hamburger::before { top: -7px; }
.hamburger::after  { top: 7px; }


/* ----------------------------------------------------------
   Cards
   ---------------------------------------------------------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* Compact card variant */
.card-compact {
    padding: 0.75rem 1.25rem;
}

/* Status indicator (SMB health, etc.) */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-green .status-dot {
    background: var(--color-success);
    box-shadow: 0 0 6px var(--color-success);
}
.status-green {
    color: var(--color-success);
}
.status-red .status-dot {
    background: var(--color-danger);
    box-shadow: 0 0 6px var(--color-danger);
}
.status-red {
    color: var(--color-danger);
}

/* Cards with colored left borders */
.card-status-green  { border-left: 4px solid var(--color-success); }
.card-status-yellow { border-left: 4px solid var(--color-warning); }
.card-status-red    { border-left: 4px solid var(--color-danger); }
.card-status-blue   { border-left: 4px solid var(--color-info); }
.card-status-gray   { border-left: 4px solid var(--color-muted); }

/* Stat cards for dashboard */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Overall compliance highlight card */
.card-highlight {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 20px rgba(96, 165, 250, 0.08);
}

/* Stat row inside highlight card */
.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 80px;
}

.stat-large {
    font-size: 3rem;
    font-weight: 800;
    color: var(--color-success);
    line-height: 1.1;
}

.stat-red {
    color: var(--color-danger) !important;
}

.stat-green {
    color: var(--color-success);
}

/* Card grid layout for domain cards */
.card-grid {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.card-grid-4 {
    grid-template-columns: repeat(2, 1fr);
}

/* Domain cards */
.card-domain {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem;
}

.card-domain h3 {
    margin-bottom: 0.25rem;
    font-size: 1.05rem;
}

.domain-code {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.domain-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 1rem;
}


/* ----------------------------------------------------------
   Status Badges
   ---------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 999px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.4;
}

.badge-not_started,
.badge-default    { background: var(--bg-muted);   color: var(--color-muted); }
.badge-in_progress,
.badge-warning    { background: var(--bg-warning);  color: var(--color-warning); }
.badge-implemented,
.badge-success    { background: var(--bg-success);  color: var(--color-success); }
.badge-not_applicable,
.badge-info       { background: var(--bg-info);     color: var(--color-info); }
.badge-danger     { background: var(--bg-danger);   color: var(--color-danger); }

/* NCR severity */
.badge-minor     { background: var(--bg-warning);  color: var(--color-warning); }
.badge-major     { background: rgba(251, 146, 60, 0.15); color: #fb923c; }
.badge-critical  { background: var(--bg-danger);   color: var(--color-danger); }

/* Risk treatment */
.badge-accept    { background: var(--bg-muted);   color: var(--color-muted); }
.badge-mitigate  { background: var(--bg-info);    color: var(--color-info); }
.badge-transfer  { background: rgba(167, 139, 250, 0.15); color: #a78bfa; }
.badge-avoid     { background: var(--bg-danger);  color: var(--color-danger); }


/* ----------------------------------------------------------
   Tables
   ---------------------------------------------------------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--bg-secondary);
}
thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition);
}
tbody tr:hover {
    background: var(--bg-hover);
}
tbody tr:last-child {
    border-bottom: none;
}

tbody td {
    padding: 0.65rem 1rem;
    vertical-align: middle;
}

/* Sortable column headers */
th.sortable {
    cursor: pointer;
    user-select: none;
}
th.sortable::after {
    content: ' \2195';
    opacity: 0.3;
}
th.sort-asc::after  { content: ' \2191'; opacity: 1; }
th.sort-desc::after { content: ' \2193'; opacity: 1; }


/* ----------------------------------------------------------
   Forms
   ---------------------------------------------------------- */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

input[type="file"] {
    padding: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.form-inline {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    flex-wrap: wrap;
}
.form-inline .form-group {
    margin-bottom: 0;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}


/* ----------------------------------------------------------
   Buttons
   ---------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }

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

.btn-secondary {
    background: transparent;
    border-color: var(--border-light);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-danger {
    background: transparent;
    border-color: var(--color-danger);
    color: var(--color-danger);
}
.btn-danger:hover {
    background: var(--bg-danger);
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}


/* ----------------------------------------------------------
   Flash Messages
   ---------------------------------------------------------- */
.flash-container {
    margin-bottom: 1rem;
}

.flash {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    animation: flashSlideIn 0.3s ease;
}

.flash-success { background: var(--bg-success); border-left: 4px solid var(--color-success); color: var(--color-success); }
.flash-error   { background: var(--bg-danger);  border-left: 4px solid var(--color-danger);  color: var(--color-danger); }
.flash-warning { background: var(--bg-warning); border-left: 4px solid var(--color-warning); color: var(--color-warning); }
.flash-info    { background: var(--bg-info);    border-left: 4px solid var(--color-info);    color: var(--color-info); }

.flash-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.flash-text {
    flex: 1;
}
.flash-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.2rem;
    line-height: 1;
}
.flash-close:hover { opacity: 1; }

.flash.fade-out {
    animation: flashFadeOut 0.4s ease forwards;
}

@keyframes flashSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes flashFadeOut {
    from { opacity: 1; max-height: 80px; margin-bottom: 0.5rem; }
    to   { opacity: 0; max-height: 0; margin-bottom: 0; padding: 0; overflow: hidden; }
}


/* ----------------------------------------------------------
   Donut Chart (SVG-based)
   ---------------------------------------------------------- */
.donut-chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.donut-chart {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}
.donut-chart svg {
    width: 100%;
    height: 100%;
}

/* Path-based donut (server-rendered from PHP) */
.donut-chart svg.donut {
    width: 120px;
    height: 120px;
    display: block;
}
.donut-chart .donut-ring {
    stroke: var(--border-color);
    stroke-width: 3;
    fill: none;
}
.donut-chart .donut-segment {
    stroke-linecap: round;
    fill: none;
    stroke-width: 3;
}
.donut-chart .donut-text {
    fill: var(--text-heading);
    font-size: 8px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
}

/* Circle-based donut (JS-rendered) */
.donut-chart circle {
    fill: none;
    stroke-linecap: round;
}
.donut-chart .donut-bg {
    stroke: var(--border-color);
}
.donut-chart .donut-fill {
    transition: stroke-dashoffset 0.8s ease;
}
.donut-chart .donut-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-heading);
    pointer-events: none;
}

.donut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.donut-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.donut-card-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}


/* ----------------------------------------------------------
   5x5 Risk Heatmap
   ---------------------------------------------------------- */
.heatmap-grid {
    display: grid;
    grid-template-columns: auto repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr) auto;
    gap: 3px;
    max-width: 500px;
    margin: 1rem auto;
}

.heatmap-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    min-height: 60px;
    cursor: default;
    transition: transform var(--transition);
}
.heatmap-cell:hover {
    transform: scale(1.05);
}

.heatmap-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.25rem;
}
.heatmap-label-y {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
}

/* Risk score colors: 1-4 green, 5-9 yellow, 10-15 orange, 16-25 red */
.risk-1,  .risk-2,  .risk-3,  .risk-4                    { background: #166534; }
.risk-5,  .risk-6,  .risk-8,  .risk-9                    { background: #854d0e; }
.risk-10, .risk-12, .risk-15                              { background: #9a3412; }
.risk-16, .risk-20, .risk-25                              { background: #991b1b; }

/* Empty cells */
.risk-0 { background: var(--bg-secondary); color: var(--text-muted); }

/* Inline risk score badge */
.risk-score {
    display: inline-block;
    padding: 0.15em 0.5em;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    min-width: 2em;
    text-align: center;
}


/* ----------------------------------------------------------
   Login Page
   ---------------------------------------------------------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-page main.container {
    max-width: 400px;
    padding-top: 0;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-card h1 {
    margin-bottom: 0.25rem;
}
.login-card .login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}
.login-card .form-group {
    text-align: left;
}
.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 0.65rem;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}


/* ----------------------------------------------------------
   Collapsible Sections
   ---------------------------------------------------------- */
.collapsible-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
}
.collapsible-header::before {
    content: '\25B6';
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform var(--transition);
}
.collapsible-header.open::before {
    transform: rotate(90deg);
}
.collapsible-body {
    display: none;
    padding: 0.5rem 0 0.5rem 1.25rem;
}
.collapsible-body.open {
    display: block;
}


/* ----------------------------------------------------------
   Pagination
   ---------------------------------------------------------- */
.pagination {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    justify-content: center;
    margin: 1.5rem 0;
}
.pagination a,
.pagination span {
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-decoration: none;
}
.pagination a {
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.pagination a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.pagination .current {
    background: var(--accent);
    color: #0a0a0f;
    font-weight: 600;
}


/* ----------------------------------------------------------
   Filter / Search Bar
   ---------------------------------------------------------- */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.filter-bar input[type="search"] {
    max-width: 300px;
}

.filter-bar select {
    max-width: 200px;
}


/* ----------------------------------------------------------
   Utility
   ---------------------------------------------------------- */
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger  { color: var(--color-danger); }
.text-info    { color: var(--color-info); }
.text-muted   { color: var(--text-muted); }

.text-right { text-align: right; }
.text-center { text-align: center; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dirty form indicator */
.form-dirty-indicator {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: var(--bg-warning);
    color: var(--color-warning);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 50;
}
.form-dirty-indicator.visible {
    display: block;
    animation: flashSlideIn 0.3s ease;
}


/* ----------------------------------------------------------
   Footer
   ---------------------------------------------------------- */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: auto;
}
.site-footer .container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.footer-sep { opacity: 0.4; }


/* ----------------------------------------------------------
   Responsive
   ---------------------------------------------------------- */
@media (max-width: 768px) {
    html { font-size: 14px; }

    .nav-toggle { display: block; }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--bg-nav);
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        padding: 0.5rem 1rem;
        box-shadow: var(--shadow-md);
    }
    .nav-links.open { display: flex; }

    .nav-divider {
        width: 100%;
        height: 1px;
        margin: 0.25rem 0;
    }

    .nav-user {
        display: none;
    }
    .nav-links.open ~ .nav-user {
        display: flex;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-grid-4 {
        grid-template-columns: 1fr;
    }

    .stat-row {
        gap: 1rem;
    }

    .stat-large {
        font-size: 2.2rem;
    }

    .donut-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-bar input[type="search"],
    .filter-bar select {
        max-width: none;
    }

    .heatmap-grid {
        max-width: 100%;
    }
    .heatmap-cell {
        min-height: 45px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
    .donut-grid {
        grid-template-columns: 1fr;
    }
}


/* ----------------------------------------------------------
   Print Styles
   ---------------------------------------------------------- */
@media print {
    :root {
        --bg-primary:    #fff;
        --bg-secondary:  #f8f8f8;
        --bg-card:       #fff;
        --text-primary:  #111;
        --text-secondary:#444;
        --text-heading:  #000;
        --border-color:  #ccc;
    }

    body {
        background: #fff;
        color: #111;
        font-size: 11pt;
    }

    .main-nav,
    .nav-toggle,
    .flash-container,
    .filter-bar,
    .btn,
    .form-dirty-indicator,
    .site-footer {
        display: none !important;
    }

    main.container {
        padding: 0;
        max-width: none;
    }

    .card {
        border: 1px solid #ccc;
        box-shadow: none;
        break-inside: avoid;
    }

    table {
        font-size: 9pt;
    }
    thead th {
        background: #eee !important;
        color: #000;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .badge {
        border: 1px solid currentColor;
    }

    a { color: #111; text-decoration: none; }
    a[href]::after {
        content: none; /* Don't print URLs in tables */
    }

    .donut-chart .donut-fill {
        stroke-width: 10;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .heatmap-cell {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    @page {
        margin: 1.5cm;
    }
}

/* ============================================================
   Detail / View Pages
   ============================================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.6rem;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.detail-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 0.75rem 1.5rem;
    margin: 0;
}

.detail-grid dt {
    color: var(--text-muted, #64748b);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-top: 0.2rem;
}

.detail-grid dd {
    margin: 0;
    color: var(--text-primary, #e2e8f0);
}

/* Two-column detail grid on wider screens */
.detail-grid-2col {
    display: grid;
    grid-template-columns: 160px 1fr 160px 1fr;
    gap: 0.75rem 1.5rem;
    margin: 0;
}

@media (max-width: 768px) {
    .detail-grid,
    .detail-grid-2col {
        grid-template-columns: 1fr;
    }
    .detail-grid dt,
    .detail-grid-2col dt {
        margin-top: 0.5rem;
        border-bottom: 1px solid var(--border-color, #1e293b);
        padding-bottom: 0.25rem;
    }
}

/* Implementation notes / guidance blocks */
.notes-block {
    background: var(--bg-darker, #0d0d14);
    border-radius: 6px;
    padding: 1rem;
    margin: 0.5rem 0;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.6;
    border-left: 3px solid var(--accent, #60a5fa);
}

/* Evidence table */
.evidence-table {
    width: 100%;
    margin-top: 0.75rem;
}

.evidence-table td {
    padding: 0.5rem 0.75rem;
}

/* Diff styling for audit history */
/* Audit log table */
.audit-table {
    width: 100%;
}

.audit-table td {
    vertical-align: top;
}

/* Audit diff expansion row */
.audit-diff-row td {
    padding: 0 !important;
    border-top: none !important;
}

.audit-diff-row details {
    padding: 0.5rem 1rem;
}

.audit-diff-row summary {
    cursor: pointer;
    color: var(--accent, #60a5fa);
    font-size: 0.85em;
    padding: 0.25rem 0;
}

.audit-diff-detail {
    display: flex;
    gap: 1.5rem;
    padding: 0.5rem 0;
    flex-wrap: wrap;
}

.audit-diff-detail .diff-section {
    flex: 1;
    min-width: 300px;
}

.audit-diff-detail pre {
    background: var(--bg-darker, #0d0d14);
    border-radius: 4px;
    padding: 0.75rem;
    font-size: 0.8em;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    margin: 0.25rem 0;
}

.diff-label.diff-old { color: #f87171; }
.diff-label.diff-new { color: #4ade80; }

/* Audit log changes column */
.audit-changes {
    overflow: hidden;
}

.audit-changes pre {
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 0.75em;
    margin: 0.25rem 0;
    padding: 0.5rem;
    background: var(--bg-darker, #0d0d14);
    border-radius: 4px;
    max-height: 120px;
    overflow-y: auto;
}

.diff-old {
    background: rgba(220, 38, 38, 0.15);
    color: #f87171;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85em;
    margin-right: 0.25rem;
    display: inline-block;
    margin-bottom: 0.25rem;
}

.diff-new {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85em;
    margin-right: 0.25rem;
    display: inline-block;
    margin-bottom: 0.25rem;
}

/* Overdue indicators */
.overdue {
    color: #ef4444;
    font-weight: 600;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}
