/* Prevent phantom horizontal scroll app-wide (100vw/scrollbar overflow, full-bleed
   bars, etc.). Root-level so it never breaks position:sticky/fixed. Local horizontal
   scroll containers (overflow-x:auto) still work. */
html { overflow-x: hidden; }

:root {
    /* CLLO Light (default) — warm soft ground, amber/yellow brand */
    --bg-color: #faf7f2;
    --bg-tint: rgba(255, 255, 255, 0.55);
    --card-bg: rgba(255, 255, 255, 0.65);
    --card-bg-strong: rgba(255, 255, 255, 0.92);
    --primary-color: #ff9800;
    --primary-color-rgb: 255, 152, 0;
    --primary-soft: #ffb74d;
    --primary-deep: #f57c00;
    --accent-yellow: #ffeb3b;
    --accent-yellow-rgb: 255, 235, 59;
    --brand-gradient: linear-gradient(135deg, #ff9800 0%, #ffc107 50%, #ffeb3b 100%);
    --secondary-color: #d32f2f;
    --accent-blue: #1976d2;
    --text-color: #1a1410;
    --text-muted: #6b6052;
    --border-color: rgba(26, 20, 16, 0.06);
    --border-strong: rgba(26, 20, 16, 0.14);
    --error-color: #d32f2f;
    --success-color: #2e7d32;
    --warning-color: #f57c00;
    --font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    --shadow-premium: 0 1px 2px rgba(26, 20, 16, 0.04), 0 8px 24px rgba(26, 20, 16, 0.05);
    --header-bg: rgba(255, 251, 245, 0.85);
    --input-bg: rgba(255, 255, 255, 0.8);
}

[data-theme='dark'] {
    /* CLLO Dark — warm graphite with amber accents */
    --bg-color: #14110d;
    --bg-tint: rgba(255, 255, 255, 0.02);
    --card-bg: rgba(255, 255, 255, 0.04);
    --card-bg-strong: rgba(255, 255, 255, 0.07);
    --primary-color: #ffa726;
    --primary-color-rgb: 255, 167, 38;
    --primary-soft: #ffcc80;
    --primary-deep: #fb8c00;
    --accent-yellow: #fdd835;
    --accent-yellow-rgb: 253, 216, 53;
    --brand-gradient: linear-gradient(135deg, #ffa726 0%, #ffca28 50%, #fdd835 100%);
    --secondary-color: #ef5350;
    --accent-blue: #42a5f5;
    --text-color: #f5ede2;
    --text-muted: #a89c8a;
    --border-color: rgba(255, 235, 200, 0.08);
    --border-strong: rgba(255, 235, 200, 0.14);
    --error-color: #ef5350;
    --success-color: #66bb6a;
    --warning-color: #ffa726;
    --shadow-premium: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.28);
    --header-bg: rgba(20, 17, 13, 0.85);
    --input-bg: rgba(255, 255, 255, 0.04);
}

html {
    font-size: 10px;
    /* Base for rem scaling */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 12% -8%, rgba(var(--primary-color-rgb), 0.12) 0%, transparent 50%),
        radial-gradient(at 92% 6%, rgba(var(--accent-yellow-rgb), 0.10) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 1.0rem;
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    /* Space for the fixed bottom nav */
    padding-bottom: 72px;
    transition: background-color 0.3s ease, color 0.3s ease;
}
@media (min-width: 768px) {
    body { padding-bottom: 80px; }
}

/* Auth Pages */
.auth-page {
    justify-content: center;
    align-items: center;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    text-align: center;
}

.auth-container h1 {
    font-size: 2.8rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
    letter-spacing: -0.02em;
}

.auth-form {
    background: var(--card-bg);
    backdrop-filter: saturate(140%) blur(18px);
    -webkit-backdrop-filter: saturate(140%) blur(18px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    text-align: left;
    box-shadow: var(--shadow-premium);
}

/* Typography Helpers */
h1 {
    font-size: 2.4rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.8rem;
}

h1,
h2,
h3 {
    margin-bottom: 1.5rem;
    font-weight: 600;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: opacity 0.2s;
}

a:hover {
    opacity: 0.8;
}

.text-muted {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Layout */
.container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 2rem;
    background: var(--header-bg);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.logo img {
    height: 40px;
    display: block;
}

.top-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    font-size: 1.2rem;
}

.top-nav a {
    color: var(--text-color);
    font-weight: 500;
}

.top-nav a.active,
.top-nav a:hover {
    color: var(--primary-color);
}

.nav-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
}

.nav-icon-btn:hover {
    background: var(--border-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* Components */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.8rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-premium);
    transition: transform 0.2s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.2s ease;
}

.card:hover {
    border-color: var(--border-strong);
}

.glass {
    backdrop-filter: saturate(140%) blur(18px);
    -webkit-backdrop-filter: saturate(140%) blur(18px);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.3rem 0.9rem;
    background: rgba(var(--primary-color-rgb), 0.08);
    border: 1px solid rgba(var(--primary-color-rgb), 0.18);
    border-radius: 999px;
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    color: var(--text-muted);
    font-size: 1.3rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.9rem 1.1rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1.3rem;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.3s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* Hide default password reveal eye icon in Edge/IE to prevent duplicates */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.18);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.6rem;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
    font-size: 1.3rem;
    line-height: 1.2;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff !important;
}
.btn-primary:hover {
    background: var(--primary-color);
    filter: brightness(1.08);
}

.btn-secondary {
    background: transparent;
    color: var(--text-color);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    background: var(--bg-tint);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 0.45rem 1rem;
    font-size: 1.1rem;
    border-radius: 8px;
}

.btn:hover {
    transform: translateY(-1px);
}

/* Notifications */
.error-msg,
.success-msg {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-msg {
    color: var(--error-color);
    background: rgba(207, 34, 46, 0.1);
    border: 1px solid rgba(207, 34, 46, 0.2);
}

.success-msg {
    color: var(--success-color);
    background: rgba(26, 127, 55, 0.1);
    border: 1px solid rgba(26, 127, 55, 0.2);
}

/* History Timeline */
.history-timeline {
    margin-top: 2rem;
    max-width: 800px;
}

.log-entry {
    margin-bottom: 1.2rem;
    border-left: 3px solid var(--border-strong);
    position: relative;
}

.log-work {
    border-left-color: var(--success-color);
    background: rgba(63, 185, 80, 0.04);
}

.log-comm {
    border-left-color: var(--secondary-color);
    background: rgba(207, 34, 46, 0.04);
}

.log-header {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    margin-bottom: 0.8rem;
}

.log-type-tag {
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.log-work .log-type-tag {
    color: var(--accent-blue);
}

.log-comm .log-type-tag {
    color: var(--secondary-color);
}

.log-meta {
    margin-bottom: 1rem;
    font-size: 1.6rem;
}

.log-meta strong {
    color: var(--primary-color);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.8rem;
    background: var(--bg-tint);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.4;
}

.summary-box {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    font-size: 1.3rem;
    border: 1px solid var(--border-color);
}

[data-theme='dark'] .summary-box {
    background: rgba(0, 0, 0, 0.2);
}

/* Dropdown Component */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content,
.popup-panel {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    /* Solid bg so the header's backdrop-filter stacking context doesn't bleed through */
    background-color: #fffbf2;
    min-width: 22rem;
    box-shadow: 0 4px 8px rgba(26, 20, 16, 0.08), 0 16px 48px rgba(26, 20, 16, 0.16);
    z-index: 1000;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    overflow: hidden;
}
[data-theme='dark'] .dropdown-content,
[data-theme='dark'] .popup-panel {
    background-color: #1f1a14;
    box-shadow: 0 4px 8px rgba(0, 0, 0, .35), 0 16px 48px rgba(0, 0, 0, .5);
}
.dropdown-content {
    margin-top: 0.5rem;
    /* Reduced gap */
}

/* Bridging pseudo-element with slight overlap */
.dropdown-content::before {
    content: '';
    position: absolute;
    top: -1rem;
    left: 0;
    width: 100%;
    height: 1.5rem;
    background: transparent;
}

.dropdown:hover .dropdown-content {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-item {
    padding: 1rem 1.5rem;
    display: block;
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: 500;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background: var(--border-color);
    color: var(--primary-color);
    padding-left: 2rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.add-btn-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    background: var(--primary-color);
    color: white !important;
    border-radius: 50%;
    font-size: 1.6rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.add-btn-round {
    transition: transform 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.add-btn-round:hover {
    transform: scale(1.15);
    opacity: 0.9;
}

/* Action Button Group (View, Edit, Delete) */
.action-controls {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    cursor: pointer;
}
.action-btn:hover { background: var(--bg-tint); }

.action-btn .material-icons-outlined {
    font-size: 1.4rem;
}

.action-btn.btn-view:hover {
    border-color: var(--success-color);
    color: var(--success-color);
    background: rgba(35, 134, 54, 0.05);
}

.action-btn.btn-edit:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(9, 105, 218, 0.05);
}

.action-btn.btn-delete:hover {
    border-color: var(--error-color);
    color: var(--error-color);
    background: rgba(207, 34, 46, 0.05);
}

/* Footer Styling */
footer {
    margin-top: auto;
    padding: 3rem 2rem;
    background: transparent;
    border-top: 1px solid var(--border-color);
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    text-align: center;
}

.footer-logo img {
    height: 35px;
    opacity: 0.8;
}

.footer-text {
    line-height: 2;
}

.footer-text p {
    margin-bottom: 0.5rem;
}

/* Gradient Links */
.gradient-link-gywv,
.gradient-link-siliconcrib {
    font-weight: 700;
    text-decoration: none !important;
    transition: filter 0.3s ease;
    background-clip: text;
    -webkit-background-clip: text;
    color: inherit;
}

.gradient-link-gywv:hover {
    background: linear-gradient(45deg, #fa7e8a, #58a6ff);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: brightness(1.2);
}

.gradient-link-siliconcrib:hover {
    background: linear-gradient(45deg, #0969da, #fa7e8a);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: brightness(1.2);
}

/* Misc */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Task Phase 2 Utilities */
.data-large {
    font-size: 1.4rem;
}

.section-full {
    width: 100%;
    margin-bottom: 2rem;
}

[data-theme='dark'] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.task-grid-full {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Circular Action Buttons */
.action-btn-circle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.action-btn-circle:hover {
    background: rgba(var(--primary-color-rgb), 0.1);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.action-btn-circle span {
    font-size: 20px;
}

.action-btn-circle.view:hover {
    color: #007bff;
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.1);
}

.action-btn-circle.delete:hover {
    color: #dc3545;
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

.action-btn-circle.add:hover {
    color: #28a745;
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

/* Small Circular Action Buttons */
.action-btn-circle-sm {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.action-btn-circle-sm:hover {
    background: rgba(var(--primary-color-rgb), 0.1);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.action-btn-circle-sm span {
    font-size: 14px;
}

.action-btn-circle-sm.view:hover { color: #007bff; border-color: #007bff; background: rgba(0, 123, 255, 0.1); }
.action-btn-circle-sm.edit:hover { color: #ffc107; border-color: #ffc107; background: rgba(255, 193, 7, 0.1); }
.action-btn-circle-sm.delete:hover { color: #dc3545; border-color: #dc3545; background: rgba(220, 53, 69, 0.1); }
.action-btn-circle-sm.add:hover { color: #28a745; border-color: #28a745; background: rgba(40, 167, 69, 0.1); }
.action-btn-circle-sm.enter:hover { color: var(--primary-color); border-color: var(--primary-color); background: rgba(var(--primary-color-rgb), 0.1); }
.action-btn-circle-sm.suspend:hover { color: #fd7e14; border-color: #fd7e14; background: rgba(253, 126, 20, 0.1); }
.action-btn-circle-sm.activate:hover { color: #28a745; border-color: #28a745; background: rgba(40, 167, 69, 0.1); }

/* Allow the action button to be used as a form-submit too */
button.action-btn-circle-sm { font-family: inherit; padding: 0; }

/* "Active" indicator state (e.g. share link generated, impersonating a role) */
.action-btn-circle-sm.active {
    background: rgba(var(--primary-color-rgb), 0.15);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.10);
}
.nav-icon-btn.active {
    background: rgba(var(--primary-color-rgb), 0.12);
    color: var(--primary-color);
}

/* Force every top-bar icon to the same muted colour by default, then let
   `.active` (current page / impersonating) and `:hover` flip to amber. */
.main-header .nav-icon-btn,
.main-header .nav-icon-btn:visited,
.main-header .nav-icon-btn .material-icons-outlined {
    color: var(--text-muted);
}
.main-header .nav-icon-btn:hover,
.main-header .nav-icon-btn:hover .material-icons-outlined,
.main-header .nav-icon-btn.active,
.main-header .nav-icon-btn.active .material-icons-outlined {
    color: var(--primary-color);
}

.action-icons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.inline-form {
    display: flex;
    gap: 1rem;
}

.tab-controls {
    display: flex;
    gap: .5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    background: transparent;
    border: 1.5px solid var(--border-strong);
    color: var(--text-muted);
    padding: .55rem 1.3rem;
    cursor: pointer;
    font-weight: 600;
    border-radius: 10px;
    transition: background .15s, color .15s, border-color .15s, transform .15s;
    font-size: 1.05rem;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.tab-btn:hover {
    color: var(--primary-deep);
    border-color: var(--primary-color);
}
.tab-btn.active {
    background: var(--brand-gradient);
    background-origin: border-box;
    background-clip: border-box;
    border: 1.5px solid transparent;
    color: #1a1410;
}

@media (max-width: 480px) {
    .tab-btn { padding: .5rem 1rem; font-size: .95rem; }
}

/* ============================================================
   Responsive tables: convert <table class="responsive-table"> rows
   into stacked cards on phones. Each <td> needs data-label="…".
   ============================================================ */
.responsive-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.responsive-table thead { background: rgba(0,0,0,.02); }
.responsive-table th, .responsive-table td {
    padding: .9rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.responsive-table th {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 700;
}

@media (max-width: 640px) {
    .responsive-table, .responsive-table thead, .responsive-table tbody,
    .responsive-table tr, .responsive-table td { display: block; width: 100%; }
    .responsive-table thead { display: none; }
    .responsive-table tr {
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        margin-bottom: .8rem;
        padding: .8rem 1rem;
    }
    .responsive-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        padding: .4rem 0;
        border-bottom: 1px dashed var(--border-color);
        text-align: right;
    }
    .responsive-table td:last-child { border-bottom: none; }
    .responsive-table td::before {
        content: attr(data-label);
        font-size: .7rem;
        text-transform: uppercase;
        letter-spacing: .05em;
        font-weight: 700;
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }
}

/* ============================================================
   Progress bar — shared across home hero, task list, task detail
   ============================================================ */
.progress-track {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    /* CLLO brand: warm amber start, deep green finish */
    background: linear-gradient(90deg, #ff9800 0%, #ffc107 35%, #66bb6a 75%, #2e7d32 100%);
    border-radius: 4px;
    transition: width .3s ease;
}

/* Icon-only view toggle (used by tasks list/kanban switch) */
.view-toggle-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
    border-radius: 8px;
    text-decoration: none;
    transition: color .15s, background .15s;
    cursor: pointer;
}
.view-toggle-btn .material-icons-outlined { font-size: 18px; }
.view-toggle-btn:hover { color: var(--primary-deep); background: rgba(var(--primary-color-rgb), .08); }
.view-toggle-btn.active { color: var(--primary-color); background: rgba(var(--primary-color-rgb), .14); }

/* Responsive */
/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ============================================================
   Bottom Navigation (mobile-first, all viewports)
   ============================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--header-bg);
    backdrop-filter: saturate(160%) blur(18px);
    -webkit-backdrop-filter: saturate(160%) blur(18px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 12px rgba(0,0,0,.04);
    z-index: 90;
    padding-bottom: env(safe-area-inset-bottom, 0);
    height: calc(64px + env(safe-area-inset-bottom, 0));
}
.bottom-nav-inner {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: 64px;
    padding: 0 .4rem;
}
.bottom-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 500;
    line-height: 1;
    padding: .5rem .2rem;
    border: none;
    background: none;
    cursor: pointer;
    transition: color .15s ease, transform .15s ease;
    min-width: 0;
    position: relative;
}
.bottom-nav-item .material-icons-outlined {
    font-size: 22px;
    transition: transform .15s ease;
}
.bottom-nav-item .bn-label {
    font-size: .65rem;
    letter-spacing: .02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-transform: capitalize;
}
.bottom-nav-item:hover {
    color: var(--primary-color);
}
.bottom-nav-item.active {
    color: var(--primary-color);
    font-weight: 700;
}
.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--brand-gradient);
    border-radius: 0 0 3px 3px;
}
.bottom-nav-item.active .material-icons-outlined {
    transform: scale(1.12);
}

/* On larger screens, give icons a bit more room */
@media (min-width: 768px) {
    .bottom-nav { height: calc(72px + env(safe-area-inset-bottom, 0)); }
    .bottom-nav-inner { height: 72px; max-width: 720px; margin: 0 auto; }
    .bottom-nav-item .material-icons-outlined { font-size: 24px; }
    .bottom-nav-item .bn-label { font-size: .72rem; }
}
@media (min-width: 1024px) {
    .bottom-nav-inner { max-width: 820px; }
}

/* Slim top bar to give the bottom nav room */
.main-header {
    height: 56px;
    padding: 0 1rem !important;
    flex-wrap: nowrap !important;
    gap: .5rem !important;
}
.main-header .logo img { height: 28px; }
.main-header .top-nav {
    gap: .4rem !important;
    font-size: 1rem !important;
    width: auto !important;
    margin-left: 0 !important;
}
.main-header .nav-icon-btn {
    width: 36px !important;
    height: 36px !important;
}
.main-header .nav-icon-btn .material-icons-outlined {
    font-size: 18px !important;
}

/* Phone: keep only the essentials in the right cluster */
@media (max-width: 480px) {
    .top-title { font-size: .85rem; }
    .top-title small { font-size: .55rem; }
    /* On phones, settings/logout move to the Home dashboard / profile page; bottom nav handles rest */
    .main-header #logout-btn { display: none; }
    .main-header a[title="Settings"] { display: none; }
}

/* Top-bar tenant + role chip in the centre */
.top-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: .95rem;
    color: var(--text-color);
    line-height: 1.1;
}
.top-title small {
    display: block;
    font-size: .65rem;
    color: var(--primary-color);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ============================================================
   Universal entity row (replaces bespoke list-card layouts)
   Markup:
   <div class="entity-row">
       <span class="entity-drag" title="Drag to reorder">⋮⋮</span>
       <span class="entity-pos">12</span>
       <div class="entity-avatar">A</div>
       <div class="entity-body">
           <div class="entity-name">Name</div>
           <div class="entity-meta">Sub-line</div>
       </div>
       <div class="entity-actions">
           <a class="btn-pill">View</a>
           <a class="btn-link-amber">Edit</a>
       </div>
   </div>
   ============================================================ */
.entity-list {
    display: flex;
    flex-direction: column;
    gap: .8rem;
    margin-bottom: 2rem;
}
.entity-row {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.1rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.entity-row:hover {
    border-color: var(--border-strong);
    box-shadow: 0 4px 18px rgba(var(--primary-color-rgb), .08);
}
.entity-row.sortable-ghost { opacity: .35; }
.entity-row.sortable-chosen { box-shadow: 0 8px 28px rgba(var(--primary-color-rgb), .25); }

.entity-drag {
    cursor: grab;
    width: 18px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: .5;
    flex-shrink: 0;
    user-select: none;
    transition: opacity .15s;
}
.entity-drag:hover, .entity-row:hover .entity-drag { opacity: 1; color: var(--primary-color); }
.entity-drag::before {
    content: '⋮⋮';
    font-size: 1.4rem;
    line-height: 1;
    letter-spacing: -2px;
}

.entity-pos {
    background: rgba(var(--primary-color-rgb), .12);
    color: var(--primary-deep);
    font-weight: 700;
    font-size: .95rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.entity-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: #1a1410;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.entity-avatar img { width: 100%; height: 100%; object-fit: cover; }

.entity-body {
    flex: 1;
    min-width: 0;
}
.entity-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-color);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.entity-meta {
    color: var(--text-muted);
    font-size: .85rem;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entity-actions {
    display: flex;
    gap: .8rem;
    align-items: center;
    flex-shrink: 0;
}
.btn-pill {
    background: rgba(var(--primary-color-rgb), .1);
    border: none;
    color: var(--primary-deep);
    padding: .45rem 1.1rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: .85rem;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s;
}
.btn-pill:hover { background: rgba(var(--primary-color-rgb), .18); }

.btn-link-amber {
    color: var(--primary-deep);
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: .3rem .2rem;
    transition: color .15s;
}
.btn-link-amber:hover { color: var(--primary-color); text-decoration: underline; }
.btn-link-amber.danger { color: var(--error-color); }
.btn-link-amber.danger:hover { color: var(--error-color); }

/* Phone: drop drag handle width, hide meta sub-line second details */
@media (max-width: 480px) {
    .entity-row { padding: 1rem 1.2rem; gap: .7rem; }
    .entity-pos { width: 28px; height: 28px; font-size: .85rem; }
    .entity-avatar { width: 36px; height: 36px; font-size: 1rem; }
    .entity-name { font-size: 1rem; }
    .entity-meta { font-size: .75rem; }
    .entity-actions { gap: .5rem; }
    .btn-pill { padding: .4rem .9rem; font-size: .8rem; }
}

/* Tiny circular checkbox (voucher acknowledgement toggle) — 10×10. */
input[type="checkbox"].circle-check {
    appearance: none !important; -webkit-appearance: none !important; -moz-appearance: none !important;
    width: 10px !important; height: 10px !important; min-width: 10px !important;
    border: 1.5px solid var(--border-color); border-radius: 50%; background: var(--input-bg);
    cursor: pointer; position: relative; flex-shrink: 0; box-sizing: border-box; padding: 0; margin: 0;
    transition: background .15s, border-color .15s;
}
input[type="checkbox"].circle-check:checked { border-color: var(--primary-color); background: var(--primary-color); }
input[type="checkbox"].circle-check:checked::after {
    content: ''; position: absolute; left: 2.3px; top: .3px; width: 2px; height: 4px;
    border: solid #fff; border-width: 0 1.4px 1.4px 0; transform: rotate(45deg);
}

/* Round checkbox — opt-in via .round-check */
input[type="checkbox"].round-check {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    padding: 0;
    border: 1.5px solid var(--border-strong);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    position: relative;
    box-sizing: border-box;
    display: inline-block;
    vertical-align: middle;
    transition: background 0.15s, border-color 0.15s;
}
input[type="checkbox"].round-check:hover { border-color: var(--primary-color); }
input[type="checkbox"].round-check:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}
input[type="checkbox"].round-check:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
}
input[type="checkbox"].round-check:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* SweetAlert2 — match the CLLO glass card look */
.swal-cllo {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 14px !important;
    backdrop-filter: saturate(140%) blur(18px);
    -webkit-backdrop-filter: saturate(140%) blur(18px);
    box-shadow: var(--shadow-premium) !important;
    color: var(--text-color) !important;
    font-family: var(--font-family) !important;
}
.swal-cllo .swal2-title,
.swal-cllo .swal2-html-container { color: var(--text-color) !important; }
.swal-cllo .swal2-actions { gap: .6rem !important; }
.swal-cllo .swal2-actions .btn { padding: .7rem 1.4rem !important; font-size: 1.1rem !important; }

/* Live-search forms: make Search/Clear buttons match the input's compact height */
[data-livesearch] .btn {
    padding: 0.6rem 1.2rem;
    font-size: 1.2rem;
    line-height: 1.4;
}

/* Cloudflare Turnstile: drop the iframe's outer 1px border so it blends with our card */
#turnstile-host iframe {
    border: 0 !important;
    border-radius: 8px;
}
[data-theme='dark'] #turnstile-host iframe {
    color-scheme: dark;
}

/* Hint the UA to render native form widgets (select option lists, date pickers,
   scrollbars) in dark-matching colours when our dark theme is active. */
[data-theme='dark'] {
    color-scheme: dark;
}
[data-theme='dark'] select,
[data-theme='dark'] input,
[data-theme='dark'] textarea {
    color-scheme: dark;
}

/* Scrollable Container Adjustment */
.scrollable-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

[data-theme='dark'] .scrollable-list {
    background: rgba(255, 255, 255, 0.02);
}

@media (max-width: 768px) {
    .main-header {
        flex-direction: row;
        gap: .5rem;
        padding: 0 1rem;
    }
    .top-nav {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: .4rem;
    }
    .container {
        padding: 1rem;
    }
    /* Universal: any role's metric tile grid collapses to 2 columns on phones,
       1 column on the smallest, no matter what `repeat(N, 1fr)` it asked for. */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .card {
        padding: 1.4rem;
        border-radius: 12px;
    }
    h1 { font-size: 2rem; }
    h2 { font-size: 1.6rem; }
    h3 { font-size: 1.3rem; }
}
@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Frosted overlay for finance modals — matches the date-picker/side-modal blur.
   Central rule so every .fin-modal (defined inline per finance page) gets it. */
.fin-modal {
    background: rgba(0, 0, 0, 0.22) !important;
    backdrop-filter: saturate(140%) blur(12px) !important;
    -webkit-backdrop-filter: saturate(140%) blur(12px) !important;
}

/* Finance line-item remove (×) button: rounded red 24×24 icon, everywhere. */
.inv-del { width: 24px !important; height: 24px !important; box-sizing: border-box; padding: 0 !important; cursor: pointer;
    border: 1px solid #dc3545 !important; background: transparent !important; color: #dc3545 !important; border-radius: 8px !important;
    display: inline-flex !important; align-items: center; justify-content: center; transition: background .15s ease; }
.inv-del:hover { background: rgba(220,53,69,.12) !important; }
.inv-del .material-icons-outlined { font-size: 14px !important; }
/* Add-line icon button: compact 24×24. Line amounts vertically centered. */
[id$="-add-row"].action-btn-circle-sm { width: 24px !important; height: 24px !important; }
.inv-lines td { vertical-align: middle !important; }

/* File-picker styled as one field with an inline amber upload/attach chip
   (matches the home search clear button). Used on Settings + finance attachments. */
.fin-upload-field { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--border-color); background: var(--input-bg); border-radius: 8px; padding: .35rem .5rem; box-sizing: border-box; }
.fin-upload-field input[type="file"] { flex: 1; min-width: 0; border: none; background: transparent; color: var(--text-color); font-size: .9rem; font-family: inherit; }
.fin-upload-btn { flex-shrink: 0; width: 28px; height: 28px; border: none; border-radius: 6px; background: rgba(var(--primary-color-rgb), .12); color: var(--primary-color); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background .15s ease; padding: 0; }
.fin-upload-btn:hover { background: rgba(var(--primary-color-rgb), .22); }
.fin-upload-btn .material-icons-outlined { font-size: 16px; }
.fin-upload-label { flex: 1; min-width: 0; cursor: pointer; color: var(--text-muted); font-size: .9rem; padding: .25rem .3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-upload-label.has-file { color: var(--text-color); }

/* Finance report date field — fixed width so flatpickr's altInput inherits it
   (inline styles don't carry to altInput; classes do). Keeps reports consistent. */
.rep-inp { padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--border-color); background: var(--input-bg); color: var(--text-color); width: 130px; box-sizing: border-box; }

/* Finance sub-page headers: title left; action buttons + Back grouped in the right
   corner, Back last. The h1 (sibling of .fin-back) takes the slack via :has(). */
.fin-back { order: 99; }
:has(> .fin-back) > h1 { margin-right: auto; }

/* SweetAlert2 — match CLLO frosted cards; OK/Cancel become tick/✕ icon buttons. */
.swal2-container { backdrop-filter: saturate(120%) blur(5px); -webkit-backdrop-filter: saturate(120%) blur(5px); }
.swal2-popup {
    background: var(--card-bg) !important;
    backdrop-filter: saturate(140%) blur(16px); -webkit-backdrop-filter: saturate(140%) blur(16px);
    border: 1px solid var(--border-color) !important;
    border-radius: 18px !important;
    color: var(--text-color) !important;
    box-shadow: 0 18px 50px rgba(0,0,0,.35) !important;
}
.swal2-title, .swal2-html-container { color: var(--text-color) !important; }
/* Warning "!" icon — pale amber washes out on light bg; force a solid amber. */
.swal2-icon.swal2-warning { border-color: #ff9800 !important; color: #ff9800 !important; }
.swal2-actions { gap: .8rem !important; }
/* OK/Cancel → rounded-square outline icon buttons (like the finance/Cru back button).
   NB: no !important on `display` — SweetAlert hides unused buttons via inline
   display:none, and we must not override that (else the hidden deny button shows). */
.swal2-actions .swal2-confirm,
.swal2-actions .swal2-cancel,
.swal2-actions .swal2-deny {
    width: 42px !important; height: 42px !important; min-width: 0 !important; padding: 0 !important;
    margin: 0 !important;
    border-radius: 10px !important; border: 1px solid var(--border-color) !important;
    background: transparent !important; background-image: none !important; box-shadow: none !important;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0 !important; transition: all .18s ease;
}
.swal2-actions .swal2-confirm::after,
.swal2-actions .swal2-cancel::after,
.swal2-actions .swal2-deny::after {
    font-family: 'Material Icons Outlined'; font-feature-settings: 'liga'; -webkit-font-feature-settings: 'liga';
    font-size: 22px; line-height: 1;
}
.swal2-actions .swal2-confirm::after { content: 'check'; color: #28a745; }
.swal2-actions .swal2-cancel::after,
.swal2-actions .swal2-deny::after { content: 'close'; color: #dc3545; }
.swal2-actions .swal2-confirm:hover { border-color: #28a745 !important; background: rgba(40,167,69,.14) !important; }
.swal2-actions .swal2-cancel:hover,
.swal2-actions .swal2-deny:hover { border-color: #dc3545 !important; background: rgba(220,53,69,.14) !important; }
.swal2-actions .swal2-confirm:focus, .swal2-actions .swal2-cancel:focus, .swal2-actions .swal2-deny:focus { box-shadow: none !important; }

/* Flatpickr Custom Styling */
.flatpickr-calendar {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-premium) !important;
    backdrop-filter: blur(12px) !important;
    border-radius: 12px !important;
    font-family: var(--font-family) !important;
}

.flatpickr-day {
    color: var(--text-color) !important;
    border-radius: 8px !important;
}

.flatpickr-day.selected, 
.flatpickr-day.startRange, 
.flatpickr-day.endRange, 
.flatpickr-day.selected.inRange, 
.flatpickr-day.startRange.inRange, 
.flatpickr-day.endRange.inRange, 
.flatpickr-day.selected:focus, 
.flatpickr-day.startRange:focus, 
.flatpickr-day.endRange:focus, 
.flatpickr-day.selected:hover, 
.flatpickr-day.startRange:hover, 
.flatpickr-day.endRange:hover, 
.flatpickr-day.selected.prevMonthDay, 
.flatpickr-day.startRange.prevMonthDay, 
.flatpickr-day.endRange.prevMonthDay, 
.flatpickr-day.selected.nextMonthDay, 
.flatpickr-day.startRange.nextMonthDay, 
.flatpickr-day.endRange.nextMonthDay {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
}

.flatpickr-day.today {
    border-color: var(--primary-color) !important;
}

.flatpickr-day:hover {
    background: var(--input-bg) !important;
    color: var(--primary-color) !important;
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month,
.flatpickr-current-month span.cur-month {
    color: var(--text-color) !important;
    font-weight: 700 !important;
    font-size: 1.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important; /* Center the month/year block */
    gap: 8px !important;
}

.flatpickr-months .flatpickr-month {
    flex: 1 !important;
    justify-content: center !important;
}

.flatpickr-current-month {
    padding: 0 !important;
    position: static !important;
    width: auto !important;
}

.flatpickr-current-month .numInputWrapper {
    width: auto !important;
}

.flatpickr-current-month .numInputWrapper span.arrowUp,
.flatpickr-current-month .numInputWrapper span.arrowDown {
    display: block !important; /* Restore for Task selection */
}

.flatpickr-current-month .numInputWrapper input.cur-year {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    color: var(--text-color) !important;
    width: 60px !important;
}

.flatpickr-weekday {
    color: var(--text-muted) !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
}

.flatpickr-months .flatpickr-prev-month, 
.flatpickr-months .flatpickr-next-month {
    color: var(--text-color) !important;
    fill: var(--text-color) !important;
}

.flatpickr-calendar.arrowTop:before, .flatpickr-calendar.arrowTop:after {
    border-bottom-color: var(--border-color) !important;
}

/* Dropdown styling for months/years if active */
.flatpickr-current-month select.flatpickr-monthDropdown-months,
.flatpickr-year-dropdown {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    color: var(--text-color) !important;
    background: transparent !important; /* No rectangle border background */
    border: none !important; /* Remove the rectangle border as requested */
    cursor: pointer;
    padding: 0 !important;
    border-radius: 0 !important;
    appearance: none !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    margin: 0 !important;
    box-shadow: none !important;
}

.flatpickr-current-month .numInputWrapper input.cur-year {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    color: var(--text-color) !important;
    width: 65px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
}

/* Redefine arrows for Year if using numeric input (Task mode) */
.flatpickr-current-month .numInputWrapper span.arrowUp,
.flatpickr-current-month .numInputWrapper span.arrowDown {
    border: none !important;
    padding: 0 !important;
}

.flatpickr-current-month .numInputWrapper span.arrowUp:after {
    border-bottom: 4px solid var(--text-muted) !important;
}

.flatpickr-current-month .numInputWrapper span.arrowDown:after {
    border-top: 4px solid var(--text-muted) !important;
}

[data-theme='dark'] .flatpickr-current-month select.flatpickr-monthDropdown-months,
[data-theme='dark'] .flatpickr-year-dropdown {
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23c9d1d9%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
}

.flatpickr-current-month select.flatpickr-monthDropdown-months:hover,
.flatpickr-year-dropdown:hover {
    border-color: var(--primary-color) !important;
}
[data-theme='dark'] .flatpickr-current-month select.flatpickr-monthDropdown-months:hover,
[data-theme='dark'] .flatpickr-year-dropdown:hover {
    background: rgba(255,255,255,0.05) !important;
}

/* Fix for the dropdown options background in Chrome/Safari */
.flatpickr-year-dropdown option,
.flatpickr-monthDropdown-months option {
    background: var(--bg-color) !important;
    color: var(--text-color) !important;
}

/* ---------- Add popover (Work + Comm picker) ---------- */
.add-popover {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    z-index: 200;
    display: flex;
    gap: .6rem;
    padding: .6rem;
    border-radius: 14px;
}

/* Smooth expand for inline-toggled forms (e.g. + button on Log / Orgs / Projects) */
@keyframes formSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}
.form-expand-anim { animation: formSlideDown .22s ease-out; transform-origin: top; }

/* ---------- Round action buttons (▶ play, ■ stop) — matches .action-btn-circle-sm ---------- */
.round-action {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    transition: all 0.2s;
}
.round-action:disabled { opacity: .55; cursor: default; }
.round-action .material-icons-outlined { font-size: 14px; }
.round-action.play { color: #28a745; border-color: rgba(40,167,69,.45); }
.round-action.play:hover:not(:disabled) { background: rgba(40,167,69,.12); border-color: #28a745; }
.round-action.stop { color: #dc3545; border-color: rgba(220,53,69,.45); }
.round-action.stop:hover:not(:disabled) { background: rgba(220,53,69,.12); border-color: #dc3545; }
.round-action.captured { color: #28a745; border-color: rgba(40,167,69,.45); background: rgba(40,167,69,.12); }

/* ---------- Selectable chip group (multi-select toggles) ---------- */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.chip-group .chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .8rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.chip-group .chip:hover {
    border-color: rgba(var(--primary-color-rgb), 0.4);
    color: var(--primary-color);
}
.chip-group .chip.active {
    background: rgba(var(--primary-color-rgb), 0.14);
    border-color: rgba(var(--primary-color-rgb), 0.55);
    color: var(--primary-color);
}
.chip-group .chip.active .material-icons-outlined { color: var(--primary-color); }

/* Slightly larger meta line on log/history entity-rows for readability */
#work .entity-meta,
#comm .entity-meta,
#hist .entity-meta {
    font-size: 1rem;
}

/* Lock-toggle button — amber tint when item is locked */
.lock-toggle-btn.active {
    background: rgba(var(--primary-color-rgb), 0.14);
    border-color: rgba(var(--primary-color-rgb), 0.55);
    color: var(--primary-color);
}
.lock-toggle-btn.active .material-icons-outlined { color: var(--primary-color); }

/* Progress sub-items — hover-only actions */
.subitem-row:hover .subitem-actions,
.subitem-row:focus-within .subitem-actions {
    opacity: 1 !important;
}
/* Progress group actions: + button always visible, others fade in on hover */
.progress-row .progress-actions .hover-only { opacity: 0; transition: opacity 0.15s ease; }
.progress-row:hover .progress-actions .hover-only,
.progress-row:focus-within .progress-actions .hover-only { opacity: 1; }

/* Section header actions (collapse / add / edit / delete): hidden until section
   hover, then they take space and PUSH the tracker left as they appear. */
.section-actions { display: none; align-items: center; gap: .2rem; flex-shrink: 0; }
.section-block:hover .section-actions,
.section-block:focus-within .section-actions { display: flex; }
@media (hover: none) { .section-actions { display: flex; } }

/* Card action buttons overlay the top-right corner (no reserved flex column). The
   body is inset on the right by the same width as the left drag/number/avatar
   gutter so the card's left and right gaps stay symmetric, and the buttons live in
   that right gutter (mirroring the avatar on the left). */
.progress-row {
    position: relative;
    /* Width of the left gutter = drag(18) + number(32) + avatar(40) + 3 flex gaps(1rem).
       The body is padded on the right by the same amount so both gaps match.
       ONE KNOB: raise/lower this to widen/narrow the right-hand gap. */
    --pr-gutter: calc(18px + 32px + 40px + 3rem);
}
.progress-row > .progress-actions { position: absolute; top: 1.1rem; right: 1.4rem; z-index: 2; }
.progress-row > .entity-body { padding-right: var(--pr-gutter); }
@media (max-width: 768px) {
    /* Mobile shrinks number→28, avatar→36 and the row gap→.7rem */
    .progress-row { --pr-gutter: calc(18px + 28px + 36px + 2.1rem); }
    .progress-row > .progress-actions { right: 1.2rem; }
}

/* Leave request status: icon-only, same shape as the action buttons beside it.
   The label lives in the tooltip; colour is set inline per status. */
.lv-status { cursor: default; background: transparent; }
.lv-status:hover { background: transparent; }

/* Note rows — hover-only actions + pinned indicator */
.note-row .note-actions {
    opacity: 0;
    transition: opacity 0.15s ease;
}
.note-row:hover .note-actions,
.note-row:focus-within .note-actions {
    opacity: 1;
}
.note-row.pinned {
    background: rgba(var(--primary-color-rgb), 0.04);
    border-color: rgba(var(--primary-color-rgb), 0.35) !important;
}
.note-pin-btn.active {
    background: rgba(var(--primary-color-rgb), 0.14);
    border-color: rgba(var(--primary-color-rgb), 0.55);
    color: var(--primary-color);
}
.note-pin-btn.active .material-icons-outlined { color: var(--primary-color); }

/* Always-visible "Pinned" badge inside the note body */
.pin-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    align-self: flex-start;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.12);
    border-radius: 4px;
    padding: .15rem .5rem;
}
.pin-badge .material-icons-outlined { font-size: 14px; }

/* Expand caret button — amber tint when its panel is open */
.caret-btn.active {
    background: rgba(var(--primary-color-rgb), 0.12);
    color: var(--primary-color);
    border-color: rgba(var(--primary-color-rgb), 0.35);
}
.caret-btn.active .material-icons-outlined { color: var(--primary-color); }

/* ---------- Inline search field (leading icon + amber clear chip) ---------- */
.search-field {
    position: relative;
    flex: 1;
    min-width: 20rem;
    display: block;
}
.search-field > input[type="text"],
.search-field > input[type="search"] {
    width: 100%;
    padding: 0.7rem 3rem 0.7rem 2.8rem;
    font-size: 1.05rem;
}
.search-field .sf-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 20px;
    line-height: 1;
}
.search-field .sf-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(var(--primary-color-rgb), 0.12);
    color: var(--primary-color);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease;
}
.search-field .sf-clear .material-icons-outlined { font-size: 16px; }
.search-field.has-text .sf-clear { display: inline-flex; }
.search-field .sf-clear:hover { background: rgba(var(--primary-color-rgb), 0.22); }

/* ---------- Due-date / deadline urgency tint ---------- */
/* warn   = ≥80% through start→due window  → light yellow */
/* danger = ≥80% through start→deadline    → light red    */
.urgency-warn,
.card.urgency-warn,
.entity-row.urgency-warn {
    background: rgba(255, 193, 7, 0.13);
    border-color: rgba(255, 193, 7, 0.45);
}
.urgency-danger,
.card.urgency-danger,
.entity-row.urgency-danger {
    background: rgba(220, 53, 69, 0.10);
    border-color: rgba(220, 53, 69, 0.42);
}
/* ---------- CLLO Cru shared top bar (list + setup pages) ---------- */
/* Full-bleed background, content aligned to the app header (1rem gutters) */
.cru-topbar {
    position: relative;
    left: 50%;
    width: 100vw;
    margin-left: -50vw;
    margin-top: -2rem;          /* cancel the container's top padding so it sits flush under the header */
    margin-bottom: 1.5rem;
    min-height: 56px;
    /* content aligns to the 1200px container (background stays full-bleed) */
    padding-top: 0;
    padding-bottom: 0;
    padding-left: max(2rem, calc(50vw - 600px + 2rem));
    padding-right: max(2rem, calc(50vw - 600px + 2rem));
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
}
@media (max-width: 768px) {
    .cru-topbar { margin-top: -1rem; padding-left: 1rem; padding-right: 1rem; }
}
.cru-logo { height: 30px; width: auto; display: block; }
.cru-topbar-title { font-size: 1.15rem; font-weight: 700; }

/* ---------- CLLO Cru voice call UI ---------- */
.cru-ring { position: fixed; inset: 0; z-index: 4000; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; }
.cru-ring-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 18px; padding: 2rem 2.4rem; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); min-width: 280px; }
.cru-ring-av { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-color); color: #fff; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 1rem; animation: cruPulse 1.4s ease-out infinite; }
.cru-ring-av .material-icons-outlined { font-size: 30px; }
@keyframes cruPulse { 0% { box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb), .45); } 100% { box-shadow: 0 0 0 18px rgba(var(--primary-color-rgb), 0); } }
.cru-ring-name { font-size: 1.3rem; font-weight: 700; }
.cru-ring-sub { color: var(--text-muted); font-size: .9rem; margin-top: .2rem; }
.cru-ring-actions { display: flex; gap: 2rem; justify-content: center; margin-top: 1.6rem; }
.cru-ring-actions button { width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.cru-ring-accept { background: #28a745; }
.cru-ring-decline { background: #dc3545; }
.cru-ring-actions button:hover { filter: brightness(1.08); }

.cru-callbar { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 4000; display: flex; align-items: center; gap: .7rem; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 999px; box-shadow: 0 8px 30px rgba(0,0,0,.25); padding: .4rem .5rem .4rem 1rem; max-width: calc(100vw - 24px); }
.cru-callbar-ico { color: var(--primary-color); font-size: 20px; }
.cru-callbar-info { min-width: 0; }
.cru-callbar-name { font-weight: 700; font-size: .9rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.cru-callbar-status { font-size: .75rem; color: var(--text-muted); }
.cru-callbar button { width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.cru-callbar-mute { background: rgba(127,127,127,.15); color: var(--text-color); }
.cru-callbar.muted .cru-callbar-mute { background: rgba(220,53,69,.15); color: #dc3545; }
.cru-callbar-speaker { background: rgba(var(--primary-color-rgb),.15); color: var(--primary-color); }
.cru-callbar-speaker.off { background: rgba(127,127,127,.15); color: var(--text-color); }
.cru-callbar-hangup { background: #dc3545; color: #fff; }
.cru-callbar button .material-icons-outlined { font-size: 18px; }
