/* =====================================================
   LOLIK Portal — unified design system
   ===================================================== */

/* Color tokens used by JS (charts) and CSS */
:root {
    --c-blue: #2f6cf3;
    --c-blue-dark: #225acc;
    --c-green: #21c97a;
    --c-yellow: #efb43d;
    --c-red: #ed5a61;
    --c-purple: #8166f0;
    --c-gray: #adb5bd;
    --c-teal: #1ec0c0;

    --c-text: #172b4d;
    --c-text-muted: #5e6c84;     /* darker than Bootstrap's #6c757d for readability */
    --c-text-faint: #7a869a;
    --c-bg-page: #f4f5f7;
    --c-bg-card: #ffffff;
    --c-bg-card-alt: #fafbfc;
    --c-border: #c1c7d0;
    --c-border-soft: #dfe1e6;
    --c-border-faint: #ebecf0;

    --portal-nav-h: 92px;        /* fixed nav height — pages clear this */
}

/* =====================================================
   Page wrapper — every authenticated portal page
   ===================================================== */
.portal-page {
    background: var(--c-bg-page);
    min-height: 100vh;
    padding-top: calc(var(--portal-nav-h) + 16px);
    padding-bottom: 60px;
    color: var(--c-text);
}
.portal-page .container,
.portal-page .container-fluid {
    max-width: 1280px;
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
}
.portal-page .container-narrow { max-width: 980px; margin: 0 auto; }

.portal-page h1,
.portal-page h2,
.portal-page h3,
.portal-page h4,
.portal-page h5 { color: var(--c-text); }
.portal-page h2.page-title { font-size: 1.55rem; font-weight: 600; margin: 0 0 6px 0; line-height: 1.25; }
.portal-page p.page-sub,
.portal-page .lead-sub { color: var(--c-text-muted); font-size: 0.92rem; margin-bottom: 22px; }

.portal-breadcrumb { color: var(--c-text-muted); font-size: 0.85rem; margin-bottom: 4px; }
.portal-breadcrumb a { color: var(--c-text-muted); text-decoration: none; }
.portal-breadcrumb a:hover { color: var(--c-blue); text-decoration: underline; }

.portal-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
}

/* =====================================================
   Stat tiles (dashboards)
   ===================================================== */
.stat-tile {
    border-radius: 12px;
    padding: 24px 22px;
    color: #fff;
    text-align: center;
    height: 100%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.stat-tile .stat-num { font-size: 2.2rem; font-weight: 700; line-height: 1.1; margin: 0; }
.stat-tile .stat-label { font-size: 0.92rem; margin-top: 4px; opacity: 0.95; }
.stat-blue   { background: linear-gradient(135deg, #2f6cf3 0%, #3b7bff 100%); }
.stat-green  { background: linear-gradient(135deg, #1bb56b 0%, #21c97a 100%); }
.stat-yellow { background: linear-gradient(135deg, #d9a325 0%, #efb43d 100%); }
.stat-red    { background: linear-gradient(135deg, #e0464d 0%, #ed5a61 100%); }
.stat-purple { background: linear-gradient(135deg, #6c4ee0 0%, #8166f0 100%); }
.stat-teal   { background: linear-gradient(135deg, #16a3a3 0%, #1ec0c0 100%); }

/* =====================================================
   Cards / Panels
   ===================================================== */
.portal-panel,
.portal-card {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 22px 24px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    margin-bottom: 16px;
}
.portal-panel.shade-alt,
.portal-card.shade-alt { background: var(--c-bg-card-alt); }
.portal-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--c-border-faint);
}
.portal-panel-header h5 { margin: 0; font-weight: 600; font-size: 1.05rem; color: var(--c-text); }
.portal-panel-header a { color: var(--c-blue); font-size: 0.85rem; text-decoration: none; }
.portal-panel-header a:hover { text-decoration: underline; }
.portal-panel-flush { padding: 0; overflow: hidden; }
.portal-panel-flush .portal-panel-header { padding: 18px 22px 12px; margin: 0; }
.portal-panel-flush table { margin: 0; }

/* Simple data row (used in dashboards) */
.portal-row { padding: 12px 0; border-bottom: 1px solid var(--c-border-faint); }
.portal-row:last-child { border-bottom: none; }
.portal-row .row-title { font-weight: 500; font-size: 0.95rem; color: var(--c-text); }
.portal-row .row-meta  { font-size: 0.82rem; color: var(--c-text-muted); }
.portal-row .progress { height: 6px; margin-top: 8px; background: #eef0f5; border-radius: 4px; }
.portal-row .progress-bar { background: var(--c-green); border-radius: 4px; }

/* =====================================================
   Forms — readable labels + sized inputs
   ===================================================== */
.portal-page label,
.portal-page .form-label {
    color: var(--c-text);
    font-weight: 500;
    font-size: 0.88rem;
    margin-bottom: 6px;
    display: block;
}
/* Uppercase variant — used in sidebars / Jira-style forms */
.portal-page .form-label.upper,
.portal-page .upper-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.72rem;
    color: var(--c-text-muted);
    font-weight: 600;
}

/* All inputs in portal pages: readable size, decent height */
.portal-page .form-control,
.portal-page .form-select {
    color: var(--c-text);
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 4px;
    font-size: 0.92rem;
    line-height: 1.4;
    padding: 7px 10px;
    min-height: 38px;
}
.portal-page .form-control-sm,
.portal-page .form-select-sm { font-size: 0.88rem; padding: 6px 9px; min-height: 34px; }
.portal-page textarea.form-control,
.portal-page textarea.form-control-sm { min-height: auto; height: auto; }
.portal-page .form-control:focus,
.portal-page .form-select:focus {
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(47,108,243,0.15);
}
.portal-page .form-text { color: var(--c-text-muted); font-size: 0.78rem; }
.portal-page .text-danger.small { font-size: 0.78rem; }

/* Section blocks for forms */
.portal-section {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 20px 22px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.portal-section.shade-alt { background: var(--c-bg-card-alt); }
.portal-section h5.sec-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: var(--c-text);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--c-border-faint);
}

/* Form action footer */
.portal-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 14px;
}

/* Mini buttons — used in toolbars and form footers */
.btn-mini {
    background: #f1f2f5;
    border: 1px solid var(--c-border);
    color: #42526e;
    font-size: 0.82rem;
    padding: 6px 14px;
    line-height: 1.4;
    border-radius: 4px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-mini:hover { background: #e6e7ec; color: #42526e; }
.btn-mini.primary { background: var(--c-blue); border-color: var(--c-blue); color: #fff; }
.btn-mini.primary:hover { background: var(--c-blue-dark); color: #fff; }
.btn-mini.danger { background: #fff; border-color: var(--c-red); color: var(--c-red); }
.btn-mini.danger:hover { background: var(--c-red); color: #fff; }

/* =====================================================
   Tables
   ===================================================== */
.portal-page .table {
    color: var(--c-text);
    font-size: 0.9rem;
    margin-bottom: 0;
}
.portal-page .table thead th {
    background: var(--c-bg-card-alt);
    border-bottom: 1px solid var(--c-border);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--c-text-muted);
    padding: 10px 12px;
}
.portal-page .table tbody td { padding: 12px; vertical-align: middle; border-bottom: 1px solid var(--c-border-faint); color: var(--c-text); }
.portal-page .table-hover tbody tr:hover { background: #f5f7fa; }

/* =====================================================
   Charts + status legends
   ===================================================== */
.chart-wrap { position: relative; height: 220px; width: 100%; }
.chart-wrap-tall { position: relative; height: 280px; width: 100%; }

.status-legend { list-style: none; padding: 0; margin: 0; }
.status-legend li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;                 /* keeps a clear visual gap between the label and the count even on narrow columns */
    padding: 6px 0;
    font-size: 0.9rem;
    color: var(--c-text);
}
.status-legend li > span { flex: 1 1 auto; min-width: 0; }
.status-legend li > strong { flex: 0 0 auto; padding-left: 16px; min-width: 40px; text-align: right; }
.status-legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 10px; vertical-align: middle; }

/* Workload row (PMO dashboard) */
.workload-row { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--c-border-faint); }
.workload-row:last-child { border-bottom: none; }
.workload-row .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--c-blue); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; margin-right: 12px; flex-shrink: 0;
}
.workload-row .who { flex: 1; font-size: 0.95rem; color: var(--c-text); }
.workload-row .breakdown { font-size: 0.85rem; color: var(--c-text-muted); }
.workload-row .breakdown .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 6px 0 12px; vertical-align: middle; }

/* =====================================================
   Kanban board
   ===================================================== */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.kanban-column { flex: 1 1 0; min-width: 260px; max-width: 320px; background: #f1f2f5; border-radius: 10px; border: 1px solid var(--c-border-soft); display: flex; flex-direction: column; }
.kanban-column-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--c-border-soft); background: #fff; border-top-left-radius: 10px; border-top-right-radius: 10px; }
.kanban-column-header .col-title { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; color: var(--c-text); }
.kanban-column-header .col-dot { width: 10px; height: 10px; border-radius: 50%; }
.kanban-column-header .col-count { background: #e6e7ec; color: #495057; border-radius: 10px; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; }
.kanban-column-body { padding: 10px; flex: 1; min-height: 120px; display: flex; flex-direction: column; gap: 8px; }
.kanban-task { background: #fff; border: 1px solid var(--c-border-soft); border-radius: 8px; padding: 10px 12px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,0.04); transition: box-shadow 0.1s ease; user-select: none; color: var(--c-text); }
.kanban-task:hover { box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.kanban-task.is-overdue { border-color: var(--c-red); border-left: 4px solid var(--c-red); }
.kanban-task .kt-meta-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.kanban-task .kt-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem; color: var(--c-text-muted); font-weight: 600; }
.kanban-task .kt-priority { font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 3px; }
.kanban-task .kt-pri-Critical { background: #fde2e4; color: #b1242a; }
.kanban-task .kt-pri-High     { background: #fff1d6; color: #8a5a06; }
.kanban-task .kt-pri-Medium   { background: #e3edff; color: #1c4ec4; }
.kanban-task .kt-pri-Low      { background: #e6e7ec; color: #495057; }
.kanban-task .kt-title { font-weight: 500; font-size: 0.92rem; line-height: 1.3; margin: 4px 0 8px 0; color: var(--c-text); }
.kanban-task .kt-meta-bot { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: var(--c-text-muted); }
.kanban-task .kt-assignee-avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--c-blue); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 700; margin-right: 6px; vertical-align: middle; }
.kanban-task .kt-due.is-overdue { color: var(--c-red); font-weight: 600; }
.kanban-task.sortable-ghost { opacity: 0.4; background: #e7f0ff; }
.kanban-task.sortable-chosen { cursor: grabbing; }
.kanban-task.sortable-drag { transform: rotate(1deg); }
.kanban-column-body.kanban-drop-active { background: #e7f0ff; border-radius: 6px; }
.kanban-empty { color: var(--c-text-faint); font-size: 0.85rem; text-align: center; padding: 20px 8px; font-style: italic; }

/* =====================================================
   Badges (consistent + readable)
   ===================================================== */
.portal-page .badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

/* =====================================================
   Notification bell + dropdown (top nav)
   ===================================================== */
#notif-wrap .dropdown-menu {
    min-width: 320px;
    max-width: 340px;
    max-height: 440px;
    overflow-y: auto;
    padding: 0;
    border: 1px solid var(--c-border-soft);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(23, 43, 77, 0.12);
    color: var(--c-text);
    z-index: 2000;
}
#notif-wrap .dropdown-menu a { color: var(--c-text); text-decoration: none; }
#notif-wrap .dropdown-menu a:hover { background: #f7f8fa; }
#notifBadge { font-weight: 700; min-width: 18px; text-align: center; }
#notifBell { color: inherit; }

/* Single notification row — minimal, subtle */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-border-faint);
    transition: background 0.1s ease;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #fafbff; }
.notif-dot {
    width: 7px;
    height: 7px;
    background: var(--c-blue);
    border-radius: 50%;
    margin-top: 7px;
    flex-shrink: 0;
}
.notif-item:not(.unread) { padding-left: 21px; }
.notif-body { flex: 1; min-width: 0; }
.notif-title {
    font-size: 0.85rem;
    line-height: 1.35;
    color: var(--c-text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.notif-item.unread .notif-title { font-weight: 600; }
.notif-time {
    font-size: 0.72rem;
    color: var(--c-text-muted);
    margin-top: 3px;
    letter-spacing: 0.01em;
}

/* =====================================================
   Activity / Comments thread
   ===================================================== */
.activity-tabs { display: flex; align-items: center; gap: 4px; margin: 0 0 14px 0; padding-bottom: 8px; border-bottom: 1px solid var(--c-border-faint); flex-wrap: wrap; }
.activity-tabs .label { font-weight: 600; margin-right: 8px; color: var(--c-text); font-size: 0.85rem; }
.activity-tabs .tab { background: transparent; border: none; padding: 4px 10px; border-radius: 4px; font-size: 0.82rem; color: #42526e; cursor: pointer; }
.activity-tabs .tab:hover { background: #e6e7ec; }
.activity-tabs .tab.active { background: var(--c-text); color: #fff; }
.activity-tabs .sort { margin-left: auto; font-size: 0.78rem; color: var(--c-text-muted); }

.add-comment-row { display: flex; gap: 12px; margin: 0 0 18px 0; align-items: flex-start; padding: 12px; background: #fff; border: 1px solid var(--c-border-soft); border-radius: 6px; }
.add-comment-row textarea { flex: 1; }
.comment-row { display: flex; gap: 12px; padding: 14px 12px; border-bottom: 1px solid var(--c-border-faint); }
.comment-row:nth-child(even) { background: #f7f8fa; }
.comment-row.is-audit { background: #e9f2ff; border-left: 3px solid var(--c-blue); border-bottom: none; margin-bottom: 8px; border-radius: 4px; padding: 12px 12px 12px 14px; }
.comment-row .avatar-circle { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.78rem; flex-shrink: 0; background: var(--c-purple); }
.comment-row.is-audit .avatar-circle { background: var(--c-blue); }
.comment-row .comment-meta { color: var(--c-text-muted); font-size: 0.78rem; margin-bottom: 2px; }
.comment-row .comment-name { font-weight: 600; color: var(--c-text); margin-bottom: 6px; font-size: 0.92rem; }
.comment-row .comment-body { color: var(--c-text); white-space: pre-wrap; line-height: 1.5; font-size: 0.92rem; }

.attachment-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.attachment-image { max-width: 200px; max-height: 200px; border: 1px solid var(--c-border); border-radius: 6px; cursor: pointer; }
.attachment-file { display: inline-flex; align-items: center; background: #f1f2f5; border: 1px solid var(--c-border); border-radius: 6px; padding: 7px 11px; color: var(--c-text); text-decoration: none; font-size: 0.85rem; }
.attachment-file:hover { background: #e6e7ec; color: var(--c-text); }

/* Sidebar sections (Jira-style task detail) */
.sidebar-section { background: #fff; border: 1px solid var(--c-border); border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.sidebar-section.shade-alt { background: var(--c-bg-card-alt); }
.sidebar-section h6 { font-size: 0.95rem; font-weight: 600; margin: 0 0 10px 0; color: var(--c-text); padding-bottom: 6px; border-bottom: 1px solid var(--c-border-faint); }
.sidebar-section dl { margin: 0; font-size: 0.88rem; }
.sidebar-section dt { color: var(--c-text-muted); font-weight: 600; padding: 8px 0 2px 0; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.sidebar-section dd { margin: 0 0 4px 0; color: var(--c-text); }

.timestamps-block { color: var(--c-text-muted); font-size: 0.83rem; padding: 8px 12px; background: var(--c-bg-card-alt); border: 1px solid var(--c-border); border-radius: 6px; }
.timestamps-block div { margin: 3px 0; }

.approval-banner { background: #deebff; border: 1px solid var(--c-blue); border-radius: 6px; padding: 14px 16px; margin: 0 0 16px 0; }
.approval-banner h5 { margin: 0 0 6px 0; font-size: 1rem; color: #0747a6; }

/* =====================================================
   Global readability overrides — apply everywhere on portal pages
   ===================================================== */
.portal-page .text-muted { color: var(--c-text-muted) !important; }
.portal-page small.text-muted,
.portal-page .small.text-muted { color: var(--c-text-muted) !important; }

/* Dropdown menus globally — ensure they're never invisible */
.dropdown-menu { color: var(--c-text); border-color: var(--c-border); }
.dropdown-menu .dropdown-item { color: var(--c-text); }
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus { background: #f1f2f5; color: var(--c-text); }

/* Alerts (TempData banners) need to layer below the bell dropdown */
.alert { z-index: 1; }

/* When pages use ad-hoc inline `style="background:#f5f6f8"`, normalize the same colour */
[style*="background:#f5f6f8"], [style*="background: #f5f6f8"] { background: var(--c-bg-page) !important; }

/* Body fallback so nothing looks broken if a page omits .portal-page */
body { color: var(--c-text); }

/* =====================================================
   Mobile / responsive — tablets and phones
   ===================================================== */

/* Tablets and below (≤992px) — navbar already collapses here */
@media (max-width: 992px) {
    .portal-page .container,
    .portal-page .container-fluid {
        padding-left: 18px;
        padding-right: 18px;
    }
    .portal-page-header {
        align-items: flex-start;
        margin-bottom: 18px;
    }
    /* Sidebar dl rows in task detail get tight on tablets */
    .sidebar-section dl { font-size: 0.85rem; }
}

/* Phones (≤768px) — main mobile breakpoint */
@media (max-width: 768px) {
    /* iOS zoom prevention: inputs need 16px font-size */
    .portal-page .form-control,
    .portal-page .form-select,
    .portal-page input,
    .portal-page textarea,
    .portal-page select {
        font-size: 16px;
    }

    .portal-page {
        padding-top: calc(var(--portal-nav-h) + 8px);
        padding-bottom: 40px;
    }
    .portal-page .container,
    .portal-page .container-fluid,
    .portal-page .container-narrow {
        padding-left: 14px;
        padding-right: 14px;
        max-width: 100%;
    }

    /* Page header — let title and actions stack cleanly */
    .portal-page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        margin-bottom: 16px;
    }
    .portal-page-header > * { width: 100%; }
    .portal-page h2.page-title { font-size: 1.3rem; }
    .portal-page p.page-sub,
    .portal-page .lead-sub { font-size: 0.88rem; margin-bottom: 14px; }
    .portal-breadcrumb { font-size: 0.8rem; }

    /* Sections / panels / cards — tighter padding so content has room */
    .portal-section,
    .portal-panel,
    .portal-card {
        padding: 14px 14px;
        margin-bottom: 12px;
        border-radius: 6px;
    }
    .portal-section h5.sec-title { font-size: 0.95rem; margin-bottom: 12px; }
    .portal-panel-flush .portal-panel-header { padding: 14px 14px 10px; }

    /* Stat tiles — slightly smaller numbers on phones */
    .stat-tile { padding: 18px 16px; border-radius: 10px; }
    .stat-tile .stat-num { font-size: 1.8rem; }
    .stat-tile .stat-label { font-size: 0.85rem; }

    /* Tables — wrap any portal table so it scrolls horizontally instead of
       breaking the layout. Bootstrap's `.table-responsive` on the wrapper
       does this for marked-up tables; this catches the rest. */
    .portal-panel,
    .portal-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .portal-panel-flush { overflow-x: auto; }
    .portal-page .table { font-size: 0.85rem; }
    .portal-page .table thead th { padding: 8px 10px; font-size: 0.7rem; }
    .portal-page .table tbody td { padding: 9px 10px; }

    /* Row-action chip groups — let them wrap below the row content if needed */
    .portal-page .table td .d-inline-flex,
    .portal-page .table td > div { flex-wrap: wrap; }
    .row-action { white-space: nowrap; }

    /* Mini buttons — slightly tighter, allow wrapping */
    .btn-mini { padding: 6px 11px; font-size: 0.8rem; }
    .portal-form-actions { flex-wrap: wrap; }
    .portal-form-actions .btn-mini { flex: 1 1 auto; justify-content: center; }

    /* Form labels closer to inputs */
    .portal-page label,
    .portal-page .form-label { margin-bottom: 4px; font-size: 0.85rem; }

    /* Sidebar section (Jira-style task detail) — drop below content on phones */
    .sidebar-section { padding: 12px 14px; }

    /* Notification dropdown — keep on-screen */
    #notif-wrap .dropdown-menu {
        min-width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        right: 12px !important;
        left: auto !important;
    }

    /* Activity / comment thread spacing */
    .activity-tabs { gap: 2px; }
    .activity-tabs .tab { padding: 4px 8px; font-size: 0.78rem; }
    .add-comment-row { padding: 10px; gap: 10px; }
    .comment-row { padding: 10px 8px; gap: 10px; }
    .comment-row .avatar-circle { width: 28px; height: 28px; font-size: 0.7rem; }
    .comment-row.is-audit { padding: 10px; }

    /* Workload row tightening */
    .workload-row { flex-wrap: wrap; padding: 10px 0; }
    .workload-row .who { flex: 1 1 auto; min-width: 0; }
    .workload-row .breakdown { font-size: 0.8rem; flex-basis: 100%; padding-left: 48px; margin-top: 4px; }

    /* Kanban — keep the horizontal-scroll behavior, narrow columns */
    .kanban-board { gap: 12px; padding-bottom: 12px; }
    .kanban-column { min-width: 240px; max-width: 280px; }
    .kanban-column-header { padding: 10px 12px; }
    .kanban-task { padding: 9px 11px; }

    /* Lead meta table — narrower label column on phones */
    .lead-meta-table th { width: 110px; padding-right: 10px; }

    /* Make image attachments fit the card */
    .attachment-image { max-width: 140px; max-height: 140px; }

    /* Modals and dropdowns shouldn't overflow */
    .modal-dialog { margin: 12px; }
    .dropdown-menu { max-width: calc(100vw - 24px); }
}

/* Small phones (≤480px) — extra tightening */
@media (max-width: 480px) {
    .portal-page .container,
    .portal-page .container-fluid,
    .portal-page .container-narrow {
        padding-left: 10px;
        padding-right: 10px;
    }
    .portal-section,
    .portal-panel,
    .portal-card { padding: 12px 12px; border-radius: 5px; }
    .portal-page h2.page-title { font-size: 1.2rem; }
    .stat-tile { padding: 16px 12px; }
    .stat-tile .stat-num { font-size: 1.6rem; }
    .btn-mini { padding: 5px 10px; font-size: 0.78rem; }
    .lead-meta-table th { width: 95px; }
    .kanban-column { min-width: 220px; max-width: 260px; }
}
