/* =========================================================================
   Parasakthi Enterprises — Redesign Design System
   Implemented on top of Bootstrap 5 without changing app workflow.
   ========================================================================= */

:root {
    /* Surfaces */
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface2: #f2f4f7;
    --surface-trans: rgba(255, 255, 255, 0.78);
    --border: #e8eaef;
    --border-strong: #d7dbe2;

    /* Text */
    --text: #171a21;
    --muted: #5c6472;
    --subtle: #9aa1ad;

    /* Accent (indigo) */
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef0fe;
    --on-accent: #ffffff;
    --ring: rgba(79, 70, 229, 0.20);

    /* Status */
    --success: #16a34a;
    --success-soft: #e7f6ed;
    --success-text: #15803d;
    --danger: #dc2626;
    --danger-soft: #fcebec;
    --danger-text: #b91c1c;
    --danger-border: #f5c9cc;
    --warning: #d97706;
    --warning-soft: #fbf0e1;
    --warning-text: #b45309;
    --info: #2563eb;

    /* Radii & shadows */
    --r: 14px;
    --r-lg: 16px;
    --r-sm: 9px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 6px rgba(16, 24, 40, 0.05);
    --shadow-lg: 0 12px 36px rgba(16, 24, 40, 0.12);

    --sidebar-w: 252px;
}

body.dark-mode {
    --bg: #0b0d12;
    --surface: #13161d;
    --surface2: #1b1f28;
    --surface-trans: rgba(19, 22, 29, 0.78);
    --border: #262b35;
    --border-strong: #343b47;

    --text: #e9ebef;
    --muted: #99a0ac;
    --subtle: #6a717e;

    --accent: #8b85f5;
    --accent-hover: #9d98f7;
    --accent-soft: #211f3d;
    --on-accent: #ffffff;
    --ring: rgba(139, 133, 245, 0.30);

    --success: #34d399;
    --success-soft: #0f2a1d;
    --success-text: #34d399;
    --danger: #f87171;
    --danger-soft: #2e1516;
    --danger-text: #f87171;
    --danger-border: #4a2222;
    --warning: #fbbf24;
    --warning-soft: #2b2110;
    --warning-text: #fbbf24;
    --info: #60a5fa;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.5);
}

/* -------------------------------------------------------------------------
   Base
   ------------------------------------------------------------------------- */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    font-weight: 500;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, color 0.2s ease;
}

@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--subtle); background-clip: content-box; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* -------------------------------------------------------------------------
   App shell
   ------------------------------------------------------------------------- */
#wrapper { display: flex; align-items: stretch; min-height: 100vh; overflow-x: hidden; }

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
    transition: margin-left 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    /* White, not the accent colour: the mark is Parasakthi red, and red on the
       indigo accent is unreadable. White keeps the brand colour true and looks
       the same in both themes. */
    background: #fff;
    /* A hairline so the white badge still reads against the white sidebar in
       light mode; in dark mode it disappears against the badge itself. */
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    padding: 5px;
    box-shadow: var(--shadow);
}
.sidebar-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sidebar-brand-text .brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.02em; line-height: 1.1; color: var(--text); }
.sidebar-brand-text .brand-sub { font-size: 10px; color: var(--muted); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }

.nav-group { margin-bottom: 4px; }
.nav-group-label {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--subtle);
    letter-spacing: 0.09em;
    text-transform: uppercase;
    padding: 14px 10px 6px;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    margin-bottom: 2px;
    border-radius: var(--r-sm);
    color: var(--muted);
    font-weight: 500;
    font-size: 13.5px;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.side-link i { width: 18px; text-align: center; font-size: 14px; color: var(--subtle); transition: color 0.12s ease; }
.side-link:hover { background: var(--surface2); color: var(--text); }
.side-link:hover i { color: var(--text); }

.side-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-link.active i { color: var(--accent); }
.side-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); text-decoration: none; }
.user-chip:hover { background: var(--surface2); }
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex: none;
    text-transform: uppercase;
}
.user-meta { min-width: 0; flex: 1; }
.user-meta .user-name { font-weight: 600; font-size: 13px; line-height: 1.2; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta .user-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.logout-btn {
    width: 30px; height: 30px; border: none; background: transparent; color: var(--subtle);
    cursor: pointer; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center;
    transition: 0.15s;
}
.logout-btn:hover { background: var(--surface2); color: var(--danger); }

/* Page content */
#page-content-wrapper { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Topbar */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    background: var(--surface-trans);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.menu-toggle {
    display: none;
    width: 38px; height: 38px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    border-radius: 10px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.topbar-titles { flex: 1; min-width: 0; }
.topbar-crumb { font-size: 11px; color: var(--subtle); font-weight: 600; letter-spacing: 0.04em; }
.topbar-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
    width: 38px; height: 38px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    border-radius: 10px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    transition: 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* Topbar user dropdown */
.topbar-user { display: flex; align-items: center; gap: 9px; padding: 4px 6px 4px 4px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; color: var(--text); text-decoration: none; cursor: pointer; }
.topbar-user:hover { border-color: var(--border-strong); color: var(--text); }
.topbar-user .user-avatar { width: 30px; height: 30px; font-size: 12px; }
.topbar-user .tu-name { font-size: 13px; font-weight: 600; }

/* Main */
.app-main { flex: 1; padding: 26px 28px; width: 100%; }
.app-main > .container-fluid { padding-left: 0 !important; padding-right: 0 !important; max-width: 1180px; margin: 0 auto; }

/* -------------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg) !important;
    box-shadow: var(--shadow);
    color: var(--text);
    animation: pop 0.3s ease;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    color: var(--text);
    font-weight: 700;
}
.card-header h6, .card-header .text-primary { color: var(--text) !important; }
.card-body { color: var(--text); }
.card-footer { background: transparent; border-top: 1px solid var(--border); color: var(--muted); }

/* -------------------------------------------------------------------------
   Dashboard stat cards (.info-card used in home.html)
   ------------------------------------------------------------------------- */
.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    color: var(--text);
    gap: 14px;
}
.info-card h3 { font-weight: 800; letter-spacing: -0.02em; margin-bottom: 2px; color: var(--text); }
.info-card p { color: var(--muted); font-weight: 500; }
.info-card .icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex: none;
}
.info-card-primary .icon { background: var(--accent-soft); color: var(--accent); }
.info-card-success .icon { background: var(--success-soft); color: var(--success-text); }
.info-card-info .icon { background: var(--accent-soft); color: var(--info); }
.info-card-warning .icon { background: var(--warning-soft); color: var(--warning-text); }

/* -------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------- */
.table {
    width: 100%;
    color: var(--text);
    vertical-align: middle;
    border-color: var(--border);
    margin-bottom: 0;
}
.table > :not(caption) > * > * { background: transparent; }
.table thead th {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.table tbody td, .table tbody th {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-weight: 500;
    vertical-align: middle;
}
.table tbody tr { transition: background-color 0.15s ease; }
.table-hover tbody tr:hover { background-color: var(--surface2); }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: none; }

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */
.btn {
    border-radius: var(--r-sm);
    padding: 0.55rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid transparent;
    transition: all 0.15s ease-in-out;
}
.btn-lg { padding: 0.8rem 1.25rem; border-radius: var(--r); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); }
.btn-primary:hover, .btn-primary:focus { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }

.btn-info { background: var(--info); border-color: var(--info); color: #fff; }
.btn-info:hover, .btn-info:focus { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.94); color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.94); color: #fff; }

.btn-secondary { background: var(--surface2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--border); border-color: var(--border-strong); color: var(--text); }

.btn-outline-primary { color: var(--accent); border-color: var(--border-strong); background: var(--surface); }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(0.94); color: #fff; }

.btn:focus-visible { box-shadow: 0 0 0 4px var(--ring); }

/* -------------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------------- */
.form-label { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 7px; }

.form-control,
.form-select {
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 0.6rem 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}
.form-control::placeholder { color: var(--subtle); }
.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--ring);
    background: var(--surface);
    color: var(--text);
}
.form-control:disabled, .form-select:disabled { background: var(--surface2); color: var(--muted); }
.form-select option { background: var(--surface); color: var(--text); }

/* keep Bootstrap floating labels working */
.form-floating > label { color: var(--muted); }
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label { color: var(--muted); }

/* -------------------------------------------------------------------------
   Badges
   ------------------------------------------------------------------------- */
.badge {
    font-weight: 600;
    padding: 0.4em 0.65em;
    border-radius: 999px;
    font-size: 0.72rem;
}
.badge.bg-success { background: var(--success-soft) !important; color: var(--success-text) !important; }
.badge.bg-danger { background: var(--danger-soft) !important; color: var(--danger-text) !important; }
.badge.bg-warning { background: var(--warning-soft) !important; color: var(--warning-text) !important; }
.badge.bg-info { background: var(--accent-soft) !important; color: var(--info) !important; }
.badge.bg-primary { background: var(--accent-soft) !important; color: var(--accent) !important; }
.badge.bg-secondary { background: var(--surface2) !important; color: var(--muted) !important; }

/* -------------------------------------------------------------------------
   Alerts
   ------------------------------------------------------------------------- */
.alert {
    border-radius: var(--r-sm);
    padding: 0.85rem 1.1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-weight: 500;
    animation: slideIn 0.25s ease;
}
.alert-success { color: var(--success-text); background: var(--success-soft); border-color: var(--success); }
.alert-danger, .alert-error { color: var(--danger-text); background: var(--danger-soft); border-color: var(--danger-border); }
.alert-warning { color: var(--warning-text); background: var(--warning-soft); border-color: var(--warning); }
.alert-info { color: var(--info); background: var(--accent-soft); border-color: var(--info); }
.alert .btn-close { filter: none; }
body.dark-mode .alert .btn-close { filter: invert(1) grayscale(1) brightness(2); }

/* -------------------------------------------------------------------------
   Dropdown menu (topbar user)
   ------------------------------------------------------------------------- */
.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    padding: 6px;
}
.dropdown-item { color: var(--text); border-radius: var(--r-sm); padding: 8px 12px; font-weight: 500; font-size: 13.5px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface2); color: var(--text); }
.dropdown-divider { border-color: var(--border); }

/* -------------------------------------------------------------------------
   Headings / misc
   ------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
.text-primary { color: var(--accent) !important; }
.text-muted { color: var(--muted) !important; }
.shadow-sm, .shadow-lg { box-shadow: var(--shadow) !important; }
hr { border-color: var(--border); }

/* DataTables (graceful if present) */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    padding: 0.4rem 0.6rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--muted) !important;
    border-radius: var(--r-sm);
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--accent) !important;
    color: var(--on-accent) !important;
    border-color: var(--accent) !important;
}

/* -------------------------------------------------------------------------
   Auth pages (login / register)
   ------------------------------------------------------------------------- */
.login-page,
.register-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(120% 90% at 80% 0%, var(--accent-soft) 0%, var(--bg) 55%);
    position: relative;
    overflow: hidden;
}
.login-page::before,
.register-page::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0.5;
    pointer-events: none;
}
.login-page .container,
.register-page .container { position: relative; z-index: 1; }

.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .sidebar-brand-logo { width: 46px; height: 46px; border-radius: 13px; font-size: 20px; box-shadow: var(--shadow-lg); }
.auth-brand .brand-name { font-size: 17px; }

.login-page .card,
.register-page .card {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    background: var(--surface);
    animation: pop 0.35s ease;
}
.login-page .card-header,
.register-page .card-header {
    background: transparent;
    border-bottom: none;
    padding-bottom: 0;
}
.login-page .card-header h3,
.register-page .card-header h3 { font-size: 22px; font-weight: 700; margin-bottom: 4px !important; }
.login-page .card-header h4,
.register-page .card-header h4 { font-size: 14px; font-weight: 500; color: var(--muted); margin-top: 0 !important; }
.login-page .card-footer,
.register-page .card-footer { background: transparent; border-top: 1px solid var(--border); }

/* -------------------------------------------------------------------------
   Responsive sidebar (mobile)
   ------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .menu-toggle { display: flex; }
    .app-sidebar {
        position: fixed;
        left: 0; top: 0;
        margin-left: calc(-1 * var(--sidebar-w) - 4px);
        box-shadow: var(--shadow-lg);
    }
    #wrapper.toggled .app-sidebar { margin-left: 0; }
    #wrapper.toggled::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1035;
    }
    .app-main { padding: 18px 16px; }
}

/* ---------------------------------------------------------------
   Responsive fixes found in the pre-deployment browser audit
   --------------------------------------------------------------- */

/* List page toolbar: "Add" on the left, search on the right, stacking on a
   phone. It used to be a plain d-flex, which squeezed the search box down to
   about three characters wide rather than wrapping. */
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.list-toolbar > .btn { flex: 0 0 auto; }
.list-search {
    display: flex;
    gap: 0.5rem;
    flex: 1 1 18rem;
    justify-content: flex-end;
    min-width: 0;
}
.list-search .form-control { min-width: 0; max-width: 22rem; }
.list-search .btn { flex: 0 0 auto; white-space: nowrap; }

@media (max-width: 575.98px) {
    .list-toolbar { flex-direction: column; align-items: stretch; }
    .list-toolbar > .btn { width: 100%; }
    .list-search { flex-basis: auto; }
    .list-search .form-control { flex: 1 1 auto; max-width: none; }
}

/* Table cells wrapped mid-value on narrow screens -- dates broke across two
   lines and DC numbers split at the hyphen. The wrapper already scrolls
   horizontally, so let it, rather than mangling the values. */
.table-responsive > .table > thead > tr > th,
.table-responsive > .table > tbody > tr > td,
.table-responsive > .table > tbody > tr > th { white-space: nowrap; }

/* Give the horizontal scroll some momentum on touch devices. */
.table-responsive { -webkit-overflow-scrolling: touch; }

/* Dashboard tiles sat at different heights because their labels are different
   lengths. Make every tile in the row match the tallest. */
.info-card { height: 100%; }

/* ---------------------------------------------------------------
   Phone layout (<= 767px)

   First attempt gave every field its own line with a big uppercase label,
   which turned one outbound record into a full screen: the labels shouted
   louder than the data and ten records meant ten screens. Now the fields sit
   two-per-line in a compact grid, the label is a quiet caption above its
   value, and tables whose values are short keep being tables.
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {

    /* ---- reclaim the width the gutters were eating ----
       A 402px phone was giving the content only 288px: container px-4 (48px)
       plus the card's own p-4 (48px) plus card-body padding. A quarter of the
       screen spent on whitespace is why nothing fitted. */
    .container-fluid { padding-left: 12px !important; padding-right: 12px !important; }
    #page-content-wrapper .card { border-radius: 12px; }
    #page-content-wrapper .card.p-4 { padding: 14px !important; }
    #page-content-wrapper .card-body { padding: 12px !important; }
    #page-content-wrapper .card-header { padding: 12px 14px !important; }
    #page-content-wrapper .row.my-5 { margin-top: 1rem !important; margin-bottom: 1rem !important; }
    #page-content-wrapper .row.my-4 { margin-top: 0.75rem !important; margin-bottom: 0.75rem !important; }
    #page-content-wrapper h3.fs-4 { font-size: 1.2rem !important; }

    /* The row number and the audit timestamp are not worth any of a phone's
       width, in either mode. The date the load moved is what matters, not the
       second the row was written. */
    .table .cell-low-value { display: none !important; }

    /* ---- tables that fit: stay tables, just tighter ---- */
    .table.fits-as-table { font-size: 0.85rem; }
    .table.fits-as-table > thead > tr > th { font-size: 0.64rem; padding: 8px 4px; }
    .table.fits-as-table > tbody > tr > td,
    .table.fits-as-table > tbody > tr > th { padding: 9px 4px; }
    .table.fits-as-table .badge { font-size: 0.66rem; padding: 0.3em 0.5em; }

    /* ---- tables too wide to fit: compact cards ---- */
    .table-responsive.has-stacked-table { overflow-x: visible; }

    .table.stacks-on-mobile,
    .table.stacks-on-mobile tbody,
    .table.stacks-on-mobile tr { display: block; width: auto; }

    .table.stacks-on-mobile thead { display: none; }

    .table.stacks-on-mobile tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 12px 14px;
        margin-bottom: 10px;
        box-shadow: var(--shadow);
        /* two fields per line instead of one */
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 14px;
        align-items: start;
    }

    .table.stacks-on-mobile td,
    .table.stacks-on-mobile tbody th {
        display: block;
        border: none !important;
        padding: 0 !important;
        white-space: normal !important;
        text-align: left;
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--text);
        min-width: 0;
        overflow-wrap: anywhere;
    }

    /* The label is a caption, not a heading competing with the value. */
    .table.stacks-on-mobile td::before,
    .table.stacks-on-mobile tbody th::before {
        content: attr(data-label);
        display: block;
        font-weight: 500;
        color: var(--muted);
        font-size: 0.66rem;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        margin-bottom: 1px;
    }

    /* Buttons span the card and sit at its foot. */
    .table.stacks-on-mobile .cell-actions {
        grid-column: 1 / -1;
        display: flex;
        gap: 8px;
        margin-top: 2px;
        padding-top: 10px !important;
        border-top: 1px solid var(--border) !important;
    }
    .table.stacks-on-mobile .cell-actions::before { content: none; }
    .table.stacks-on-mobile .cell-actions > *,
    .table.stacks-on-mobile .cell-actions form { flex: 1 1 0; margin: 0 !important; }
    .table.stacks-on-mobile .cell-actions .btn {
        width: 100%;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* ---- dashboard ---- */
    /* Four full-width tiles pushed everything else off the screen. Two up
       lets the figures be compared without scrolling. */
    .info-card { padding: 14px !important; height: 100%; }
    .info-card h3 { font-size: 1.35rem; }
    .info-card p { font-size: 0.74rem !important; line-height: 1.2; }
    .info-card .icon { width: 32px; height: 32px; font-size: 13px; }

    .quick-action { padding: 1rem !important; }
    .quick-action .fa-2x { font-size: 1.35em; }
    .quick-action .fs-3 { font-size: 1.05rem !important; }

    /* Links sitting at 17px are hard to hit accurately. */
    .card-footer .small a { display: inline-block; padding: 8px 4px; }
}
