/*
 * NRED Meeting — Design System v4
 * Style: Minimalism & Swiss (ui-ux-pro-max) · App shell with sidebar navigation
 * UI font: Noto Sans Thai · Document font: Sarabun
 */

:root {
    /* Color tokens */
    --c-primary: #166534;
    --c-primary-hover: #14532d;
    --c-primary-soft: #e8f5ec;
    --c-primary-line: #bfe5cc;
    --c-accent: #d97706;
    --c-accent-soft: #fef3e2;
    --c-bg: #f4f6f5;
    --c-surface: #ffffff;
    --c-surface-2: #f8faf9;
    --c-fg: #0f172a;
    --c-fg-muted: #475569;
    --c-fg-subtle: #64748b;
    --c-border: #e3e8e6;
    --c-border-strong: #cbd5e1;
    --c-danger: #dc2626;
    --c-danger-soft: #fdecec;
    --c-info: #0369a1;
    --c-info-soft: #e6f2f9;
    --c-success: #15803d;
    --c-success-soft: #e7f6ec;
    --c-warning: #b45309;
    --c-warning-soft: #fdf4e3;
    --c-ring: #15803d;

    /* Sidebar */
    --sb-w: 264px;
    --sb-rail: 76px;
    --sb-bg: #0e2a1a;
    --sb-bg-2: #12341f;
    --sb-fg: #c9dcd0;
    --sb-fg-strong: #ffffff;
    --sb-muted: #7fa08b;
    --sb-active: rgba(255, 255, 255, .10);
    --sb-hover: rgba(255, 255, 255, .06);
    --sb-accent: #4ade80;

    /* Shape & elevation */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow: 0 4px 12px -2px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .05);
    --shadow-lg: 0 16px 40px -12px rgba(15, 23, 42, .25);

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Motion */
    --ease: cubic-bezier(.2, .8, .2, 1);
    --dur: 180ms;

    --topbar-h: 64px;

    /* Bootstrap bridge */
    --bs-body-font-family: 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-color: var(--c-fg);
    --bs-body-bg: var(--c-bg);
    --bs-primary: var(--c-primary);
    --bs-primary-rgb: 22, 101, 52;
    --bs-success-rgb: 21, 128, 61;
    --bs-danger-rgb: 220, 38, 38;
    --bs-link-color: var(--c-primary);
    --bs-link-color-rgb: 22, 101, 52;
    --bs-link-hover-color: var(--c-primary-hover);
    --bs-link-hover-color-rgb: 20, 83, 45;
    --bs-border-color: var(--c-border);
    --bs-border-radius: var(--radius-sm);
}

/* ======================================================================
   Base
   ====================================================================== */
html { scroll-behavior: smooth; }
body {
    font-family: var(--bs-body-font-family);
    background: var(--c-bg);
    color: var(--c-fg);
    font-size: 15.5px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { color: var(--c-fg); font-weight: 600; line-height: 1.35; letter-spacing: -0.005em; }
a { color: var(--c-primary); }
a:hover { color: var(--c-primary-hover); }
.text-muted, .text-secondary { color: var(--c-fg-muted) !important; }
.text-subtle { color: var(--c-fg-subtle) !important; }
.text-primary { color: var(--c-primary) !important; }
.bg-primary { background-color: var(--c-primary) !important; }
.min-w-0 { min-width: 0; }
.flex-none { flex: none; }
.fw-semibold { font-weight: 600 !important; }
.tabular { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 3px solid var(--c-ring); outline-offset: 2px; border-radius: 4px; }
button, [role="button"], a, label.btn, .form-check-input, .clickable-row { cursor: pointer; }

.skip-link {
    position: absolute; left: var(--space-4); top: -48px; z-index: 3000;
    background: var(--c-primary); color: #fff; padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm); text-decoration: none; transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--space-3); color: #fff; }

/* ======================================================================
   App shell
   ====================================================================== */
.app { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; }
html.rail .app { --sb-w: var(--sb-rail); }

.sidebar {
    position: sticky; top: 0; height: 100vh; z-index: 1045;
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--sb-bg-2) 0%, var(--sb-bg) 100%);
    color: var(--sb-fg); overflow: hidden;
}
.sb-brand { padding: 14px 14px 10px; }
.sb-logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--sb-fg-strong); padding: 6px; border-radius: 10px; min-width: 0; }
.sb-logo img { width: 36px; height: 36px; border-radius: 9px; background: #fff; object-fit: contain; flex: none; }
.sb-logo .sb-label { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sb-logo strong { font-size: 1rem; font-weight: 700; color: #fff; white-space: nowrap; }
.sb-logo small { font-size: .74rem; color: var(--sb-muted); white-space: nowrap; }
.sb-logo:hover { color: #fff; background: var(--sb-hover); }

.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 12px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.sb-section { font-size: .72rem; font-weight: 600; letter-spacing: .06em; color: var(--sb-muted); padding: 14px 10px 6px; text-transform: uppercase; white-space: nowrap; min-height: 38px; }
.sb-item {
    position: relative; display: flex; align-items: center; gap: 12px;
    min-height: 42px; padding: 0 12px; margin: 2px 0; border-radius: 10px;
    color: var(--sb-fg); text-decoration: none; font-size: .93rem; font-weight: 500; white-space: nowrap;
    background: transparent; border: 0; width: 100%; text-align: left;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sb-item i { font-size: 1.15rem; width: 22px; text-align: center; flex: none; }
.sb-item:hover { background: var(--sb-hover); color: #fff; }
.sb-item.active { background: var(--sb-active); color: #fff; }
.sb-item.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--sb-accent); }
.sb-item.active i { color: var(--sb-accent); }
.sb-item:focus-visible { outline-color: var(--sb-accent); }
.sb-meeting { display: flex; gap: 10px; align-items: flex-start; margin: 0 2px 6px; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); color: #fff; font-size: .86rem; line-height: 1.45; }
.sb-meeting i { color: var(--sb-accent); margin-top: 2px; }
.sb-meeting span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.sb-foot { padding: 10px 12px 14px; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 6px; }
.sb-user { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 10px; border: 0; background: transparent; color: var(--sb-fg); text-align: left; min-height: 48px; }
.sb-user:hover { background: var(--sb-hover); }
.sb-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sb-user-text strong { color: #fff; font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-text small { color: var(--sb-muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-collapse { align-items: center; gap: 12px; min-height: 38px; padding: 0 12px; border-radius: 10px; border: 0; background: transparent; color: var(--sb-muted); font-size: .85rem; }
.sb-collapse i { font-size: 1.05rem; width: 22px; text-align: center; }
.sb-collapse:hover { background: var(--sb-hover); color: #fff; }
.app-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    background: var(--sb-accent); color: #0e2a1a; font-weight: 700; font-size: .9rem;
}

/* Rail (collapsed sidebar) */
html.rail .sidebar .sb-label { display: none; }
html.rail .sb-brand { padding: 14px 10px 10px; }
html.rail .sb-logo { justify-content: center; }
html.rail .sb-nav { padding: 6px 10px; }
html.rail .sb-section { padding: 10px 0 4px; min-height: 18px; }
html.rail .sb-section::after { content: ""; display: block; height: 1px; background: rgba(255,255,255,.08); margin: 0 8px; }
html.rail .sb-item, html.rail .sb-collapse { justify-content: center; padding: 0; }
html.rail .sb-item.active::before { left: -10px; }
html.rail .sb-user { justify-content: center; padding: 6px 0; }
html.rail .sb-collapse i { transform: scaleX(-1); }

/* Rail tooltips */
html.rail .sidebar [data-tip] { position: relative; }
html.rail .sidebar [data-tip]:hover::after, html.rail .sidebar [data-tip]:focus-visible::after {
    content: attr(data-tip); position: fixed; left: calc(var(--sb-rail) + 6px);
    transform: translateY(-50%); margin-top: 21px;
    background: #0f172a; color: #fff; font-size: .8rem; padding: 5px 10px; border-radius: 6px; white-space: nowrap; pointer-events: none; z-index: 3000;
}

/* Main column + topbar */
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1030;
    height: var(--topbar-h); flex: none;
    display: flex; align-items: center; gap: var(--space-3);
    padding: 0 var(--space-6);
    background: rgba(255, 255, 255, .9); backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--c-border);
}
.topbar-title { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.crumbs { display: flex; flex-wrap: nowrap; gap: 6px; list-style: none; margin: 0; padding: 0; font-size: .78rem; color: var(--c-fg-subtle); white-space: nowrap; overflow: hidden; }
.crumbs li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumbs li + li::before { content: "\F285"; font-family: bootstrap-icons; font-size: .65rem; opacity: .6; }
.crumbs li:last-child span { overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--c-fg-subtle); text-decoration: none; }
.crumbs a:hover { color: var(--c-primary); }
.topbar-h1 { font-size: 1.12rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); flex: none; }

.page { padding: var(--space-5) var(--space-6) var(--space-7); width: 100%; max-width: 1320px; }
.page-fluid { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.sb-scrim { display: none; }

@media (max-width: 991.98px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    html.rail .app { --sb-w: 264px; }
    html.rail .sidebar .sb-label { display: revert; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; width: min(288px, 86vw);
        transform: translateX(-100%); transition: transform 240ms var(--ease); box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: none; }
    .sb-scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 1044; }
    .sb-scrim.show { display: block; }
    html.rail .sb-item, html.rail .sb-collapse { justify-content: flex-start; padding: 0 12px; }
    html.rail .sidebar [data-tip]:hover::after { display: none; }
    .topbar { padding: 0 var(--space-3); }
    .page { padding: var(--space-4) var(--space-4) var(--space-7); }
}
@media (max-width: 575.98px) {
    .topbar-actions .btn-label { display: none; }
}

/* ======================================================================
   Page building blocks
   ====================================================================== */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-4); margin-bottom: var(--space-5); }
.page-head h2 { font-size: clamp(1.3rem, 2vw, 1.6rem); margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--c-fg-muted); }
.meta-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); color: var(--c-fg-muted); font-size: .92rem; }
.meta-row i { color: var(--c-primary); margin-right: 6px; }

.section-title { display: flex; align-items: center; gap: var(--space-2); font-size: 1rem; font-weight: 600; margin: 0; }
.section-title i { color: var(--c-primary); }

/* Cards */
.card {
    --bs-card-border-color: var(--c-border);
    --bs-card-border-radius: var(--radius);
    --bs-card-cap-bg: transparent;
    background: var(--c-surface);
    box-shadow: var(--shadow-xs);
}
.card-header { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--c-border); }
.card-body { padding: var(--space-5); }
.card-title-sm { font-size: 1rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: var(--space-2); }
.card-title-sm i { color: var(--c-primary); }

/* KPI tiles */
.kpi { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); flex-direction: row; height: 100%; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.kpi-icon.green { background: var(--c-primary-soft); color: var(--c-primary); }
.kpi-icon.amber { background: var(--c-accent-soft); color: var(--c-warning); }
.kpi-icon.blue { background: var(--c-info-soft); color: var(--c-info); }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: .85rem; color: var(--c-fg-muted); }

/* Featured (latest meeting) */
.feature {
    position: relative; overflow: hidden; border-radius: var(--radius-lg);
    background: linear-gradient(120deg, #0e2a1a 0%, #166534 70%, #1f7a43 100%);
    color: #fff; padding: var(--space-5) var(--space-6);
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4) var(--space-6);
    box-shadow: var(--shadow);
}
.feature::after { content: ""; position: absolute; right: -60px; bottom: -120px; width: 320px; height: 320px; border-radius: 50%; border: 48px solid rgba(255,255,255,.05); pointer-events: none; }
.feature-body { flex: 1 1 380px; min-width: 0; position: relative; z-index: 1; }
.feature h2 { color: #fff; font-size: clamp(1.25rem, 2.2vw, 1.65rem); margin: 8px 0 10px; }
.feature .meta-row, .feature .meta-row i { color: rgba(255,255,255,.85); }
.feature-eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; background: rgba(255,255,255,.14); padding: 3px 10px; border-radius: 999px; }
.feature-progress { margin-top: var(--space-4); max-width: 420px; }
.feature-progress .progress { background: rgba(255,255,255,.18); }
.feature-progress .progress-bar { background: #4ade80; }
.feature-progress small { color: rgba(255,255,255,.8); }
.feature-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); position: relative; z-index: 1; }
.btn-on-dark { --bs-btn-bg: #fff; --bs-btn-color: var(--c-primary); --bs-btn-border-color: #fff; --bs-btn-hover-bg: #f0fdf4; --bs-btn-hover-color: var(--c-primary-hover); --bs-btn-hover-border-color: #f0fdf4; --bs-btn-active-bg: #dcfce7; font-weight: 600; }
.btn-on-dark-ghost { --bs-btn-bg: rgba(255,255,255,.1); --bs-btn-color: #fff; --bs-btn-border-color: rgba(255,255,255,.3); --bs-btn-hover-bg: rgba(255,255,255,.18); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: rgba(255,255,255,.5); --bs-btn-active-bg: rgba(255,255,255,.24); --bs-btn-active-color: #fff; }

/* ======================================================================
   Buttons
   ====================================================================== */
.btn {
    --bs-btn-font-weight: 500;
    --bs-btn-border-radius: 10px;
    --bs-btn-padding-y: .5rem;
    --bs-btn-padding-x: 1rem;
    --bs-btn-font-size: .94rem;
    min-height: 42px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    white-space: nowrap;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform 80ms var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn i { font-size: 1.05em; }
.btn-sm { min-height: 34px; --bs-btn-padding-y: .3rem; --bs-btn-padding-x: .75rem; --bs-btn-font-size: .86rem; --bs-btn-border-radius: 8px; gap: 6px; }
.btn-lg { min-height: 50px; --bs-btn-font-size: 1rem; --bs-btn-padding-x: 1.35rem; }
.btn-primary {
    --bs-btn-bg: var(--c-primary); --bs-btn-border-color: var(--c-primary);
    --bs-btn-hover-bg: var(--c-primary-hover); --bs-btn-hover-border-color: var(--c-primary-hover);
    --bs-btn-active-bg: #0f3d22; --bs-btn-active-border-color: #0f3d22;
    --bs-btn-disabled-bg: var(--c-primary); --bs-btn-disabled-border-color: var(--c-primary);
    --bs-btn-focus-shadow-rgb: 22, 101, 52;
    box-shadow: 0 1px 2px rgba(15, 61, 34, .25), inset 0 1px 0 rgba(255,255,255,.08);
}
.btn-success {
    --bs-btn-bg: var(--c-success); --bs-btn-border-color: var(--c-success);
    --bs-btn-hover-bg: #166534; --bs-btn-hover-border-color: #166534; --bs-btn-active-bg: #14532d;
}
.btn-danger { --bs-btn-bg: var(--c-danger); --bs-btn-border-color: var(--c-danger); --bs-btn-hover-bg: #b91c1c; --bs-btn-hover-border-color: #b91c1c; }
.btn-secondary, .btn-outline-secondary, .btn-light {
    --bs-btn-color: var(--c-fg); --bs-btn-bg: #fff; --bs-btn-border-color: var(--c-border-strong);
    --bs-btn-hover-bg: var(--c-surface-2); --bs-btn-hover-color: var(--c-fg); --bs-btn-hover-border-color: #94a3b8;
    --bs-btn-active-bg: #eef2f0; --bs-btn-active-color: var(--c-fg); --bs-btn-active-border-color: #94a3b8;
    --bs-btn-disabled-color: var(--c-fg-subtle); --bs-btn-disabled-bg: #fff; --bs-btn-disabled-border-color: var(--c-border);
    box-shadow: var(--shadow-xs);
}
.btn-outline-primary {
    --bs-btn-color: var(--c-primary); --bs-btn-bg: #fff; --bs-btn-border-color: var(--c-primary-line);
    --bs-btn-hover-bg: var(--c-primary-soft); --bs-btn-hover-color: var(--c-primary-hover); --bs-btn-hover-border-color: var(--c-primary);
    --bs-btn-active-bg: #d7efdf; --bs-btn-active-color: var(--c-primary-hover); --bs-btn-active-border-color: var(--c-primary);
}
.btn-soft { --bs-btn-color: var(--c-primary); --bs-btn-bg: var(--c-primary-soft); --bs-btn-border-color: transparent; --bs-btn-hover-bg: #d7efdf; --bs-btn-hover-color: var(--c-primary-hover); --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: #c6e8d2; --bs-btn-active-color: var(--c-primary-hover); }
.btn-outline-danger {
    --bs-btn-color: var(--c-danger); --bs-btn-bg: #fff; --bs-btn-border-color: #f3c4c4;
    --bs-btn-hover-bg: var(--c-danger-soft); --bs-btn-hover-color: #b91c1c; --bs-btn-hover-border-color: var(--c-danger);
    --bs-btn-active-bg: #fbd5d5; --bs-btn-active-color: #b91c1c;
}
.btn-ghost {
    --bs-btn-color: var(--c-fg-muted); --bs-btn-bg: transparent; --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: #eef2f0; --bs-btn-hover-color: var(--c-fg); --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: #e3e8e6; --bs-btn-active-color: var(--c-fg);
}
.btn-icon { width: 42px; min-width: 42px; height: 42px; min-height: 42px; padding: 0; }
.btn-sm.btn-icon { width: 34px; min-width: 34px; height: 34px; min-height: 34px; }
.btn-group-joined { display: inline-flex; border: 1px solid var(--c-border-strong); border-radius: 10px; background: #fff; overflow: hidden; box-shadow: var(--shadow-xs); }
.btn-group-joined > .btn { border: 0; border-radius: 0; box-shadow: none; min-height: 38px; }
.btn-group-joined > .btn + .btn { border-left: 1px solid var(--c-border); }
.btn-group-joined > .btn.active { background: var(--c-primary-soft); color: var(--c-primary); }

/* Dropdown menus */
.dropdown-menu {
    --bs-dropdown-border-color: var(--c-border);
    --bs-dropdown-border-radius: 12px;
    --bs-dropdown-padding-y: 6px;
    --bs-dropdown-link-active-bg: var(--c-primary-soft);
    --bs-dropdown-link-active-color: var(--c-primary-hover);
    --bs-dropdown-link-hover-bg: var(--c-surface-2);
    --bs-dropdown-font-size: .92rem;
    min-width: 220px; box-shadow: var(--shadow-lg); padding: 6px;
}
.dropdown-item { display: flex; align-items: center; gap: 10px; border-radius: 8px; padding: 9px 12px; color: var(--c-fg); }
.dropdown-item i { width: 18px; text-align: center; color: var(--c-fg-subtle); }
.dropdown-item.text-danger i { color: inherit; }
.dropdown-item.text-danger:hover { background: var(--c-danger-soft); color: #b91c1c !important; }
.dropdown-header { font-size: .75rem; color: var(--c-fg-subtle); padding: 6px 12px; }
.dropdown-divider { margin: 6px 4px; border-color: var(--c-border); }

/* Underline tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); margin-bottom: var(--space-5); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button {
    position: relative; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
    padding: 12px 14px; color: var(--c-fg-muted); text-decoration: none; font-weight: 500; font-size: .93rem;
    border: 0; background: none; min-height: 46px;
}
.tabs a:hover, .tabs button:hover { color: var(--c-fg); }
.tabs a.active, .tabs button.active { color: var(--c-primary); }
.tabs a.active::after, .tabs button.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--c-primary); }
.tabs .count { font-size: .75rem; background: #eef2f0; color: var(--c-fg-muted); border-radius: 999px; padding: 1px 8px; }
.tabs .active .count { background: var(--c-primary-soft); color: var(--c-primary); }

/* Segmented filter */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: #eef2f0; border-radius: 10px; }
.seg button { border: 0; background: transparent; color: var(--c-fg-muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; font-size: .86rem; min-height: 34px; white-space: nowrap; }
.seg button.active { background: #fff; color: var(--c-fg); box-shadow: var(--shadow-xs); }
.seg button:hover:not(.active) { color: var(--c-fg); }

/* ======================================================================
   Forms
   ====================================================================== */
.form-label { font-weight: 500; color: var(--c-fg); margin-bottom: 6px; font-size: .92rem; }
.form-label .req { color: var(--c-danger); margin-left: 2px; }
.form-text { color: var(--c-fg-subtle); font-size: .8rem; }
.form-control, .form-select {
    min-height: 44px; border-radius: 10px; border-color: var(--c-border-strong);
    font-size: .98rem; color: var(--c-fg); background-color: #fff;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea.form-control { min-height: auto; }
.form-control:hover, .form-select:hover { border-color: #94a3b8; }
.form-control:focus, .form-select:focus { border-color: var(--c-ring); box-shadow: 0 0 0 4px rgba(21, 128, 61, .14); }
.form-control::placeholder { color: #94a3b8; }
.form-check-input:checked { background-color: var(--c-primary); border-color: var(--c-primary); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(21, 128, 61, .14); border-color: var(--c-ring); }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--c-fg-subtle); pointer-events: none; }
.input-icon > .form-control { padding-left: 42px; }
.input-icon .kbd-hint { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }

.file-drop {
    position: relative; display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-4); border: 1.5px dashed var(--c-border-strong); border-radius: var(--radius);
    background: var(--c-surface-2); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.file-drop:hover, .file-drop.is-dragover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.file-drop .file-drop-icon { width: 40px; height: 40px; border-radius: 10px; background: #fff; border: 1px solid var(--c-border); display: grid; place-items: center; color: var(--c-primary); font-size: 1.15rem; flex: none; }
.file-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop-text { font-size: .9rem; color: var(--c-fg-muted); min-width: 0; }
.file-drop-text strong { color: var(--c-fg); font-weight: 500; display: block; }
.file-drop-names { font-size: .85rem; color: var(--c-primary); word-break: break-all; }

/* ======================================================================
   Tables / lists
   ====================================================================== */
.table { --bs-table-hover-bg: #f6f9f7; margin: 0; }
.table > thead th {
    background: var(--c-surface-2); color: var(--c-fg-subtle); font-weight: 600; font-size: .78rem; letter-spacing: .02em;
    border-bottom: 1px solid var(--c-border); padding: 11px 16px; white-space: nowrap;
}
.table > tbody td { padding: 14px 16px; vertical-align: middle; border-color: var(--c-border); }
.table > tbody tr:last-child td { border-bottom: 0; }
.clickable-row:hover .row-title { color: var(--c-primary); }
.row-title { font-weight: 600; color: var(--c-fg); text-decoration: none; display: block; }
.row-sub { font-size: .84rem; color: var(--c-fg-subtle); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.row-actions { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: var(--space-4); border-bottom: 1px solid var(--c-border); position: relative; }
    .table-stack td { padding: 3px 0; border: 0; }
    .table-stack td.col-hide-sm { display: none; }
    .table-stack td.col-actions { padding-top: var(--space-3); text-align: left !important; }
}

/* Pills */
.pill {
    display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
    font-size: .76rem; font-weight: 600; padding: 2px 10px; border-radius: 999px;
    border: 1px solid transparent; line-height: 1.6;
}
.pill-green { background: var(--c-success-soft); color: var(--c-success); border-color: var(--c-primary-line); }
.pill-gray { background: #f1f5f9; color: var(--c-fg-muted); border-color: var(--c-border); }
.pill-amber { background: var(--c-warning-soft); color: var(--c-warning); border-color: #f6dcae; }
.pill-red { background: var(--c-danger-soft); color: #b91c1c; border-color: #f5c2c2; }
.pill-blue { background: var(--c-info-soft); color: var(--c-info); border-color: #bcdcee; }
.pill-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.type-1 { --type-c: #0369a1; --type-bg: #e6f2f9; }
.type-2 { --type-c: #7c3aed; --type-bg: #f1ebfd; }
.type-3 { --type-c: #b45309; --type-bg: #fdf4e3; }
.type-4 { --type-c: #15803d; --type-bg: #e7f6ec; }
.type-5 { --type-c: #475569; --type-bg: #f1f5f9; }
.type-pill { background: var(--type-bg, #f1f5f9); color: var(--type-c, #475569); }

.progress { height: 8px; background: #e8eeeb; border-radius: 99px; }
.progress-bar { background: var(--c-primary); border-radius: 99px; transition: width 400ms var(--ease); }
.progress-sm { height: 6px; }

/* Empty states */
.empty-state { text-align: center; padding: var(--space-7) var(--space-4); color: var(--c-fg-muted); }
.empty-state .empty-icon {
    width: 64px; height: 64px; margin: 0 auto var(--space-4); border-radius: 16px;
    display: grid; place-items: center; background: var(--c-primary-soft); color: var(--c-primary); font-size: 1.75rem;
}
.empty-state h3 { font-size: 1.08rem; color: var(--c-fg); margin-bottom: var(--space-1); }

/* ======================================================================
   Agenda editor (manage agendas)
   ====================================================================== */
.agenda-section-title { display: flex; align-items: center; gap: var(--space-3); font-size: 1rem; font-weight: 600; margin: var(--space-5) 0 var(--space-3); }
.agenda-group:first-child .agenda-section-title { margin-top: 0; }
.agenda-section-title .num { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: .88rem; background: var(--type-bg); color: var(--type-c); font-weight: 700; flex: none; }
.agenda-section-title .count { margin-left: auto; font-size: .8rem; font-weight: 500; color: var(--c-fg-subtle); }

.agenda-editor { border: 1px solid var(--c-border); border-radius: var(--radius); background: #fff; margin-bottom: 8px; transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.agenda-editor:hover { border-color: var(--c-border-strong); }
.agenda-editor:has(.collapse.show) { box-shadow: var(--shadow); border-color: var(--type-c); }
.agenda-editor-head { display: flex; align-items: center; gap: var(--space-2); padding: 6px 8px 6px var(--space-4); min-height: 56px; }
.agenda-editor-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-3); background: none; border: 0; padding: 8px 0; text-align: left; color: inherit; }
.agenda-editor-toggle .chev { transition: transform var(--dur) var(--ease); color: var(--c-fg-subtle); }
.agenda-editor-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.agenda-order { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--type-c, var(--c-primary)); background: var(--type-bg, var(--c-primary-soft)); padding: 2px 10px; border-radius: 6px; font-size: .86rem; white-space: nowrap; }
.agenda-editor-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.agenda-editor-body { padding: var(--space-4) var(--space-5) var(--space-5); border-top: 1px solid var(--c-border); }

.new-agenda { border: 1px solid var(--c-border); border-radius: var(--radius); background: #fff; margin-bottom: var(--space-4); overflow: hidden; box-shadow: var(--shadow-xs); animation: rise 260ms var(--ease); }
.new-agenda-head { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-4); background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); }
.new-agenda-head .idx { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--c-primary); color: #fff; font-size: .82rem; font-weight: 700; }
.new-agenda-body { padding: var(--space-5); }
.add-row-btn { width: 100%; min-height: 56px; border: 1.5px dashed var(--c-primary-line); background: #fff; color: var(--c-primary); border-radius: var(--radius); font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.add-row-btn:hover { background: var(--c-primary-soft); border-color: var(--c-primary); }

/* Sticky bottom action bar */
.action-bar {
    position: sticky; bottom: 0; z-index: 1020;
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px);
    border-top: 1px solid var(--c-border);
    padding: 12px var(--space-6); margin: var(--space-5) calc(-1 * var(--space-6)) calc(-1 * var(--space-7));
    display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
}
.action-bar .hint { color: var(--c-fg-subtle); font-size: .86rem; margin-right: auto; }
@media (max-width: 991.98px) { .action-bar { padding: 12px var(--space-4); margin: var(--space-5) calc(-1 * var(--space-4)) calc(-1 * var(--space-7)); } }

/* Attachments */
.attach-list { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.attach-item { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-3); border: 1px solid var(--c-border); border-radius: 10px; background: #fff; text-decoration: none; color: var(--c-fg); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); min-width: 0; }
a.attach-item:hover { border-color: var(--c-primary); background: var(--c-primary-soft); color: var(--c-fg); }
.attach-item .fi { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--c-danger-soft); color: var(--c-danger); flex: none; }
.attach-item .fi.doc { background: var(--c-info-soft); color: var(--c-info); }
.attach-item .fi.img { background: var(--c-accent-soft); color: var(--c-warning); }
.attach-item .fi.xls { background: var(--c-success-soft); color: var(--c-success); }
.attach-item .fn { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.attach-item .bi-box-arrow-up-right { color: var(--c-fg-subtle); flex: none; }

/* ======================================================================
   Document content (agenda descriptions pasted from Word)
   ====================================================================== */
.doc {
    --doc-fs: clamp(18px, 0.55vw + 11px, 24px);
    font-family: 'Sarabun', 'TH SarabunPSK', 'Noto Sans Thai', sans-serif;
    font-size: var(--doc-fs);
    line-height: 1.75;
    color: #111827;
    overflow-wrap: break-word;
    word-break: normal;
}
.doc.doc-sized { --doc-fs: var(--doc-fs-user); }
/* Normalise Word inline styles: one readable size/leading for everything */
.doc * { font-size: inherit !important; line-height: inherit !important; }
.doc [style*="font-family"]:not([style*="Symbol"]):not([style*="Wingdings"]):not([style*="Webdings"]) { font-family: inherit !important; }
.doc font[face]:not([face*="Symbol"]):not([face*="Wingdings"]) { font-family: inherit !important; }
.doc h1, .doc h1 * { font-size: 1.45em !important; }
.doc h2, .doc h2 * { font-size: 1.3em !important; }
.doc h3, .doc h3 * { font-size: 1.15em !important; }
.doc h1, .doc h2, .doc h3, .doc h4 { margin: 1em 0 .5em; font-weight: 700; }
.doc p { margin-top: 0 !important; margin-bottom: .45em !important; }
.doc p:last-child { margin-bottom: 0 !important; }
.doc [style*="justify"], .doc [align="justify"] { text-align: left !important; }
.doc strong, .doc b { font-weight: 700; }
.doc ul, .doc ol { padding-left: 1.6em; margin-bottom: .6em; }
.doc img { max-width: 100% !important; height: auto !important; border-radius: 6px; }
.doc a { word-break: break-all; }
.doc-table-wrap { overflow-x: auto; margin: .8em 0 1em; border-radius: 8px; -webkit-overflow-scrolling: touch; }
.doc table { width: 100% !important; max-width: none; border-collapse: collapse !important; margin: 0 !important; font-size: .9em !important; background: #fff; }
.doc table * { font-size: inherit !important; }
.doc td, .doc th { border: 1px solid #cbd5e1 !important; padding: .4em .65em !important; vertical-align: top; height: auto !important; }
.doc tr { height: auto !important; }
.doc td p, .doc th p { margin-bottom: 0 !important; }
.doc table tr:first-child td { background: #f6f9f7; }
.doc-empty { color: var(--c-fg-subtle); font-style: italic; }

/* ======================================================================
   Reader (meeting run / view)
   ====================================================================== */
html.reader-page, html.reader-page body { height: 100%; overflow: hidden; }
/* Pin the shell to the viewport so each reader pane scrolls on its own */
html.reader-page .app { height: 100vh; height: 100dvh; grid-template-rows: minmax(0, 1fr); }
html.reader-page .main-col { position: relative; min-height: 0; height: 100%; overflow: hidden; }
html.reader-page .sidebar { height: 100%; }
.reader { flex: 1; min-height: 0; display: grid; grid-template-columns: 288px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); background: var(--c-surface); }
.reader.list-hidden { grid-template-columns: 0 minmax(0, 1fr); }
.reader.list-hidden .reader-list { visibility: hidden; border: 0; }

.reader-list { position: relative; min-height: 0; overflow-y: auto; border-right: 1px solid var(--c-border); background: var(--c-surface-2); display: flex; flex-direction: column; }
.reader-list-head { padding: var(--space-4) var(--space-4) var(--space-3); border-bottom: 1px solid var(--c-border); position: sticky; top: 0; background: var(--c-surface-2); z-index: 2; }
.reader-list-head .label { font-size: .78rem; color: var(--c-fg-subtle); font-weight: 600; letter-spacing: .03em; }
.progress-label { display: flex; justify-content: space-between; font-size: .78rem; color: var(--c-fg-muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

.agenda-nav { list-style: none; margin: 0; padding: 8px; }
.agenda-nav-group { font-size: .72rem; font-weight: 600; color: var(--c-fg-subtle); padding: 12px 10px 4px; letter-spacing: .03em; }
.agenda-link { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid transparent; background: transparent; text-align: left; color: var(--c-fg); transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.agenda-link:hover { background: #eef3f0; }
.agenda-link.active { background: #fff; border-color: var(--c-primary-line); box-shadow: var(--shadow-sm); }
.agenda-link .agenda-order { flex: none; margin-top: 1px; font-size: .8rem; padding: 1px 8px; }
.agenda-link .t { flex: 1; min-width: 0; font-size: .88rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agenda-link.active .t { font-weight: 600; }
.status-dot { flex: none; width: 20px; height: 20px; margin-top: 1px; display: grid; place-items: center; font-size: .95rem; color: #cbd5e1; }
.status-dot[data-status="completed"] { color: var(--c-success); }

.reader-body { position: relative; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.reader-toolbar {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
    padding: 10px var(--space-5); min-height: 58px;
    background: rgba(255,255,255,.95); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--c-border);
}
.reader-toolbar .spacer { flex: 1; }
.reader-toolbar .pos { font-size: .86rem; color: var(--c-fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fs-control { display: inline-flex; align-items: center; border: 1px solid var(--c-border-strong); border-radius: 10px; overflow: hidden; background: #fff; height: 38px; }
.fs-control button { border: 0; background: transparent; width: 36px; height: 36px; color: var(--c-fg-muted); display: grid; place-items: center; }
.fs-control button:hover { background: var(--c-surface-2); color: var(--c-fg); }
.fs-control .fs-label { font-size: .78rem; color: var(--c-fg-subtle); width: auto; padding: 0 6px; min-width: 48px; font-variant-numeric: tabular-nums; }

.reader-grid { display: grid; grid-template-columns: minmax(0, 1fr); }
.reader-content { padding: var(--space-6) clamp(20px, 3.5vw, 64px) var(--space-6); min-width: 0; }
.reader-content-inner { margin: 0 auto; max-width: none; }
.reader.fit-width .reader-content-inner { max-width: 1040px; }
.agenda-headline { margin-bottom: var(--space-5); padding-bottom: var(--space-4); border-bottom: 1px solid var(--c-border); }
.agenda-headline .eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: 10px; }
.agenda-headline h2 { font-size: clamp(1.45rem, 1.2vw + 1rem, 2.1rem); line-height: 1.4; margin: 0; font-weight: 700; }
.reader-section-title { font-size: .82rem; font-weight: 600; color: var(--c-fg-subtle); letter-spacing: .03em; margin: var(--space-6) 0 var(--space-3); display: flex; align-items: center; gap: 8px; }

/* Resolution panel */
.res-panel { border-top: 1px solid var(--c-border); background: var(--c-surface-2); padding: var(--space-5) clamp(20px, 3.5vw, 64px) var(--space-6); }
.res-panel-inner { max-width: 1040px; }
.res-card { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; }
.res-card-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--c-border); }
.res-card-head h3 { font-size: 1rem; margin: 0; }
.res-card-body { padding: var(--space-4); }
.res-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.res-option { position: relative; }
.res-option input { position: absolute; opacity: 0; pointer-events: none; }
.res-option label {
    display: flex; align-items: center; gap: 8px; justify-content: center; text-align: center;
    min-height: 46px; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--c-border-strong);
    background: #fff; font-weight: 500; color: var(--c-fg-muted); width: 100%; font-size: .92rem;
    transition: all var(--dur) var(--ease);
}
.res-option label:hover { border-color: var(--rc); color: var(--rc); }
.res-option input:checked + label { background: var(--rbg); border-color: var(--rc); color: var(--rc); box-shadow: 0 0 0 3px var(--rbg); font-weight: 600; }
.res-option input:focus-visible + label { outline: 3px solid var(--c-ring); outline-offset: 2px; }
.res-acknowledge { --rc: #15803d; --rbg: #e7f6ec; }
.res-certify { --rc: #0369a1; --rbg: #e6f2f9; }
.res-not_certify { --rc: #b45309; --rbg: #fdf4e3; }
.res-approve { --rc: #166534; --rbg: #dcfce7; }
.res-object { --rc: #b91c1c; --rbg: #fdecec; }
.res-other { --rc: #475569; --rbg: #f1f5f9; }
.res-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.resolution-result { border: 1px solid var(--c-primary-line); border-left: 4px solid var(--c-success); background: var(--c-success-soft); border-radius: 10px; padding: var(--space-4) var(--space-5); }

.reader-footer { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-4) clamp(20px, 3.5vw, 64px) var(--space-6); border-top: 1px solid var(--c-border); }
.reader-footer .grow { flex: 1; }
.kbd { display: inline-block; padding: 0 6px; font-size: .75rem; border: 1px solid var(--c-border-strong); border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--c-fg-muted); font-family: inherit; line-height: 1.6; }

/* Wide screens: resolution panel on the right */
@media (min-width: 1400px) {
    .reader-body.has-panel { overflow: hidden; display: flex; flex-direction: column; }
    .reader-body.has-panel .reader-grid { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr); }
    .reader-body.has-panel .reader-main { min-height: 0; overflow-y: auto; }
    .reader-body.has-panel .res-panel { min-height: 0; overflow-y: auto; border-top: 0; border-left: 1px solid var(--c-border); padding: var(--space-5); }
    .reader-body.has-panel .res-options { grid-template-columns: 1fr 1fr; }
}

/* Presentation mode (full screen reading) */
html.present .sidebar, html.present .topbar, html.present .reader-list, html.present .res-panel { display: none !important; }
html.present .app { grid-template-columns: minmax(0, 1fr); }
html.present .reader { grid-template-columns: minmax(0, 1fr); }
html.present .reader-body.has-panel .reader-grid { grid-template-columns: minmax(0, 1fr); }
html.present .doc { --doc-fs: clamp(22px, 0.9vw + 12px, 34px); }
html.present .doc.doc-sized { --doc-fs: var(--doc-fs-user); }
html.present .reader-content { padding-left: clamp(24px, 5vw, 96px); padding-right: clamp(24px, 5vw, 96px); }

/* Reader: tablet & mobile */
@media (max-width: 991.98px) {
    html.reader-page, html.reader-page body { height: auto; overflow: auto; }
    .reader { display: block; }
    .reader-list {
        position: fixed; left: 0; top: 0; bottom: 0; width: min(320px, 88vw); z-index: 1046;
        transform: translateX(-100%); transition: transform 240ms var(--ease); box-shadow: var(--shadow-lg); visibility: visible !important;
    }
    .reader-list.open { transform: none; }
    .reader.list-hidden .reader-list { visibility: visible; }
    .reader-body { overflow: visible; }
    .reader-toolbar { top: var(--topbar-h); padding: 8px var(--space-3); }
    .reader-content { padding: var(--space-5) var(--space-4); }
    .res-panel { padding: var(--space-4); }
    .reader-footer { padding: var(--space-4); }
    .hide-md { display: none !important; }
}

/* ======================================================================
   Modals / alerts / misc
   ====================================================================== */
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--c-border); padding: var(--space-4) var(--space-5); }
.modal-title { font-weight: 600; font-size: 1.08rem; display: flex; align-items: center; gap: var(--space-2); }
.modal-title i { color: var(--c-primary); }
.modal-body { padding: var(--space-5); }
.modal-footer { border-top: 1px solid var(--c-border); padding: var(--space-3) var(--space-5); background: var(--c-surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.alert { border-radius: var(--radius); }
.callout { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--c-info-soft); border: 1px solid #bcdcee; color: #0c4a6e; font-size: .9rem; }
.callout i { font-size: 1.15rem; color: var(--c-info); margin-top: 1px; }
.swal2-popup { font-family: var(--bs-body-font-family) !important; border-radius: var(--radius-lg) !important; }
.swal2-styled.swal2-confirm, .swal2-styled.swal2-cancel { border-radius: 10px !important; }
.tooltip { --bs-tooltip-font-size: .8rem; --bs-tooltip-bg: #0f172a; --bs-tooltip-border-radius: 6px; }
.tox-tinymce { border-radius: 10px !important; border-color: var(--c-border-strong) !important; }

/* ======================================================================
   Login
   ====================================================================== */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside { position: relative; overflow: hidden; color: #fff; background: linear-gradient(160deg, #0e2a1a 0%, #166534 62%, #1f7a43 100%); padding: clamp(32px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside::before, .auth-aside::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .05); }
.auth-aside::before { width: 420px; height: 420px; right: -140px; top: -120px; }
.auth-aside::after { width: 300px; height: 300px; left: -100px; bottom: -120px; }
.auth-aside h1 { color: #fff; font-size: clamp(1.6rem, 3vw, 2.3rem); line-height: 1.35; margin: 0 0 var(--space-3); position: relative; }
.auth-aside p { color: rgba(255, 255, 255, .82); max-width: 460px; position: relative; }
.auth-feature { display: flex; gap: var(--space-3); align-items: flex-start; margin-top: var(--space-4); position: relative; }
.auth-feature i { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .12); flex: none; }
.auth-feature strong { display: block; font-weight: 600; }
.auth-feature span { color: rgba(255, 255, 255, .75); font-size: .9rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: var(--space-6) var(--space-4); background: #fff; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { height: 64px; width: auto; margin-bottom: var(--space-5); }
.auth-card h2 { font-size: 1.55rem; margin-bottom: var(--space-1); }
.pw-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }
@media (max-width: 991.98px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-main { background: var(--c-bg); }
    .auth-card { background: #fff; padding: var(--space-6) var(--space-5); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--c-border); }
}

/* ======================================================================
   Report / print
   ====================================================================== */
.report-paper { background: #fff; max-width: 900px; margin: 0 auto; padding: clamp(24px, 5vw, 64px); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.report-head { text-align: center; padding-bottom: var(--space-5); margin-bottom: var(--space-5); border-bottom: 2px solid var(--c-fg); }
.report-head img { height: 64px; margin-bottom: var(--space-3); }
.report-head h1 { font-size: 1.45rem; margin-bottom: var(--space-1); }
.report-head h2 { font-size: 1.12rem; font-weight: 500; color: var(--c-fg-muted); margin-bottom: var(--space-2); }
.report-group { font-size: 1.05rem; font-weight: 700; margin: var(--space-6) 0 var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid var(--c-border); }
.report-item { margin-bottom: var(--space-5); break-inside: avoid-page; }
.report-item h3 { font-size: 1rem; font-weight: 600; margin-bottom: var(--space-2); }
.report-item .doc { --doc-fs: 17px; padding-left: var(--space-5); }
.report-resolution { margin: var(--space-3) 0 0 var(--space-5); padding: var(--space-3) var(--space-4); border-left: 4px solid var(--c-primary); background: var(--c-surface-2); border-radius: 0 8px 8px 0; }

@media print {
    body { background: #fff; }
    .no-print, .sidebar, .topbar, .action-bar, .tabs { display: none !important; }
    .app { display: block; }
    .page { padding: 0; max-width: none; }
    .report-paper { border: 0; box-shadow: none; margin: 0; max-width: none; padding: 0; }
    .report-item .doc { --doc-fs: 14pt; }
    .report-resolution { background: #fff; }
    a { color: inherit; text-decoration: none; }
}

/* ======================================================================
   Motion
   ====================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: rise 260ms var(--ease) both; }
.agenda-view.is-active { animation: rise 280ms var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Compact reader toolbar on medium screens */
@media (max-width: 1279.98px) {
    .reader-toolbar .tb-text { display: none; }
    .reader-toolbar [data-reader="width"], .reader-toolbar [data-reader="present"] { width: 38px; padding: 0; }
}
@media (min-width: 1680px) {
    .reader { grid-template-columns: 320px minmax(0, 1fr); }
    .reader-body.has-panel .reader-grid { grid-template-columns: minmax(0, 1fr) 380px; }
}
@media (max-width: 575.98px) {
    .reader-toolbar [data-reader="present"] { display: none; }
}

/* Reader on tablet/mobile: normal page scroll (undo the viewport pinning) */
@media (max-width: 991.98px) {
    html.reader-page .app { height: auto; grid-template-rows: none; }
    html.reader-page .main-col { height: auto; overflow: visible; }
    .reader { grid-template-rows: none; }
}

/* Tab panes may be nested inside a <form>; Bootstrap only hides direct children of .tab-content */
.tab-content .tab-pane { display: none; }
.tab-content .tab-pane.active { display: block; }

/* Selected-files list under a file picker */
.file-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.file-list:empty { display: none; }
.file-chip { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 10px; border: 1px solid var(--c-border); border-radius: 10px; background: #fff; min-width: 0; animation: rise 180ms var(--ease); }
.file-chip .fi { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: var(--c-danger-soft); color: var(--c-danger); flex: none; font-size: .95rem; }
.file-chip .fi.doc { background: var(--c-info-soft); color: var(--c-info); }
.file-chip .fi.img { background: var(--c-accent-soft); color: var(--c-warning); }
.file-chip .fi.xls { background: var(--c-success-soft); color: var(--c-success); }
.file-chip .fn { flex: 1; min-width: 0; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .fs { font-size: .78rem; color: var(--c-fg-subtle); white-space: nowrap; font-variant-numeric: tabular-nums; }
.file-chip.is-error { border-color: #f5c2c2; background: var(--c-danger-soft); }
.file-chip.is-error .fs { color: var(--c-danger); font-weight: 600; }
.file-chip .btn-icon { width: 30px; min-width: 30px; height: 30px; min-height: 30px; }

/* ======================================================================
   Presentation mode: resolution bar in the top toolbar
   ====================================================================== */
.pres-res, .present-only { display: none; }
html.present .present-only { display: block; }
html.present .pres-res {
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center;
    padding: 4px; background: #f1f5f3; border: 1px solid var(--c-border); border-radius: 14px;
}
.pres-res-label { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px 0 10px; font-size: .8rem; font-weight: 600; color: var(--c-fg-subtle); white-space: nowrap; }
.pres-res-label i { color: var(--c-primary); }
.res-chip {
    position: relative; display: inline-flex; align-items: center; gap: 7px;
    height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid transparent;
    background: transparent; color: var(--c-fg-muted); font-weight: 500; font-size: .9rem; white-space: nowrap;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.res-chip i { font-size: 1rem; }
.res-chip .k {
    font-family: inherit; font-size: .68rem; line-height: 1; padding: 3px 5px; border-radius: 4px;
    border: 1px solid currentColor; opacity: .45; background: transparent; color: inherit; box-shadow: none;
}
.res-chip:hover { background: #fff; color: var(--rc); border-color: var(--c-border); }
.res-chip.active {
    background: var(--rbg); color: var(--rc); border-color: var(--rc); font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 0 0 3px color-mix(in srgb, var(--rbg) 60%, transparent);
}
.res-chip.active .k { opacity: .8; }
.res-chip.active::after {
    content: "\F26B"; font-family: bootstrap-icons; position: absolute; top: -7px; right: -6px;
    width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
    font-size: .7rem; background: var(--rc); color: #fff; box-shadow: 0 0 0 2px #fff;
}
.res-chip.is-saving { opacity: .6; pointer-events: none; }
.res-chip:focus-visible { outline: 3px solid var(--c-ring); outline-offset: 1px; }
.pres-res-divider { width: 1px; height: 24px; background: var(--c-border-strong); margin: 0 4px; }
.res-tool {
    position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent;
    background: transparent; color: var(--c-fg-muted); display: grid; place-items: center; font-size: 1.05rem;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.res-tool:hover { background: #fff; color: var(--c-fg); border-color: var(--c-border); }
.res-tool-danger:hover { color: var(--c-danger); background: var(--c-danger-soft); border-color: #f5c2c2; }
.res-tool:disabled { opacity: .35; pointer-events: none; }
.res-note-dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--c-accent); box-shadow: 0 0 0 2px #f1f5f3; }

/* Toolbar layout while presenting: nav | resolution bar (centre) | text size + exit */
html.present .reader-toolbar {
    min-height: 72px; padding: 12px clamp(16px, 3vw, 48px); gap: 12px;
    box-shadow: 0 8px 20px -16px rgba(15, 23, 42, .4);
}
html.present .reader-toolbar [data-reader="toggle-list"],
html.present .reader-toolbar [data-reader="width"] { display: none; }
html.present .reader-toolbar .btn-group-joined:has([data-reader="width"]) { display: none; }
html.present .reader-toolbar .pos { font-weight: 600; color: var(--c-fg); }

/* Not enough room on one line: resolution bar gets its own row */
@media (max-width: 1399.98px) {
    html.present .pres-res { order: 10; width: 100%; }
    html.present .reader-toolbar .present-only { display: none; }
}
@media (max-width: 1099.98px) {
    html.present .res-chip .k { display: none; }
    html.present .res-chip { padding: 0 10px; }
}
