/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue-50:  #E6F1FB;
    --blue-100: #B5D4F4;
    --blue-400: #378ADD;
    --blue-600: #185FA5;
    --blue-800: #0C447C;
    --blue-900: #042C53;

    --gray-50:  #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-400: #94A3B8;
    --gray-600: #475569;
    --gray-800: #1E293B;

    --red-100:  #FEE2E2;
    --red-600:  #DC2626;
    --amber-100:#FEF3C7;
    --amber-600:#D97706;
    --green-100:#D1FAE5;
    --green-600:#059669;

    --sidebar-w: 240px;
    --sidebar-collapsed-w: 56px;
    --topbar-h: 48px;
    --sidebar-transition: 220ms ease;
    --radius:    8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow:    0 4px 12px rgba(0,0,0,.1);
}

body {
    font-family: 'Sarabun', 'Segoe UI', sans-serif;
    font-size: 15px;
    color: var(--gray-800);
    background: var(--gray-100);
    line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════════ */
/* ── Layout                                                        ── */
/* ═══════════════════════════════════════════════════════════════════ */
.grc-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--blue-900);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow: hidden;                   /* ซ่อน overflow ที่ sidebar ตัวเอง */
    transition: width var(--sidebar-transition);
}

/* Brand ─────────────────────────────────────────────────────────── */
.sidebar-brand {
    display: flex; align-items: center;
    gap: 10px; padding: 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.brand-logo {
    width: 34px; height: 34px; background: var(--blue-600);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 17px;
    flex-shrink: 0; cursor: pointer;
}
.brand-text  { overflow: hidden; flex: 1; min-width: 0; }
.brand-name  { display: block; color: #fff; font-weight: 600; font-size: 14px; line-height: 1.2;
               white-space: nowrap; }
.brand-tagline { display: block; color: rgba(255,255,255,.35); font-size: 10px; white-space: nowrap; }

/* Workspace strip ───────────────────────────────────────────────── */
.sidebar-workspace {
    display: flex; align-items: center; gap: 7px;
    padding: 7px 14px;
    background: rgba(255,255,255,.04);
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0; min-width: 0;
}
.sidebar-workspace-icon { color: rgba(255,255,255,.35); line-height: 0; flex-shrink: 0; }
.sidebar-workspace-name {
    color: rgba(255,255,255,.5); font-size: 11px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1; min-width: 0;
}

/* Search ────────────────────────────────────────────────────────── */
.sidebar-search {
    display: flex; align-items: center; gap: 7px;
    margin: 8px 10px;
    padding: 6px 10px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 7px;
    flex-shrink: 0;
}
.sidebar-search-icon  { color: rgba(255,255,255,.3); line-height: 0; flex-shrink: 0; }
.sidebar-search-input {
    flex: 1; background: none; border: none; outline: none;
    color: rgba(255,255,255,.8); font-size: 13px;
    font-family: 'Sarabun', 'Segoe UI', sans-serif;
    min-width: 0;
}
.sidebar-search-input::placeholder { color: rgba(255,255,255,.25); }
.sidebar-search-kbd {
    font-size: 10px; color: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 4px; padding: 1px 5px; flex-shrink: 0;
}
.sidebar-search-clear {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.3); font-size: 16px; line-height: 1; padding: 0 2px;
}
.sidebar-search-clear:hover { color: rgba(255,255,255,.7); }
.sidebar-no-result {
    padding: 12px 16px; color: rgba(255,255,255,.3); font-size: 13px; font-style: italic;
}

/* Nav — scrollable ──────────────────────────────────────────────── */
/* flex: 1 1 0 + min-height: 0 บังคับให้ nav ไม่เกินความสูง sidebar */
.sidebar-nav {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 0;
    /* custom scrollbar ให้ดูดีบน sidebar มืด */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.12) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12); border-radius: 2px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.25); }

/* Nav sections ──────────────────────────────────────────────────── */
.nav-section {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px 3px;
    color: rgba(255,255,255,.3);
    font-size: 10px; font-weight: 600; letter-spacing: .07em;
    text-transform: uppercase; cursor: pointer; user-select: none;
    transition: color .15s;
}
.nav-section:hover { color: rgba(255,255,255,.5); }
.nav-section-chevron { transition: transform .2s ease; opacity: .5; }
.nav-section.collapsed .nav-section-chevron { transform: rotate(-90deg); }

/* Nav items ─────────────────────────────────────────────────────── */
.nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 14px 8px 14px;
    color: rgba(255,255,255,.6);
    text-decoration: none; font-size: 13.5px;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}
.nav-item:hover  { background: rgba(255,255,255,.05); color: rgba(255,255,255,.9); }
.nav-item.active { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--blue-400); }
.nav-icon {
    width: 16px; height: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    line-height: 0; opacity: .75;
}
.nav-item.active .nav-icon,
.nav-item:hover  .nav-icon { opacity: 1; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Nav badge ─────────────────────────────────────────────────────── */
.nav-badge {
    margin-left: auto; flex-shrink: 0;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--blue-600); color: #fff;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    animation: badge-pop .25s ease;
}
.nav-badge.danger  { background: var(--red-600); }
.nav-badge.warning { background: #B45309; }
@keyframes badge-pop {
    0%   { transform: scale(0.6); opacity: 0; }
    70%  { transform: scale(1.15); }
    100% { transform: scale(1);   opacity: 1; }
}

/* Sidebar footer ────────────────────────────────────────────────── */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.08);
    padding: 8px 10px 10px;
    display: flex; flex-direction: column; gap: 5px;
    flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sidebar-user-avatar {
    width: 28px; height: 28px; flex-shrink: 0;
    background: var(--blue-600); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 12px; text-transform: uppercase;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    color: #fff; font-size: 12px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { color: rgba(255,255,255,.35); font-size: 11px; }
.sidebar-user-actions { display: flex; gap: 2px; flex-shrink: 0; }
.sidebar-icon-btn {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.3); padding: 5px;
    border-radius: 6px; line-height: 0;
    transition: color .15s, background .15s;
}
.sidebar-icon-btn:hover { color: rgba(255,255,255,.8); background: rgba(255,255,255,.08); }
.sidebar-version { color: rgba(255,255,255,.2); font-size: 10px; padding: 0 2px; letter-spacing: .02em; }

/* Collapsed mode ────────────────────────────────────────────────── */
.grc-collapsed .sidebar              { width: var(--sidebar-collapsed-w); }
.grc-collapsed .brand-text,
.grc-collapsed .sidebar-workspace,
.grc-collapsed .sidebar-search,
.grc-collapsed .nav-section,
.grc-collapsed .nav-label,
.grc-collapsed .nav-badge,
.grc-collapsed .sidebar-user-info,
.grc-collapsed .sidebar-user-actions,
.grc-collapsed .sidebar-version      { display: none; }
.grc-collapsed .sidebar-brand        { justify-content: center; padding: 14px 10px; }
.grc-collapsed .brand-logo           { margin: 0; }
.grc-collapsed .sidebar-user         { justify-content: center; padding: 4px 0; }
.grc-collapsed .sidebar-user-avatar  { margin: 0; }
.grc-collapsed .nav-item             { justify-content: center; padding: 10px 0; }
.grc-collapsed .nav-icon             { width: auto; }
.grc-collapsed .main-content         { margin-left: var(--sidebar-collapsed-w); }

/* Transitions ───────────────────────────────────────────────────── */
.brand-text, .sidebar-workspace, .sidebar-search,
.nav-label, .nav-badge, .sidebar-user-info,
.sidebar-user-actions, .sidebar-version {
    transition: opacity var(--sidebar-transition);
}
.main-content { transition: margin-left var(--sidebar-transition); }

/* ── Main content ────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1; min-height: 100vh;
    background: var(--gray-100);
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.grc-topbar {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 8px;
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    position: sticky; top: 0; z-index: 50;
}
/* Collapse toggle — desktop always visible */
.grc-topbar-collapse {
    background: none; border: none; cursor: pointer;
    color: var(--gray-400); padding: 6px;
    border-radius: 6px; line-height: 0;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.grc-topbar-collapse:hover { color: var(--gray-700); background: var(--gray-100); }
/* Mobile hamburger — hidden on desktop */
.grc-topbar-hamburger {
    display: none;
    background: none; border: none; cursor: pointer;
    color: var(--gray-600); padding: 6px; border-radius: 6px; line-height: 0;
}
.grc-topbar-tenant {
    flex: 1; font-size: 13.5px; color: var(--gray-600); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grc-topbar-actions { display: flex; align-items: center; gap: 2px; }
.grc-topbar-btn {
    position: relative; background: none; border: none; cursor: pointer;
    color: var(--gray-400); padding: 7px;
    border-radius: 7px; line-height: 0;
    transition: color .15s, background .15s;
}
.grc-topbar-btn:hover { color: var(--gray-700); background: var(--gray-100); }
.grc-topbar-dot {
    position: absolute; top: 6px; right: 6px;
    width: 7px; height: 7px;
    background: var(--red-600); border-radius: 50%;
    border: 1.5px solid #fff;
}

/* Content wrap ──────────────────────────────────────────────────── */
.content-wrap { padding: 24px 28px; }

/* Mobile ────────────────────────────────────────────────────────── */
.grc-mobile-overlay {
    position: fixed; inset: 0; z-index: 99;
    background: rgba(15,23,42,.4);
}
@media (max-width: 768px) {
    .grc-topbar-hamburger { display: flex; }
    .grc-topbar-collapse  { display: none; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--sidebar-transition), width var(--sidebar-transition);
    }
    .grc-mobile-open .sidebar { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
}

/* ═══════════════════════════════════════════════════════════════════ */
/* ── Page header                                                   ── */
/* ═══════════════════════════════════════════════════════════════════ */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; color: var(--gray-800); }
.page-header p  { color: var(--gray-600); font-size: 14px; margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
    padding: 20px 24px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title  { font-size: 16px; font-weight: 600; color: var(--gray-800); }

/* ── KPI Grid ────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
    background: #fff; border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200); padding: 20px; box-shadow: var(--shadow-sm);
}
.kpi-label  { font-size: 12px; color: var(--gray-600); font-weight: 500; margin-bottom: 6px; }
.kpi-value  { font-size: 28px; font-weight: 700; color: var(--gray-800); line-height: 1; }
.kpi-sub    { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.kpi-card.danger  { border-left: 4px solid var(--red-600); }
.kpi-card.warning { border-left: 4px solid var(--amber-600); }
.kpi-card.success { border-left: 4px solid var(--green-600); }
.kpi-card.info    { border-left: 4px solid var(--blue-600); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--radius);
    border: none; cursor: pointer;
    font-family: inherit; font-size: 14px; font-weight: 500;
    text-decoration: none; transition: opacity .15s, box-shadow .15s;
}
.btn:hover       { opacity: .88; }
.btn-primary     { background: var(--blue-600); color: #fff; }
.btn-secondary   { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-danger      { background: var(--red-600);  color: #fff; }
.btn-sm          { padding: 6px 12px; font-size: 13px; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 5px; }
.form-control {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    font-family: inherit; font-size: 14px; color: var(--gray-800);
    background: #fff; transition: border-color .15s, box-shadow .15s; outline: none;
}
.form-control:focus { border-color: var(--blue-400); box-shadow: 0 0 0 3px var(--blue-50); }
.form-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ── Alert / Badge ───────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-danger  { background: var(--red-100);   color: #7f1d1d; }
.alert-success { background: var(--green-100); color: #065f46; }
.alert-warning { background: var(--amber-100); color: #78350f; }
.alert-info    { background: var(--blue-50);   color: var(--blue-800); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-danger  { background: var(--red-100);   color: #991b1b; }
.badge-warning { background: var(--amber-100); color: #92400e; }
.badge-success { background: var(--green-100); color: #065f46; }
.badge-info    { background: var(--blue-50);   color: var(--blue-800); }
.badge-gray    { background: var(--gray-100);  color: var(--gray-600); }

/* ── Table ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* P4.6 — sticky first column. Opt in by adding .stickcol to a <table> inside a horizontal-scroll container (.table-wrap / *-wrap). Override header tint with --stickcol-head-bg. */
.stickcol thead th:first-child,
.stickcol tbody td:first-child { position: sticky; left: 0; background: var(--stickcol-body-bg, #fff); }
.stickcol tbody td:first-child { z-index: 1; box-shadow: 1px 0 0 var(--gray-200); }
.stickcol thead th:first-child { z-index: 3; background: var(--stickcol-head-bg, var(--gray-100)); box-shadow: 1px 0 0 var(--gray-200); }

/* ── P4.8 Accessibility: visible keyboard focus ── */
:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.form-control:focus-visible { outline: none; }  /* keeps its own border+glow ring */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    padding: 10px 14px; text-align: left;
    font-size: 12px; font-weight: 600; color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200); background: var(--gray-50);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-800); }
tbody tr:hover { background: var(--gray-50); }

/* ── Auth pages ──────────────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-800) 100%); padding: 20px;
}
.auth-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 40px; width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-icon {
    width: 52px; height: 52px; background: var(--blue-600); border-radius: var(--radius-lg);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 24px; font-weight: 700; margin-bottom: 10px;
}
.auth-logo h1 { font-size: 20px; font-weight: 700; color: var(--gray-800); }
.auth-logo p  { font-size: 13px; color: var(--gray-400); }

/* ── Loading spinner ─────────────────────────────────────────────── */
.spinner {
    display: inline-block; width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
    border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ─────────────────────────────────────────────────────── */
.text-muted  { color: var(--gray-400); }
.text-danger { color: var(--red-600);  }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }   .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }  .mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.d-flex { display: flex; } .align-center { align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.flex-1 { flex: 1; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── Filter bar ──────────────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-count { font-size: 13px; color: var(--gray-400); margin-left: auto; }

/* ── Code badge ─────────────────────────────────────────────── */
.code-badge {
    display: inline-block; padding: 2px 8px;
    background: var(--blue-50); color: var(--blue-800);
    border-radius: 4px; font-size: 12px; font-weight: 600;
    font-family: monospace; white-space: nowrap;
}
.code-badge.code-green  { background: var(--green-100); color: #065f46; }
.code-badge.code-purple { background: #EEEDFE; color: #3C3489; }

/* ── Category & Level badges ─────────────────────────────────── */
.cat-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; background: var(--gray-100); color: var(--gray-600); }
.cat-operational  { background: #E6F1FB; color: #0C447C; }
.cat-strategic    { background: #EEEDFE; color: #3C3489; }
.cat-financial    { background: #FAEEDA; color: #633806; }
.cat-compliance   { background: #D1FAE5; color: #065f46; }
.cat-technology   { background: #FAECE7; color: #712B13; }
.cat-reputational { background: #FBEAF0; color: #72243E; }
.cat-ctrl-preventive { background: #D1FAE5; color: #065f46; }
.cat-ctrl-detective  { background: #FAEEDA; color: #633806; }
.cat-ctrl-corrective { background: #FEE2E2; color: #7f1d1d; }

.level-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.level-low      { background: #D1FAE5; color: #065f46; }
.level-medium   { background: #FEF3C7; color: #92400e; }
.level-high     { background: #FEE2E2; color: #991b1b; }
.level-critical { background: #7f1d1d; color: #fff; }

/* ── Table item ─────────────────────────────────────────────── */
.item-name { font-size: 14px; font-weight: 500; color: var(--gray-800); }
.item-desc { font-size: 12px; color: var(--gray-400); margin-top: 2px;
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }

/* ── Action buttons ───────────────────────────────────────────── */
.action-btns { display: flex; align-items: center; gap: 4px; }
.btn-icon {
    width: 30px; height: 30px; background: var(--gray-100); border: 1px solid var(--gray-200);
    border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: var(--gray-600); transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--blue-50); color: var(--blue-600); }
.btn-icon-danger:hover { background: #FEE2E2; color: #dc2626; }
.btn-icon-sm { width: 24px; height: 24px; font-size: 11px; }

/* ── Loading / Empty state ──────────────────────────────────────── */
.loading-wrap { display: flex; align-items: center; gap: 10px; padding: 40px; justify-content: center; color: var(--gray-400); font-size: 14px; }
.tbl-spinner { width: 18px; height: 18px; border: 2px solid var(--gray-200); border-top-color: var(--blue-600); border-radius: 50%; animation: spin .7s linear infinite; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; gap: 12px; color: var(--gray-400); }
.empty-icon { font-size: 36px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.2); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; }
.modal-box.modal-sm { max-width: 440px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--gray-200); }
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--gray-800); }
.modal-close { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--gray-400); padding: 4px; border-radius: 4px; line-height: 1; }
.modal-close:hover { color: var(--gray-800); background: var(--gray-100); }
.modal-body { padding: 20px 24px; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Form row ────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
textarea.form-control { resize: vertical; }

/* ── Regulation tree ───────────────────────────────────────────── */
.reg-group-card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); margin-bottom: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.reg-group-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); gap: 12px; flex-wrap: wrap; }
.reg-group-info { display: flex; align-items: center; gap: 12px; flex: 1; }
.clause-count { font-size: 12px; color: var(--gray-400); white-space: nowrap; }
.clause-list { padding: 8px 0; }
.clause-row { display: flex; align-items: center; gap: 10px; padding: 8px 20px 8px 32px; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.clause-row:last-child { border-bottom: none; }
.clause-code { color: var(--blue-600); font-weight: 600; white-space: nowrap; min-width: 80px; }
.clause-name { color: var(--gray-800); font-weight: 500; }
.clause-desc { color: var(--gray-400); flex: 1; }
.clause-actions { margin-left: auto; display: flex; gap: 4px; }

/* ── Skeleton loader ──────────────────────────────────────────────── */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 600px 100%; animation: shimmer 1.4s infinite linear; border-radius: 4px; }
.skeleton-row { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid #f8fafc; }
.skeleton-row:last-child { border-bottom: none; }

/* ── Empty state (rich) ──────────────────────────────────────────── */
.empty-rich { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 24px; gap: 16px; text-align: center; }
.empty-rich-icon { width: 80px; height: 80px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 36px; margin-bottom: 4px; }
.empty-rich-title { font-size: 18px; font-weight: 700; color: #0f172a; margin: 0; }
.empty-rich-desc  { font-size: 14px; color: #64748b; max-width: 380px; line-height: 1.6; margin: 0; }
.empty-rich-actions { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; justify-content: center; }
.empty-rich-hint { font-size: 12px; color: #94a3b8; border: 1px dashed #e2e8f0; border-radius: 8px; padding: 10px 16px; margin-top: 4px; }

/* ── Change password modal ───────────────────────────────────────── */
.grc-modal-backdrop { position: fixed; inset: 0; z-index: 9000; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.grc-modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; overflow: hidden; }
.grc-modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--gray-100); }
.grc-modal-title { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.grc-modal-sub   { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.grc-modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--gray-300); line-height: 1; padding: 0 4px; border-radius: 4px; }
.grc-modal-close:hover { color: var(--gray-700); }
.grc-modal-alert { margin: 12px 24px 0; padding: 9px 12px; border-radius: 7px; font-size: 13px; }
.grc-modal-alert.danger  { background: var(--red-100);   color: #991b1b; border: 1px solid #fecaca; }
.grc-modal-alert.success { background: var(--green-100); color: #065f46; border: 1px solid #a7f3d0; }
.grc-modal-body   { padding: 16px 24px 4px; }
.grc-modal-hint   { font-size: 12px; margin-top: 4px; }
.grc-modal-hint.danger { color: var(--red-600); }
.grc-modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 20px; border-top: 1px solid var(--gray-100); }
