/* ==========================================
   SayFlow Components — components.css
   ========================================== */

/* ==========================================
   CARDS
   ========================================== */

.card {
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* A header is a title plus (usually) an action. On a narrow card the action
   drops under the title instead of squeezing it to nothing. */
.card-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background-color: transparent;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    min-width: 0;
    color: var(--text-main);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 0.875rem 1.25rem;
    background-color: transparent;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 575.98px) {
    .card {
        margin-bottom: 1rem;
        border-radius: var(--radius);
    }

    .card-header,
    .card-footer {
        padding: 0.75rem 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Footers pair an explanatory note with a submit button; side by side at
       this width the button ends up two words wide. */
    .card-footer.d-flex {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .card-footer.d-flex .btn {
        width: 100%;
    }
}

/* Stat Cards
   A small icon sits beside the label on the top row and the figure gets a row
   to itself. Money strings are long enough (₦11,962,903.82) that sharing a row
   with a 48px icon left barely 180px for them on a laptop — the figure broke
   across lines, and a number split in two is a number that has to be read
   twice. */
.stat-card {
    display: block;
    padding: 1.25rem;
}

.stat-head {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.625rem;
}

.stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.stat-icon.success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.stat-icon.warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-icon.info {
    background-color: rgba(14, 165, 233, 0.1);
    color: var(--info);
}

.stat-head h3 {
    margin: 0;
    min-width: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Never broken across lines, and scaled to the viewport so it still fits on
   one at every column width. Tabular figures keep the digits on a fixed
   advance, so whether an amount is full of 1s no longer decides whether it
   fits. */
.stat-value {
    display: block;
    width: 100%;
    margin: 0;
    font-size: clamp(1.1rem, 1.1vw + 0.4rem, 1.5rem);
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 575.98px) {
    .stat-card {
        padding: 1rem;
    }

    /* One card per row on a phone, so the figure has the whole width and can
       be read at full size. */
    .stat-value {
        font-size: 1.35rem;
    }
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    border-radius: var(--radius);
    transition: var(--transition);
    cursor: pointer;
    gap: 0.25rem;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: white;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: var(--success-hover);
    color: white;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    color: white;
}

.btn-warning {
    background-color: var(--warning);
    color: white;
}

.btn-warning:hover {
    background-color: var(--warning-hover);
    color: white;
}

.btn-info {
    background-color: var(--info);
    color: white;
}

.btn-info:hover {
    background-color: var(--info-hover);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-light);
}

.btn-outline-primary {
    background-color: transparent;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    color: #fff;
}

.btn-outline-secondary {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-muted);
}

.btn-outline-secondary:hover {
    background-color: var(--bg-light);
    color: var(--text-main);
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
}

/* On touch screens a 0.75rem icon button is a ~22px target. Give every button
   a finger-sized minimum there without changing the desktop look. */
@media (pointer: coarse) {
    .btn {
        min-height: 40px;
    }

    .btn-sm {
        min-height: 34px;
        padding: 0.35rem 0.7rem;
    }
}

/* ==========================================
   FORMS
   ========================================== */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-main);
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--bg-white);
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: var(--transition);
    font-family: inherit;
    appearance: auto;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control-sm,
.form-select-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.form-control-color {
    padding: 0.3rem;
    height: 38px;
}

textarea.form-control {
    resize: vertical;
}

.is-invalid {
    border-color: var(--danger) !important;
}

.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* Input Group */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1 1 auto;
}

.input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Helper text under a field. */
.form-text {
    margin-top: 0.3rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
}

/* Form Check */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* A switch is a checkbox with its label and help text beside it, so the row
   has to wrap rather than stretch the label off-screen. */
.form-check.form-switch {
    flex-wrap: wrap;
    align-items: flex-start;
}

.form-check.form-switch .form-check-input {
    margin-top: 0.15rem;
    flex-shrink: 0;
}

.form-check.form-switch .form-check-label {
    flex: 1 1 auto;
    min-width: 0;
}

.form-check.form-switch .form-text {
    flex: 1 1 100%;
    margin-top: 0.25rem;
}

.form-check-input {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.form-check-label {
    font-size: 0.85rem;
    cursor: pointer;
}

/* ==========================================
   TABLES
   ========================================== */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--text-main);
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.7rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    font-size: 0.85rem;
}

.table thead th {
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.02);
}

.table-sm th,
.table-sm td {
    padding: 0.45rem 0.75rem;
}

/* ------------------------------------------
   STACKED TABLES (mobile)

   A seven-column ledger cannot be read through a 360px window, and sideways
   scrolling hides exactly the columns that matter (the amount, the action).
   Below the md breakpoint a .table-stack turns each row into its own card and
   labels every cell from its `data-label`, so nothing needs scrolling.

   Markup contract: every <td> carries data-label="<column heading>". Cells
   that are self-explanatory (an avatar, a row of action buttons) get
   data-label="" and print no label.
   ------------------------------------------ */

@media (max-width: 767.98px) {

    .table-responsive:has(> .table-stack) {
        overflow-x: visible;
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }

    .table-stack thead {
        display: none;
    }

    .table-stack tr {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .table-stack tr:last-child {
        border-bottom: 0;
    }

    .table-stack td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.3rem 0;
        border: 0;
        text-align: right;
    }

    .table-stack td::before {
        content: attr(data-label);
        flex: 0 0 40%;
        text-align: left;
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--text-muted);
    }

    /* An unlabelled cell (avatar block, action buttons) spans the full width.
       A cell that was never given the attribute is treated the same way rather
       than reserving an empty label gutter. */
    .table-stack td[data-label=""]::before,
    .table-stack td:not([data-label])::before {
        content: none;
    }

    .table-stack td[data-label=""],
    .table-stack td:not([data-label]) {
        justify-content: flex-start;
        text-align: left;
    }

    /* The primary cell of a row reads as its heading. */
    .table-stack td.cell-primary {
        display: block;
        text-align: left;
        padding-bottom: 0.5rem;
    }

    .table-stack td.cell-primary::before {
        content: none;
    }

    /* Action buttons get a row of their own, spread across the card. */
    .table-stack td.cell-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.4rem;
        padding-top: 0.6rem;
        margin-top: 0.4rem;
        border-top: 1px dashed var(--border-color);
    }

    .table-stack td.cell-actions::before {
        content: none;
    }

    /* Empty states and other colspan rows stay full-width and centred. */
    .table-stack td[colspan] {
        display: block;
        text-align: center;
    }

    .table-stack td[colspan]::before {
        content: none;
    }

    /* Inputs inside a stacked cell (the salary batch) take the right half. */
    .table-stack td .form-control {
        max-width: 55%;
        margin-left: auto;
    }

    .table-stack td.cell-primary .form-control,
    .table-stack td[data-label=""] .form-control {
        max-width: 100%;
        margin-left: 0;
    }
}

/* ==========================================
   PAGE HEADER + FILTER BAR

   Every list screen opens with the same two things: a title block and a set of
   controls. They were hand-rolled per view as `d-flex justify-content-between`
   with no wrapping, so on a phone the controls ran off the side of the screen.
   These two classes are that pattern, done once.
   ========================================== */

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header-titles {
    min-width: 0;
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1 1 150px;
    min-width: 0;
}

.filter-bar .form-control,
.filter-bar .form-select {
    width: 100%;
}

/* A search box is typed into, not picked from, so it earns more room than the
   dropdowns beside it. */
.filter-bar .filter-search {
    flex: 2 1 220px;
}

/* A results block the page refreshes in place (the income/expense lists). It
   dims while the new rows are in flight so a slow reply never looks like the
   filter was ignored. */
.results-live {
    transition: opacity 0.15s ease;
}

.results-live.is-loading {
    opacity: 0.45;
    pointer-events: none;
}

/* A boxed filter bar (the reports/salaries period pickers) reads as a control
   panel rather than loose inputs. */
.filter-bar-boxed {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 0.5rem 0.75rem;
}

@media (max-width: 767.98px) {
    .page-header,
    .page-header-actions,
    .filter-bar {
        width: 100%;
    }

    /* One control per row beats four half-legible ones. */
    .filter-bar > .form-group,
    .filter-bar > .filter-bar-item {
        flex: 1 1 100%;
    }

    .filter-bar .btn {
        flex: 1 1 auto;
    }

    .page-header-actions .btn,
    .page-header > .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

/* ==========================================
   CHARTS
   ========================================== */

/* Chart.js is told not to maintain an aspect ratio, so the canvas takes the
   height of this box — one place to make charts shorter on a phone. */
.chart-box {
    position: relative;
    width: 100%;
    height: 320px;
}

@media (max-width: 575.98px) {
    .chart-box {
        height: 240px;
    }
}

/* ==========================================
   PROGRESS
   ========================================== */

.progress {
    display: flex;
    height: 8px;
    overflow: hidden;
    background-color: var(--border-color);
    border-radius: 6px;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary);
}

/* ==========================================
   BADGES
   ========================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25em 0.65em;
    font-size: 0.72em;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-primary {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.badge-info {
    background-color: rgba(14, 165, 233, 0.1);
    color: var(--info);
}

.badge-secondary {
    background-color: #e2e8f0;
    color: var(--text-muted);
}

/* ==========================================
   ALERTS
   ========================================== */

.alert {
    position: relative;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    animation: fadeIn 0.3s ease-in;
}

.alert-dismissible {
    padding-right: 3rem;
}

/* A flash message that wraps to three lines must not squash its icon or push
   its text under the close button. */
.alert > i {
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 0.15rem;
}

.alert > span {
    min-width: 0;
    overflow-wrap: break-word;
}

@media (max-width: 575.98px) {
    .alert {
        align-items: flex-start;
    }
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.15);
    color: #065f46;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.15);
    color: #991b1b;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.15);
    color: #92400e;
}

.alert-info {
    background-color: rgba(14, 165, 233, 0.08);
    border-color: rgba(14, 165, 233, 0.15);
    color: #075985;
}

.btn-close {
    padding: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.5;
    margin-left: auto;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

.btn-close:hover {
    opacity: 1;
}

/* ==========================================
   PAGINATION
   ========================================== */

.pagination-wrapper {
    display: flex;
    justify-content: center;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding-left: 0;
    list-style: none;
    gap: 0.25rem;
}

@media (pointer: coarse) {
    .page-link {
        padding: 0.5rem 0.85rem;
    }
}

.page-link {
    position: relative;
    display: block;
    color: var(--text-main);
    text-decoration: none;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    transition: var(--transition);
    font-size: 0.85rem;
}

.page-link:hover {
    background-color: var(--bg-light);
    color: var(--primary);
}

.page-item.active .page-link {
    color: white;
    background-color: var(--primary);
    border-color: var(--primary);
}

.page-item.disabled .page-link {
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.6;
}

/* ==========================================
   DROPDOWNS
   ========================================== */

.dropdown {
    position: relative;
}

.user-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-main);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.user-menu-btn:hover {
    background-color: var(--bg-light);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1000;
    display: none;
    min-width: 10rem;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu-right {
    right: 0;
    left: auto;
}

.dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.5rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    background-color: transparent;
    border: 0;
    font-size: 0.85rem;
    transition: var(--transition);
}

.dropdown-item:hover {
    background-color: var(--bg-light);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    margin-right: 0.5rem;
}

.dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    border-top: 1px solid var(--border-color);
}

/* ==========================================
   LIST GROUPS
   ========================================== */

.list-group {
    display: flex;
    flex-direction: column;
    padding-left: 0;
    margin-bottom: 0;
}

.list-group-item {
    position: relative;
    display: block;
    padding: 0.75rem 1.25rem;
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
}

.list-group-item:last-child {
    border-bottom: 0;
}

.list-group-flush {
    border-radius: 0;
}

.list-group-flush .list-group-item {
    border-left: 0;
    border-right: 0;
}

/* ==========================================
   BREADCRUMBS
   ========================================== */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    margin-bottom: 0;
    list-style: none;
    font-size: 0.8rem;
}

.breadcrumb-item+.breadcrumb-item {
    padding-left: 0.5rem;
}

.breadcrumb-item+.breadcrumb-item::before {
    display: inline-block;
    padding-right: 0.5rem;
    color: var(--text-muted);
    content: "/";
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--primary);
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

/* ==========================================
   EMPTY STATE
   ========================================== */

.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.35;
}

.empty-state h4 {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* ==========================================
   CUSTOM CONFIRM MODAL
   ========================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease;
    padding: 1rem;
}

.modal-dialog {
    background: var(--bg-white);
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
    animation: modalSlideIn 0.25s ease;
    overflow: hidden;
}

.modal-dialog .modal-header {
    padding: 2rem 2rem 1rem;
    text-align: center;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.modal-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.modal-icon.info {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.modal-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success, #10b981);
}

.modal-dialog .modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 0.5rem;
}

.modal-message {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem 2rem 1.75rem;
    justify-content: center;
}

.modal-actions .btn {
    flex: 1;
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
}

@media (max-width: 400px) {
    .modal-dialog .modal-header {
        padding: 1.5rem 1.25rem 0.75rem;
    }

    .modal-actions {
        flex-direction: column-reverse;
        padding: 1rem 1.25rem 1.5rem;
    }
}

.modal-cancel-btn:hover {
    background-color: var(--bg-light) !important;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ==========================================
   DOCUMENT TEMPLATE EDITOR
   ==========================================
   The editing surface is styled like the printed page (public/css/print.css)
   so the wording is composed at roughly the size and rhythm it will be read
   at. The rules are repeated here rather than sharing that stylesheet: print.css
   styles the whole document — body included — and loading it into the admin
   pages would restyle every screen it touches. */

.doc-editor {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.doc-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem;
    background: var(--bg-light, #f8fafc);
    border-bottom: 1px solid var(--border-color);
}

.doc-tool {
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}

.doc-tool:hover {
    background: #fff;
    border-color: var(--border-color);
}

.doc-tool-sep {
    width: 1px;
    height: 20px;
    margin: 0 0.25rem;
    background: var(--border-color);
}

.doc-editor-surface {
    min-height: 420px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
    background: #fff;
    color: #1f2937;
    font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.55;
    outline: none;
}

.doc-editor-surface:focus { box-shadow: inset 0 0 0 2px rgba(99, 102, 241, 0.25); }

.doc-editor-surface h1 {
    margin: 0 0 1rem;
    font-size: 1.15rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #111827;
}

.doc-editor-surface h2 {
    margin: 1.1rem 0 0.4rem;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #111827;
}

.doc-editor-surface p { margin: 0 0 0.65rem; }

.doc-editor-surface ul,
.doc-editor-surface ol {
    margin: 0 0 0.65rem;
    padding-left: 1.35rem;
}

.doc-editor-surface li { margin-bottom: 0.25rem; }

.doc-editor-surface .doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.9rem 0;
}

.doc-editor-surface .doc-table th,
.doc-editor-surface .doc-table td {
    border: 1px solid #d1d5db;
    padding: 0.45rem 0.6rem;
    text-align: left;
    vertical-align: top;
}

.doc-editor-surface .doc-table th {
    width: 32%;
    background: #f3f4f6;
    font-weight: 600;
}

.doc-editor-surface .doc-center { text-align: center; }

.doc-editor-surface .doc-name {
    margin: 0.4rem 0 0.9rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
}

.doc-editor-surface .doc-signature { margin-top: 1.5rem; max-width: 260px; }
.doc-editor-surface .doc-signature-rule { border-top: 1px solid #111827; margin-bottom: 0.35rem; }
.doc-editor-surface .doc-signature-name { font-weight: 700; color: #111827; }
.doc-editor-surface .doc-signature-title { font-size: 0.85rem; color: var(--text-muted); }

.doc-editor-preview { background: #fcfcfd; }

/* The raw-HTML fallback: what an admin edits when JavaScript is unavailable. */
.doc-source {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.85rem;
}

/* A placeholder chip. Deliberately small — there are a lot of them. */
.doc-chip {
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-light, #f8fafc);
    color: var(--text-main);
    font-size: 0.75rem;
    line-height: 1.4;
    cursor: pointer;
}

.doc-chip:hover {
    background: #fff;
    border-color: var(--primary);
    color: var(--primary);
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {

    .sidebar,
    .topbar,
    .btn,
    .pagination-wrapper {
        display: none !important;
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}