/* Google Fonts - Inter (must be first) */
@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;14..32,400;14..32,500;14..32,600;14..32,700;14..32,800&display=swap');

/**
 * Lousa Engenharia 2.0 — Precision Design System
 * Clean, enterprise-grade UI. Linear / Vercel aesthetic.
 */

/* ══════════════════════════════════════════════════════════════
   RESET & DESIGN TOKENS
   ══════════════════════════════════════════════════════════════ */

:root {
    /* Brand */
    --primary: #9b1006;
    --primary-dark: #7a0d05;
    --primary-light: #c41a0e;
    --primary-50: rgba(155, 16, 6, 0.05);
    --primary-100: rgba(155, 16, 6, 0.10);
    --primary-200: rgba(155, 16, 6, 0.18);

    /* Neutrals — cooler, more refined */
    --dark: #0f0f10;
    --dark-800: #1a1a1d;
    --dark-700: #26262a;
    --dark-600: #38383d;
    --dark-500: #515158;

    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-300: #d4d4d4;
    --gray-400: #a3a3a3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-700: #404040;
    --gray-800: #262626;

    /* Surface — layered backgrounds */
    --surface-0: #ffffff;
    --surface-1: #fafafa;
    --surface-2: #f5f5f5;
    --surface-raised: #ffffff;
    --surface-overlay: rgba(0, 0, 0, 0.5);

    /* Border — subtle, consistent */
    --border: #e5e5e5;
    --border-subtle: #ebebeb;
    --border-strong: #d4d4d4;
    --border-focus: var(--primary);

    /* Status — refined, slightly desaturated */
    --status-open: #dc2626;
    --status-displacement: #2563eb;
    --status-checkin: #16a34a;
    --status-checkout: #ca8a04;
    --status-finished: #71717a;
    --status-paused: #ea580c;

    /* Priority */
    --priority-low: #22c55e;
    --priority-medium: #eab308;
    --priority-high: #ef4444;

    /* Semantic */
    --success: #16a34a;
    --warning: #ca8a04;
    --error: #dc2626;
    --info: #2563eb;

    /* Shadows — refined layered system */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04), 0 1px 3px 0 rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 4px 6px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px -4px rgba(0, 0, 0, 0.08), 0 4px 8px -4px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 16px 48px -8px rgba(0, 0, 0, 0.1), 0 8px 16px -4px rgba(0, 0, 0, 0.04);
    --shadow-inner: inset 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-primary: 0 4px 12px -2px rgba(155, 16, 6, 0.20);
    --shadow-dark: 0 8px 32px rgba(0, 0, 0, 0.32);
    --shadow-ring: 0 0 0 1px rgba(0, 0, 0, 0.05);
    --shadow-ring-primary: 0 0 0 3px rgba(155, 16, 6, 0.12);

    /* Layout */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 999px;

    --transition-fast: 0.12s ease;
    --transition: 0.18s ease;
    --transition-slow: 0.25s ease;
    --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

    --header-height: 64px;
    --controls-height: 48px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

    /* Text colors */
    --text-primary: #171717;
    --text-secondary: #525252;
    --text-tertiary: #a3a3a3;
    --text-muted: #a3a3a3;
    --text-light: #737373;
    --text-inverse: #fafafa;

    font-size: 14px;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

body {
    font-family: var(--font-sans);
    background: var(--surface-1);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--primary-dark); }

::selection {
    background: var(--primary-200);
    color: var(--primary-dark);
}

/* Minimal scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Focus visible ring */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ══════════════════════════════════════════════════════════════
   HEADER — Minimal dark top bar
   ══════════════════════════════════════════════════════════════ */

.app-header {
    display: flex;
    align-items: center;
    height: var(--header-height);
    background: #f5f5f5;
    color: var(--text-primary);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 3px solid #9b1006;
    gap: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── Hamburger Button ───────────────────────────────────────── */

.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
}

.hamburger-btn:active {
    background: rgba(0, 0, 0, 0.1);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 16px;
    flex-shrink: 0;
}

.app-logo img {
    height: 32px;
    width: auto;
    border-radius: var(--radius-sm);
    padding: 2px;
}

.app-logo-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    letter-spacing: -0.2px;
}

.app-logo-version {
    font-size: 9px;
    background: #9b1006;
    color: #fff;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 6px;
    border: 1px solid #9b1006;
}

/* ── Sidebar ────────────────────────────────────────────────── */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100%;
    background: var(--dark);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header img {
    height: 26px;
    width: auto;
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 2px 4px;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    flex: 1;
    letter-spacing: -0.2px;
}

.sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 6px;
    gap: 2px;
    flex: 1;
}

.sidebar-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
    border: none;
    background: none;
    white-space: nowrap;
    text-align: left;
    letter-spacing: -0.01em;
}

.sidebar-tab:hover {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-tab.active {
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

.sidebar-tab i {
    font-size: 15px;
    width: 18px;
    text-align: center;
    opacity: 0.7;
}

.sidebar-tab.active i {
    opacity: 1;
    color: var(--primary-light);
}

.sidebar-tab .badge {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
    margin-left: auto;
}

.sidebar-tab.active .badge {
    background: var(--primary);
    color: var(--white);
}

/* ── Period Display ─────────────────────────────────────────── */

.period-display {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.period-display:hover {
    background: rgba(0, 0, 0, 0.07);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.period-display i {
    color: #9b1006;
    font-size: 12px;
}

/* ══════════════════════════════════════════════════════════════
   TAB CONTENT
   ══════════════════════════════════════════════════════════════ */

.tab-content {
    display: none;
    padding: 0;
    height: calc(100vh - var(--header-height));
    overflow: auto;
    background: var(--surface-0);
}

.tab-content.active {
    display: block;
}

/* Tasks tab uses flex column so controls bar stays fixed */
#tab-tasks {
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#tab-tasks.active {
    display: flex;
}

/* ══════════════════════════════════════════════════════════════
   CONTROLS BAR — Clean, minimal toolbar
   ══════════════════════════════════════════════════════════════ */

.controls-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface-0);
    border-bottom: 1px solid var(--border);
    min-height: var(--controls-height);
    flex-wrap: wrap;
    flex-shrink: 0;
    position: relative;
    z-index: 800;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Selects inside controls-bar — match filter-dropdown-toggle style */
.controls-bar select {
    width: auto;
    min-width: 110px;
    padding: 6px 28px 6px 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    height: 34px;
}

/* Select dropdown — custom single-select replacing native <select> */
.filter-radio-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.filter-radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}

.filter-radio-item:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.filter-radio-item.is-selected {
    color: var(--primary);
    font-weight: 500;
}

.select-check {
    margin-left: auto;
    font-size: 11px;
    color: var(--primary);
    opacity: 0;
    flex-shrink: 0;
}

.filter-radio-item.is-selected .select-check {
    opacity: 1;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.control-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS — Clean, flat with subtle depth
   ══════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-0);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
    letter-spacing: -0.01em;
    height: 34px;
}

.btn:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn:active {
    background: var(--surface-2);
}

.btn i { font-size: 13px; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary-dark);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: var(--white);
}

.btn-primary:active {
    background: #600a04;
}

.btn-secondary {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.btn-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-0);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    height: 34px;
}

.btn-toggle:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-toggle.active {
    background: var(--primary);
    border-color: var(--primary-dark);
    color: var(--white);
}

.btn-toggle.active:hover {
    background: var(--primary-dark);
}

.btn-toggle i { font-size: 13px; }

.btn-sm {
    padding: 3px 8px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    height: 28px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-0);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* ══════════════════════════════════════════════════════════════
   FORM CONTROLS — Clean, precise inputs
   ══════════════════════════════════════════════════════════════ */

select, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="datetime-local"], input[type="date"],
input[type="time"], textarea {
    font-family: inherit;
    font-size: 13px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-0);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
    line-height: 1.4;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-ring-primary);
}

select:hover, input:hover, textarea:hover {
    border-color: var(--border-strong);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23a3a3a3' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 6px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 28px;
}

textarea {
    min-height: 72px;
    resize: vertical;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.form-group label.required::after {
    content: ' *';
    color: var(--primary);
}

.form-row {
    display: flex;
    gap: 12px;
}

/* ══════════════════════════════════════════════════════════════
   FILTER DROPDOWNS — Precise floating panels
   ══════════════════════════════════════════════════════════════ */

.filter-dropdown {
    position: relative;
}

.filter-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-0);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-width: 110px;
    height: 34px;
}

.filter-dropdown-toggle:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.filter-dropdown.open .filter-dropdown-toggle {
    border-color: var(--primary);
    box-shadow: var(--shadow-ring-primary);
}

.filter-dropdown-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 220px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 900;
    display: none;
    animation: dropdownFadeIn 0.12s ease-out;
    pointer-events: auto;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.filter-dropdown.open .filter-dropdown-panel {
    display: block;
}

.filter-dropdown-search {
    width: 100%;
    padding: 6px 8px !important;
    font-size: 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    margin-bottom: 4px;
    background: var(--surface-1) !important;
}

.filter-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 13px;
    color: var(--text-secondary);
}

.filter-checkbox-item:hover {
    background: var(--surface-2);
}

.filter-checkbox-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.filter-checkbox-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Filter Clear Button ────────────────────────────────────── */
.filter-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 5px 8px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-clear-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-50, rgba(155, 16, 6, 0.06));
}

.filter-clear-btn i {
    font-size: 10px;
}

/* Row with multiple filter action buttons side by side */
.filter-actions-row {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}
.filter-actions-row .filter-clear-btn {
    flex: 1;
    margin-bottom: 0;
}

/* ══════════════════════════════════════════════════════════════
   ZOOM LABEL
   ══════════════════════════════════════════════════════════════ */

.zoom-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ══════════════════════════════════════════════════════════════
   TASK COUNT
   ══════════════════════════════════════════════════════════════ */

.task-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    padding: 3px 10px;
    background: var(--surface-2);
    border-radius: var(--radius-full);
    white-space: nowrap;
    margin-left: auto;
    border: 1px solid var(--border-subtle);
}

/* ══════════════════════════════════════════════════════════════
   HIDDEN COLUMNS BAR
   ══════════════════════════════════════════════════════════════ */

.hidden-columns-bar {
    display: none;
    align-items: center;
    padding: 5px 16px;
    background: var(--primary-50);
    border-bottom: 1px solid var(--primary-100);
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.hidden-column-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    background: var(--surface-0);
    border: 1px solid var(--primary-100);
    border-radius: var(--radius-full);
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.hidden-column-chip:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.hidden-column-chip i { font-size: 9px; }

/* ══════════════════════════════════════════════════════════════
   TASKS TABLE — Clean grid
   ══════════════════════════════════════════════════════════════ */

.tasks-table-wrapper {
    overflow: auto;
    flex: 1 1 0;
    min-height: 0;
    padding: 0;
}

#tasksTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 600px;
    table-layout: auto;
    font-size: 100%;
}

#tasksTable thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

#tasksTable th {
    background: var(--surface-1);
    padding: 8px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

#tasksTable th.th-date {
    width: 72px;
    min-width: 72px;
    position: sticky;
    top: 0;
    left: 0;
    z-index: 22;
    background: var(--surface-2);
}

#tasksTable th.th-user {
    min-width: 120px;
    width: auto;
    position: relative;
}

.th-user-name {
    display: inline-block;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-hide-column {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

th:hover .btn-hide-column {
    opacity: 1;
}

.btn-hide-column:hover {
    color: var(--primary);
    background: var(--primary-50);
}

/* Table body */
#tasksTable td {
    padding: 0;
    border-bottom: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    vertical-align: top;
    background: var(--surface-0);
}

#tasksTable td.td-date {
    position: sticky;
    left: 0;
    z-index: 11;
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    padding: 6px 4px;
    box-shadow: 2px 0 4px rgba(0,0,0,0.04);
}

.date-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 4px 0;
}

.date-label .date-day {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.date-label .date-num {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.date-label.today {
    background: var(--primary);
    color: var(--white);
    border-radius: var(--radius);
    padding: 4px 8px;
}

.date-label.today .date-day,
.date-label.today .date-num {
    color: var(--white);
}

.row-today td {
    background: var(--primary-50) !important;
}

.row-today td.td-date {
    background: var(--primary-50) !important;
}

/* ── Task Cells ─────────────────────────────────────────────── */

.task-cell {
    padding: 3px !important;
    min-height: 48px;
    min-width: 110px;
    width: auto;
    max-width: 220px;
    transition: background var(--transition-fast);
    cursor: pointer;
}

.task-cell:hover {
    background: var(--surface-1) !important;
}

.task-cell.drag-over {
    background: var(--primary-50) !important;
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
    transition: none !important;
}

/* Prevent child elements from interfering with cell drag events */
.task-cell.drag-over > * {
    pointer-events: none;
}

.cell-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    color: var(--border-strong);
    font-size: 16px;
    font-weight: 300;
    transition: color var(--transition-fast);
}

.task-cell:hover .cell-empty {
    color: var(--primary);
}

/* ── Task Cards — Clean, compact ────────────────────────────── */

.task-item {
    position: relative;
    padding: 6px 7px 6px 11px;
    margin-bottom: 2px;
    background: var(--surface-0);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    overflow: hidden;
    font-size: 11px;
    width: max-content;
    max-width: 100%;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: element;
}

.task-item:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.task-item:active {
    box-shadow: var(--shadow-xs);
}

.task-item.dragging {
    opacity: 0.4;
    transform: rotate(1deg);
    box-shadow: var(--shadow-md);
    transition: none !important;
}

/* Touch drag floating clone */
.touch-drag-clone {
    border-radius: var(--radius);
    border: 2px solid var(--primary);
    background: var(--surface-0);
    transition: none;
    touch-action: none;
}

/* Status indicator — left border accent */
.task-status-indicator {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: var(--radius) 0 0 var(--radius);
}

.task-status-indicator.pulse {
    animation: statusPulse 2.5s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.task-type {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 1px;
    color: var(--text-tertiary);
}

.task-customer {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-title {
    color: var(--text-light);
    font-size: 11px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.task-address {
    color: var(--text-tertiary);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.task-drag-handle {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--border-strong);
    cursor: grab;
    padding: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
    touch-action: none;
}

.task-item:hover .task-drag-handle {
    opacity: 1;
}

.task-drag-handle:active { cursor: grabbing; }

/* Status border accents (left border matches task status color) */
.task-item.status-1 { border-left: 3px solid #dc2626; } /* Aberta */
.task-item.status-2 { border-left: 3px solid #2563eb; } /* Em Deslocamento */
.task-item.status-3 { border-left: 3px solid #16a34a; } /* Check-in */
.task-item.status-4 { border-left: 3px solid #facc15; } /* Check-out */
.task-item.status-5 { border-left: 3px solid #6b7280; } /* Finalizada */
.task-item.status-6 { border-left: 3px solid #f97316; } /* Pausada */



/* Status visual tweaks */
.task-item.status-5 { opacity: 0.5; }
.task-item.status-5:hover { opacity: 0.75; }

/* ══════════════════════════════════════════════════════════════
   MODALS — Clean overlay with precise content
   ══════════════════════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    animation: modalBgIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes modalBgIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--surface-0);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body .form-group {
    margin-bottom: 12px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-1);
    flex-shrink: 0;
}

/* ── Modal Tabs ─────────────────────────────────────────────── */

.modal-tabs {
    display: flex;
    gap: 0;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-1);
}

.modal-tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: color var(--transition);
    font-family: inherit;
    margin-bottom: -1px;
}

.modal-tab:hover {
    color: var(--text-primary);
}

.modal-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text-light);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: var(--radius-full);
    margin-left: 4px;
    min-width: 16px;
}

.modal-tab.active .tab-badge {
    background: var(--primary-100);
    color: var(--primary);
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

/* ══════════════════════════════════════════════════════════════
   SEARCHABLE SELECT — Customer dropdown
   ══════════════════════════════════════════════════════════════ */

.searchable-select-container {
    position: relative;
}

.searchable-input {
    padding-right: 28px !important;
}

.searchable-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-2);
    border: none;
    border-radius: var(--radius-full);
    width: 18px;
    height: 18px;
    font-size: 13px;
    line-height: 1;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.searchable-clear:hover {
    background: var(--border-strong);
    color: var(--text-primary);
}

.searchable-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 2100;
    display: none;
}

.searchable-dropdown.open {
    display: block;
    animation: dropdownFadeIn 0.12s ease-out;
}

.searchable-option {
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-subtle);
}

.searchable-option:last-child { border-bottom: none; }

.searchable-option:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.searchable-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ══════════════════════════════════════════════════════════════
   EQUIPMENT LIST
   ══════════════════════════════════════════════════════════════ */

.equipment-placeholder {
    padding: 24px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

.equipment-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.equipment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition-fast);
}

.equipment-item:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

.equipment-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.equipment-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.equipment-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.equipment-id {
    font-size: 11px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

.equipment-category {
    font-size: 11px;
    color: var(--primary);
    font-weight: 500;
}

/* ── Equipment Accordion (unassigned) ───────────────────── */
.equipment-accordion {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.equipment-accordion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    transition: var(--transition-fast);
}

.equipment-accordion-header:hover {
    background: var(--surface-3, var(--surface-2));
    color: var(--text-primary);
}

.equipment-accordion-header .accordion-icon {
    font-size: 10px;
    transition: transform 0.2s ease;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.equipment-accordion-header .accordion-count {
    color: var(--text-tertiary);
    font-weight: 400;
    margin-left: auto;
}

.equipment-accordion-body {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.equipment-accordion.open .equipment-accordion-body {
    display: flex;
}

/* ══════════════════════════════════════════════════════════════
   CALENDAR — Period / Replicate
   ══════════════════════════════════════════════════════════════ */

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.calendar-month-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
    min-width: 160px;
    text-align: center;
}

.calendar-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.calendar-days-header span {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    padding: 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    color: var(--text-secondary);
    position: relative;
}

.calendar-day:hover {
    background: var(--surface-2);
}

.calendar-day.empty {
    cursor: default;
}

.calendar-day.selected {
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
}

.calendar-day.selected.start {
    border-radius: var(--radius) 0 0 var(--radius);
}

.calendar-day.selected.end {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.calendar-day.selected.start.end {
    border-radius: var(--radius);
}

.calendar-day.in-range {
    background: var(--primary-50);
    color: var(--primary-dark);
    border-radius: 0;
}

.calendar-day.today-mark::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
}

.calendar-day.selected.today-mark::after {
    background: var(--white);
}

/* ── Calendar Selection Summary ─────────────────────────── */
.cal-selection-summary {
    margin-top: 12px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    background: var(--surface-1);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
}

.cal-selection-summary.has-selection {
    background: var(--primary-50, rgba(155, 16, 6, 0.06));
    border-color: var(--primary);
    border-style: solid;
    color: var(--text-primary);
    font-weight: 500;
}

.cal-selection-summary i {
    font-size: 11px;
    color: var(--primary);
}

.cal-days-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 4px;
    line-height: 1.2;
}

/* ── Calendar Quick Presets ─────────────────────────────── */
.cal-presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 12px;
}

.cal-preset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.cal-preset-btn:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.cal-preset-btn:active {
    transform: scale(0.97);
}

.cal-preset-btn i {
    font-size: 11px;
    color: var(--primary);
}

/* ── Period Display Loading State ───────────────────────── */
.period-display.period-loading {
    position: relative;
    overflow: hidden;
    pointer-events: none;
}

.period-display.period-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(155, 16, 6, 0.08) 40%,
        rgba(155, 16, 6, 0.15) 50%,
        rgba(155, 16, 6, 0.08) 60%,
        transparent 100%
    );
    animation: periodShimmer 1.4s infinite ease-in-out;
}

@keyframes periodShimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ── Skeleton Loading Cells ─────────────────────────────── */

/* Tasks Progress Bar */
.tasks-progress-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--surface-0);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tasks-progress-bar.active {
    display: flex;
}

.tasks-progress-track {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--surface-2);
    overflow: hidden;
    position: relative;
}

.tasks-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary, #9b1006), var(--primary-light, #c0392b));
    transition: width 0.35s ease;
    position: relative;
}

.tasks-progress-fill.indeterminate {
    width: 30% !important;
    animation: progressIndeterminate 1.4s infinite ease-in-out;
}

@keyframes progressIndeterminate {
    0% { left: -30%; }
    100% { left: 100%; }
}

.tasks-progress-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 140px;
    text-align: right;
}

.skeleton-cell {
    position: relative;
    padding: 8px 6px !important;
    min-height: 60px;
}

.skeleton-bar {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        var(--surface-2) 25%,
        var(--surface-3, rgba(155, 16, 6, 0.06)) 50%,
        var(--surface-2) 75%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.6s infinite ease-in-out;
    margin-bottom: 6px;
    width: 80%;
}

.skeleton-bar--short {
    width: 50%;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════════════════════════════
   MAP
   ══════════════════════════════════════════════════════════════ */

#tab-map,
#tab-metrics {
    display: none;
    flex-direction: column;
    position: relative;
}

#tab-map.active,
#tab-metrics.active {
    display: flex;
}

/* Floating back-to-agenda button */
.btn-back-to-agenda {
    position: absolute;
    top: 60px;
    right: 16px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--primary, #9b1006);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: background 0.2s, transform 0.2s, opacity 0.2s;
    animation: fadeInDown 0.3s ease;
}

.btn-back-to-agenda:hover {
    background: var(--primary-dark, #7a0d05);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.btn-back-to-agenda:active {
    transform: translateY(0);
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

#mapContainer {
    flex: 1 1 0;
    min-height: 300px;
    border-radius: 0;
}

.map-legend {
    padding: 6px 16px;
    background: var(--surface-0);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* ── Progress bar ────────────────────────────────────── */
.legend-progress {
    position: relative;
    height: 18px;
    background: var(--surface-1);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 6px;
    transition: opacity 0.4s, height 0.4s, margin 0.4s;
}

.legend-progress.done {
    opacity: 0;
    height: 0;
    margin-bottom: 0;
    pointer-events: none;
}

.legend-progress-bar {
    position: absolute;
    inset: 0;
    width: 0%;
    background: #9b1006;
    border-radius: var(--radius);
    transition: width 0.5s ease;
}

.legend-progress-text {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 10px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}

/* ── Inline legend row ───────────────────────────────── */
.legend-row {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.legend-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.legend-group-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.legend-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
    font-weight: 700;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-full);
    line-height: 1;
}

.legend-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    flex-shrink: 0;
    align-self: center;
}

.map-legend h4 {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.legend-dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

/* Map Markers */
.map-marker-custom {
    background: none !important;
    border: none !important;
}

.marker-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid;
    color: var(--white);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: transform 0.12s ease;
}

.marker-circle:hover {
    transform: scale(1.15);
}

.marker-circle.pulse {
    animation: markerPulse 2s infinite;
}

@keyframes markerPulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.25); }
    70% { box-shadow: 0 0 0 8px rgba(0, 0, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}

/* Map Popup */
.map-popup-wrapper .leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0;
}

.map-popup-wrapper .leaflet-popup-content {
    margin: 0;
    min-width: 250px;
}

.map-popup {
    font-family: var(--font-sans);
    font-size: 12px;
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-1);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.popup-id {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.popup-status-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--white);
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.popup-date {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-tertiary);
}

.popup-body {
    padding: 10px 12px;
}

.popup-row {
    padding: 2px 0;
    color: var(--text-secondary);
    line-height: 1.4;
}

.popup-row strong {
    color: var(--text-primary);
}

.popup-actions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface-1);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Leaflet controls — reset global anchor color leak */
.leaflet-control-container a {
    color: #333;
    text-decoration: none;
}

.leaflet-control-container a:hover {
    color: #333;
}

/* Leaflet custom controls */
.map-control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--text-secondary);
    font-size: 14px;
}

.map-control-btn:hover {
    color: var(--primary);
}

/* Vehicle toggle button active state */
.map-control-btn.vehicle-toggle-active {
    color: #16a34a;
}

/* ── Vehicle Markers ────────────────────────────────────── */
.vehicle-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 2px solid;
    color: #fff;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.12s ease;
    position: relative;
}

.vehicle-marker:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

.vehicle-marker.vehicle-moving {
    animation: vehiclePulse 2s infinite;
}

@keyframes vehiclePulse {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.vehicle-plate-label {
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.92);
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    line-height: 1.2;
    pointer-events: none;
}

.vehicle-tooltip {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* Vehicle popup overrides */
.vehicle-popup .popup-header {
    border-bottom: 2px solid var(--border);
}

.vehicle-popup .popup-id {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* ── Team GPS Markers ───────────────────────────────────── */
.team-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.12s ease;
    position: relative;
}

.team-marker:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

.team-marker-initials {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1;
    pointer-events: none;
}

.team-marker-online {
    animation: teamPulseOnline 2.5s infinite;
}

@keyframes teamPulseOnline {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
    70% { box-shadow: 0 0 0 12px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.team-marker-recent {
    animation: teamPulseRecent 3s infinite;
}

@keyframes teamPulseRecent {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.team-marker-label {
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.92);
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    line-height: 1.2;
    pointer-events: none;
}

.team-tooltip {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.team-popup .popup-header {
    border-bottom: 2px solid var(--border);
}

.team-popup .popup-id {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Team toggle button active state */
.map-control-btn.team-toggle-active {
    color: #8b5cf6;
}

/* ── Unassigned Task Markers ────────────────────────────── */
.marker-unassigned {
    border-style: dashed !important;
    border-width: 3px !important;
    animation: unassignedPulse 1.8s infinite !important;
}

@keyframes unassignedPulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.marker-unassigned-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #f59e0b;
    color: #000;
    font-size: 12px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 10;
    animation: badgeBounce 2s infinite;
}

@keyframes badgeBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.popup-unassigned .popup-header {
    border-bottom: 2px solid #f59e0b;
    background: rgba(245, 158, 11, 0.08) !important;
}

.popup-unassigned-badge {
    font-size: 10px;
    font-weight: 700;
    color: #92400e;
    background: rgba(245, 158, 11, 0.2);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.legend-dot-unassigned {
    box-sizing: border-box;
}

.legend-item-highlight {
    font-weight: 600;
    color: #f59e0b;
}

/* ══════════════════════════════════════════════════════════════
   TICKETS
   ══════════════════════════════════════════════════════════════ */

.tickets-container {
    padding: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

.ticket-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.ticket-stat-card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    text-align: center;
    transition: border-color var(--transition);
}

.ticket-stat-card:hover {
    border-color: var(--border-strong);
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ticket-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ticket-card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    transition: border-color var(--transition);
}

.ticket-card:hover {
    border-color: var(--border-strong);
}

.ticket-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.ticket-id {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.ticket-status-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--white);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.ticket-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    line-height: 1.4;
}

.ticket-description {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 8px;
}

.ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.ticket-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.ticket-meta-item i {
    color: var(--text-tertiary);
    font-size: 11px;
}

.ticket-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

.ticket-date {
    font-size: 11px;
    color: var(--text-tertiary);
}

.ticket-date i { margin-right: 3px; }

.ticket-priority {
    font-size: 11px;
    font-weight: 600;
}

.ticket-priority i { margin-right: 3px; }

.ticket-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

.ticket-empty i {
    font-size: 36px;
    margin-bottom: 10px;
    display: block;
    color: var(--border-strong);
}

.ticket-empty p {
    font-size: 13px;
}

/* ══════════════════════════════════════════════════════════════
   METRICS (iframe)
   ══════════════════════════════════════════════════════════════ */

.metrics-tab-bar {
    display: flex;
    gap: 0;
    background: var(--surface-0);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.metrics-tab {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color var(--transition);
    white-space: nowrap;
    margin-bottom: -1px;
}

.metrics-tab:hover {
    color: var(--text-primary);
}

.metrics-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.metrics-container {
    width: 100%;
    flex: 1 1 0;
    border: none;
    display: none;
}

.metrics-container.active {
    display: block;
}

/* ══════════════════════════════════════════════════════════════
   USER / PROFILE
   ══════════════════════════════════════════════════════════════ */

.user-container {
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 18px 20px;
    margin-bottom: 16px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-info p {
    font-size: 13px;
    color: var(--text-tertiary);
}

.user-role-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.user-role-badge.admin { background: var(--primary-100); color: var(--primary); }
.user-role-badge.editor { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
.user-role-badge.viewer { background: var(--surface-2); color: var(--text-secondary); }

/* Insights */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.insight-card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}

.insight-card h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.insight-card h4 i {
    margin-right: 6px;
    color: var(--text-tertiary);
}

.insight-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Admin Section */
.admin-section {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 18px 20px;
}

.admin-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.admin-section h3 i {
    color: var(--primary);
    margin-right: 8px;
}

.admin-user-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 10px;
    margin-bottom: 14px;
    align-items: end;
}

.admin-user-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ══════════════════════════════════════════════════════════════
   LOADING SCREENS & INDICATORS
   ══════════════════════════════════════════════════════════════ */

.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--surface-0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    z-index: 9999;
    transition: opacity var(--transition-slow);
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-logo {
    height: 200px;
    max-width: 80vw;
    width: auto;
    animation: logoPulse 2.4s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.95); }
}

.loading-bar-track {
    width: 280px;
    height: 4px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
}

.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px;
    color: var(--text-muted);
    font-size: 13px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════════════════════════
   LOGIN OVERLAY
   ══════════════════════════════════════════════════════════════ */

.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity var(--transition-slow);
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-card img {
    height: 40px;
    margin-bottom: 14px;
}

.login-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.4px;
}

.login-card p {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 22px;
}

.login-card form {
    text-align: left;
}

.login-card .form-group {
    margin-bottom: 14px;
}

.login-card .form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-card .btn-primary {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 6px;
}

/* ══════════════════════════════════════════════════════════════
   TOASTS — Floating notifications
   ══════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 10px);
    right: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5000;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 260px;
    max-width: 400px;
    pointer-events: auto;
    transform: translateX(100%);
    opacity: 0;
    transition: all var(--transition-slow);
}

.toast.toast-show {
    transform: translateX(0);
    opacity: 1;
}

.toast.toast-hide {
    transform: translateX(100%);
    opacity: 0;
}

.toast i:first-child {
    font-size: 15px;
    flex-shrink: 0;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-success i:first-child { color: var(--success); }

.toast-error { border-left: 3px solid var(--error); }
.toast-error i:first-child { color: var(--error); }

.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning i:first-child { color: var(--warning); }

.toast-info { border-left: 3px solid var(--info); }
.toast-info i:first-child { color: var(--info); }

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 15px;
    padding: 2px;
    margin-left: auto;
    transition: var(--transition-fast);
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ══════════════════════════════════════════════════════════════
   MOVE CONFIRMATION MODAL
   ══════════════════════════════════════════════════════════════ */

.move-modal {
    max-width: 420px;
}

.move-modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.move-modal-task-info {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 13px;
    line-height: 1.6;
}

.move-modal-task-info .move-info-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.move-modal-task-info .move-info-row + .move-info-row {
    margin-top: 4px;
}

.move-info-label {
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    min-width: 70px;
}

.move-info-value {
    color: var(--text-primary);
    font-weight: 500;
}

.move-modal-arrow {
    padding: 10px 0;
    color: var(--primary);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.move-modal-destination {
    width: 100%;
    padding: 14px 16px;
    background: var(--primary-bg, rgba(59, 130, 246, 0.06));
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-lg);
    font-size: 13px;
    line-height: 1.6;
}

.move-modal-destination .move-info-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.move-modal-destination .move-info-row + .move-info-row {
    margin-top: 4px;
}

.move-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════════════════════════════ */

#printContainer {
    display: none;
}

/* ── Print Day Selection Modal ────────────────────────────── */
.print-day-modal {
    max-width: 480px !important;
    width: 480px !important;
}

.print-day-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px 0;
}

.print-day-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}

.print-day-item:hover {
    background: var(--surface-2);
}

.print-day-item.selected {
    background: rgba(155, 16, 6, 0.06);
    border-color: var(--primary, #9b1006);
}

.print-day-item input[type="checkbox"] {
    accent-color: var(--primary, #9b1006);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.print-day-item .day-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.print-day-item .day-date {
    font-size: 12px;
    color: var(--text-muted);
}

.print-day-item .day-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 10px;
}

.print-day-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ── Print Preview Modal (screen) ────────────────────────── */
.print-preview-modal {
    max-width: 95vw !important;
    width: 95vw !important;
    max-height: 95vh !important;
    height: 95vh;
    display: flex;
    flex-direction: column;
}

.print-preview-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.print-preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.print-preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px !important;
    background: #f3f4f6;
}

/* ── Preview container (screen rendering) ────────────────── */
.pr-preview {
    max-width: 1100px;
    margin: 0 auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 24px 28px;
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    color: #1f2937;
}

.pr-edit-hint {
    font-size: 12px;
    color: var(--primary);
    background: rgba(155, 16, 6, 0.04);
    border: 1px dashed rgba(155, 16, 6, 0.25);
    border-radius: 6px;
    padding: 8px 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pr-edit-hint i {
    font-size: 13px;
}

/* Screen-mode header */
.pr-preview .pr-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 3px solid #9b1006;
    margin-bottom: 14px;
}

.pr-preview .pr-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pr-preview .pr-logo { height: 40px; object-fit: contain; }
.pr-preview .pr-brand-name { font-size: 24px; font-weight: 800; color: #9b1006; margin: 0; line-height: 1; }
.pr-preview .pr-brand-sub { font-size: 13px; color: #6b7280; margin: 2px 0 0; }

.pr-preview .pr-header-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.pr-preview .pr-meta-row { font-size: 12px; color: #6b7280; }
.pr-preview .pr-meta-label { font-weight: 600; color: #374151; }
.pr-preview .pr-meta-badge { font-size: 13px; font-weight: 700; background: #9b1006; color: #fff; padding: 3px 14px; border-radius: 12px; }

/* Summary bar */
.pr-preview .pr-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 8px 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 12px;
}

.pr-preview .pr-stat { display: inline-flex; align-items: center; gap: 5px; }
.pr-preview .pr-stat-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }

/* Day sections */
.pr-preview .pr-day { margin-bottom: 18px; }
.pr-preview .pr-day-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 14px; background: linear-gradient(135deg, #9b1006 0%, #bf291d 100%);
    color: #fff; border-radius: 6px; margin-bottom: 10px;
}
.pr-preview .pr-day-name { font-size: 14px; font-weight: 700; }
.pr-preview .pr-day-badge { font-size: 11px; font-weight: 600; background: rgba(255,255,255,0.2); padding: 2px 12px; border-radius: 10px; }



/* User groups */
.pr-preview .pr-user-group { margin-bottom: 14px; border: 1.5px solid #d1d5db; border-radius: 8px; padding: 10px 12px; background: #fff; }
.pr-preview .pr-user-bar { display: flex; align-items: center; gap: 8px; padding: 4px 0; margin-bottom: 6px; border-bottom: 1.5px solid #e5e7eb; }
.pr-preview .pr-user-avatar { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: #9b1006; color: #fff; font-size: 10px; font-weight: 700; }
.pr-preview .pr-user-name { font-size: 13px; font-weight: 700; color: #1f2937; }
.pr-preview .pr-user-count { font-size: 11px; font-weight: 600; background: #f3f4f6; padding: 2px 10px; border-radius: 10px; color: #4b5563; margin-left: auto; }

/* Equipe field in user bar (screen) */
.pr-user-equipe {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    flex: 0 0 auto;
}

.pr-equipe-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}

.pr-equipe-input {
    width: 180px;
    min-height: 28px !important;
    max-height: 60px;
    font-size: 11px !important;
    padding: 4px 8px !important;
}

/* Equipe in user bar (print) */
.pr-user-equipe-print {
    margin-left: 12px;
    font-size: 13px;
    color: #374151;
}

/* Table */
.pr-preview .pr-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.pr-preview .pr-table th { padding: 6px 6px; text-align: left; font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px; color: #6b7280; border-bottom: 2px solid #9b1006; white-space: nowrap; background: #f9fafb; }
.pr-preview .pr-table td { padding: 5px 6px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; word-break: break-word; }
.pr-preview .pr-table tbody tr:nth-child(even) { background: #fafbfc; }
.pr-preview .pr-table tbody tr:hover { background: #f0f4ff; }

/* Column widths (screen preview — 4 columns) */
.pr-preview .pr-col-customer { width: 20%; }
.pr-preview .pr-col-desc     { width: 30%; }
.pr-preview .pr-col-type     { width: 15%; }
.pr-preview .pr-col-address  { width: 35%; }



/* Badges */
.pr-preview .pr-badge-status { display: inline-block; padding: 2px 8px; border-radius: 4px; color: #fff; font-size: 10px; font-weight: 600; white-space: nowrap; }
.pr-preview .pr-badge-prio { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; white-space: nowrap; }
.pr-preview .pr-badge-prio.prt-alta { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.pr-preview .pr-badge-prio.prt-media { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.pr-preview .pr-badge-prio.prt-baixa { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

/* Editable textarea cells (screen only) */
.pr-input-cell {
    width: 100%;
    padding: 4px 6px;
    border: 1px dashed #d1d5db;
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    color: #374151;
    background: #fffdf7;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    resize: vertical;
    min-height: 36px;
    max-height: 120px;
    line-height: 1.4;
}

.pr-input-cell:focus {
    border-color: #9b1006;
    border-style: solid;
    box-shadow: 0 0 0 2px rgba(155, 16, 6, 0.1);
    background: #fff;
}

.pr-input-cell::placeholder {
    color: #d1d5db;
    font-style: italic;
}

/* Equipe autocomplete dropdown */
.pr-user-equipe {
    position: relative;
}
.eq-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
    margin-top: 2px;
}
.eq-autocomplete-item {
    padding: 6px 12px;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    transition: background 0.1s;
}
.eq-autocomplete-item:hover {
    background: #fef2f2;
    color: #9b1006;
}

/* ── Outline Button ──────────────────────────────────────── */
.btn-outline {
    background: transparent;
    color: #9b1006;
    border: 1.5px solid #9b1006;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-outline:hover {
    background: #9b1006;
    color: #fff;
}

/* ── Print History Viewer ────────────────────────────────── */
.ph-container {
    max-width: 1100px;
    margin: 0 auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 24px 28px;
}
.ph-header-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #9b1006;
}
.ph-title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}
.ph-back-btn {
    flex-shrink: 0;
}
.ph-loading {
    text-align: center;
    padding: 32px;
    color: #6b7280;
    font-size: 14px;
}
.ph-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.ph-table thead th {
    background: #f9fafb;
    padding: 8px 12px;
    text-align: left;
    font-weight: 700;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ph-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
    vertical-align: top;
}
.ph-table tbody tr:hover {
    background: #fef2f2;
}
.ph-reprint-btn {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
}

/* Footer (screen) */
.pr-preview .pr-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; padding-top: 8px; border-top: 2px solid #9b1006; font-size: 11px; color: #9ca3af; }
.pr-preview .pr-footer-brand { flex: 1; text-align: left; font-weight: 700; color: #9b1006; }
.pr-preview .pr-footer-date  { flex: 1; text-align: center; }
.pr-preview .pr-footer-total { flex: 1; text-align: right; font-weight: 700; color: #374151; }

.print-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ══════════════════════════════════════════════════════════════
   @MEDIA PRINT — Professional Report Layout
   ══════════════════════════════════════════════════════════════ */

@media print {
    /* Hide everything except print container */
    body > *:not(#printContainer) {
        display: none !important;
    }

    #printContainer {
        display: block !important;
        position: static;
        width: 100%;
    }

    /* ── Report Root ─────────────────────────────────── */
    .pr-report {
        font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
        font-size: 9px;
        color: #1f2937;
        line-height: 1.4;
        padding: 0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ── Header ──────────────────────────────────────── */
    .pr-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        padding-bottom: 4px;
        border-bottom: 3px solid #9b1006;
        margin-bottom: 4px;
    }

    .pr-header-brand {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .pr-logo { height: 34px; object-fit: contain; }
    .pr-brand-name { font-size: 20px; font-weight: 800; color: #9b1006; margin: 0; line-height: 1; letter-spacing: -0.5px; }
    .pr-brand-sub { font-size: 10px; font-weight: 400; color: #6b7280; margin: 2px 0 0; }

    .pr-header-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
    .pr-meta-row { font-size: 8px; color: #6b7280; }
    .pr-meta-label { font-weight: 600; color: #374151; }
    .pr-meta-badge { display: inline-block; font-size: 10px; font-weight: 700; background: #9b1006; color: #fff; padding: 2px 10px; border-radius: 10px; margin-top: 2px; }

    /* ── Summary Bar ─────────────────────────────────── */
    .pr-summary {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        padding: 3px 10px;
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-radius: 4px;
        margin-bottom: 4px;
        font-size: 8px;
    }

    .pr-stat { display: inline-flex; align-items: center; gap: 4px; }
    .pr-stat-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

    /* ── Day Section ─────────────────────────────────── */
    .pr-day {
        margin-bottom: 10px;
    }

    .pr-day-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 4px 10px;
        background: linear-gradient(135deg, #9b1006 0%, #bf291d 100%);
        color: #fff;
        border-radius: 4px;
        margin-bottom: 6px;
    }

    .pr-day-name { font-size: 11px; font-weight: 700; }
    .pr-day-badge { font-size: 8px; font-weight: 600; background: rgba(255,255,255,0.2); padding: 1px 8px; border-radius: 8px; }

    /* ── User Group ──────────────────────────────────── */
    .pr-user-group {
        margin-bottom: 8px;
        page-break-inside: avoid;
        border: 1.5px solid #d1d5db;
        border-radius: 6px;
        padding: 8px 10px;
        background: #fff;
    }

    .pr-user-bar {
        display: flex;
        align-items: center;
        gap: 5px;
        padding: 2px 0;
        margin-bottom: 3px;
        border-bottom: 1.5px solid #e5e7eb;
    }

    .pr-user-avatar { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: #9b1006; color: #fff; font-size: 7px; font-weight: 700; flex-shrink: 0; }
    .pr-user-name { font-size: 10px; font-weight: 700; color: #1f2937; }
    .pr-user-equipe-print { margin-left: 4px; font-size: 11px; color: #374151; }
    .pr-user-count { font-size: 8px; font-weight: 600; background: #f3f4f6; padding: 1px 6px; border-radius: 8px; color: #4b5563; margin-left: auto; }

    /* ── Table ────────────────────────────────────────── */
    .pr-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 8px;
        table-layout: fixed;
    }

    .pr-table thead tr { background: #f9fafb; }

    .pr-table th {
        padding: 3px 3px;
        text-align: left;
        font-weight: 700;
        font-size: 7px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        color: #6b7280;
        border-bottom: 2px solid #9b1006;
        white-space: nowrap;
    }

    .pr-table td {
        padding: 2px 3px;
        border-bottom: 1px solid #f3f4f6;
        vertical-align: middle;
        word-break: break-word;
    }

    .pr-table tbody tr:nth-child(even) { background: #fafbfc; }

    /* Column widths (print — 4 columns) */
    .pr-col-customer { width: 20%; }
    .pr-col-desc     { width: 30%; }
    .pr-col-type     { width: 15%; }
    .pr-col-address  { width: 35%; }

    /* Editable cell (printed as text, preserves line breaks) */
    .pr-editable-cell {
        font-style: italic;
        color: #374151;
        white-space: pre-line;
    }

    /* ── Status Badge ────────────────────────────────── */
    .pr-badge-status {
        display: inline-block;
        padding: 1px 5px;
        border-radius: 3px;
        color: #fff;
        font-size: 7px;
        font-weight: 600;
        white-space: nowrap;
    }

    /* ── Priority Badge ──────────────────────────────── */
    .pr-badge-prio {
        display: inline-block;
        padding: 1px 5px;
        border-radius: 3px;
        font-size: 7px;
        font-weight: 600;
        white-space: nowrap;
    }

    .pr-badge-prio.prt-alta { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
    .pr-badge-prio.prt-media { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
    .pr-badge-prio.prt-baixa { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

    /* ── Footer ──────────────────────────────────────── */
    .pr-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 12px;
        padding-top: 5px;
        border-top: 2px solid #9b1006;
        font-size: 7px;
        color: #9ca3af;
    }

    .pr-footer-brand { flex: 1; text-align: left; font-weight: 700; color: #9b1006; }
    .pr-footer-date  { flex: 1; text-align: center; }
    .pr-footer-total { flex: 1; text-align: right; font-weight: 700; color: #374151; }

    /* ── Page Settings ───────────────────────────────── */
    @page {
        margin: 8mm 6mm 14mm 6mm;
        size: A4 portrait;

        @bottom-left {
            content: "Lousa Engenharia 2.0 — Ts Teck";
            font-size: 7px;
            font-weight: 700;
            color: #9b1006;
        }

        @bottom-right {
            content: "Página " counter(page) " de " counter(pages);
            font-size: 7px;
            font-weight: 600;
            color: #374151;
        }
    }
}

/* ══════════════════════════════════════════════════════════════
   PERMISSION-BASED VISIBILITY
   ══════════════════════════════════════════════════════════════ */

[data-permission="write"] { display: none; }
[data-permission="admin"] { display: none; }

.role-editor [data-permission="write"],
.role-admin [data-permission="write"],
.role-admin [data-permission="admin"] {
    display: initial;
}

/* Buttons with data-permission should respect flex */
button[data-permission="write"],
.btn[data-permission="write"] {
    display: none;
}

.role-editor button[data-permission="write"],
.role-editor .btn[data-permission="write"],
.role-admin button[data-permission="write"],
.role-admin .btn[data-permission="write"] {
    display: inline-flex;
}

.role-admin [data-permission="admin"] {
    display: block;
}

/* Viewer can't drag */
.role-viewer .task-drag-handle { display: none !important; }
.role-viewer .task-item { cursor: default; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .app-header { padding: 0 10px; }
    .app-logo { margin-right: 10px; }
    .app-logo-text { display: none; }
    .nav-tab span { display: none; }
    .nav-tab { padding: 10px 12px; }
    .period-display span { display: none; }
    .period-display { padding: 6px 8px; }
    .control-divider { display: none; }
}

@media (max-width: 768px) {
    :root { --header-height: 48px; --controls-height: 42px; }
    .controls-bar { padding: 6px 8px; gap: 6px; }
    .btn { padding: 6px 10px; font-size: 12px; }
    .tickets-container { padding: 10px; }
    .ticket-stats { grid-template-columns: 1fr; }
    .user-container { padding: 10px; }
    .user-profile { flex-direction: column; text-align: center; }
    .admin-user-form { grid-template-columns: 1fr; }
    .modal-content { margin: 8px; border-radius: var(--radius-lg); }
    .modal-header { padding: 12px 14px; }
    .modal-body { padding: 12px 14px; }
    .form-row { flex-direction: column; }
}

/* ══════════════════════════════════════════════════════════════
   ANIMATION UTILITIES
   ══════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.fade-in { animation: fadeIn var(--transition-slow); }
.slide-up { animation: slideUp var(--transition-slow); }

/* ══════════════════════════════════════════════════════════════
   TOUCH SCREEN USABILITY
   ══════════════════════════════════════════════════════════════ */

/* Base touch-friendly defaults */
@media (pointer: coarse) {
    /* Remove hover-dependent effects on touch */
    .btn:hover,
    .task-item:hover,
    .ticket-card:hover,
    .ticket-stat-card:hover {
        transform: none;
    }

    * {
        -webkit-tap-highlight-color: transparent;
    }

    .task-cell,
    .ticket-list,
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }

    /* Buttons — 44px minimum tap target (WCAG 2.5.8) */
    .btn {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 14px;
    }

    .btn i { font-size: 15px; }

    .hamburger-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .sidebar-tab {
        padding: 14px 16px;
        font-size: 15px;
        min-height: 48px;
    }

    .period-display {
        min-height: 44px;
    }

    select, input[type="text"], input[type="email"], input[type="password"],
    input[type="number"], input[type="datetime-local"], input[type="date"],
    input[type="time"], textarea {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 16px;
    }

    .task-item {
        padding: 10px 12px 10px 14px;
        margin-bottom: 4px;
        font-size: 13px;
    }

    .task-drag-handle {
        opacity: 1;
        padding: 8px;
        right: 2px;
        font-size: 16px;
    }

    .task-cell {
        min-height: 48px;
        padding: 4px;
    }

    .cell-empty {
        min-height: 48px;
    }

    .modal-close {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .sidebar-close {
        width: 40px;
        height: 40px;
    }

    .metrics-tab {
        padding: 12px 20px;
        font-size: 14px;
        min-height: 44px;
    }

    .ticket-card {
        padding: 14px;
    }

    .controls-bar {
        gap: 8px;
        padding: 8px 12px;
    }

    .control-divider {
        margin: 0 4px;
    }

    .vehicle-marker {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .vehicle-plate-label {
        font-size: 10px;
        padding: 2px 5px;
    }

    .team-marker {
        width: 40px !important;
        height: 40px !important;
    }

    .team-marker-initials {
        font-size: 14px;
    }

    .team-marker-label {
        font-size: 10px;
        padding: 2px 6px;
    }

    .map-control-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    /* Enhanced touch drag — entire card is draggable on touch */
    .task-item {
        cursor: grab;
        touch-action: manipulation;
    }

    /* Touch-active state */
    .task-item:active {
        opacity: 0.9;
        transform: scale(0.98);
    }

    /* Better drag handle on touch */
    .task-drag-handle {
        width: 44px;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ── Touch drag clone styles ─────────────────────────────── */
.touch-drag-clone {
    border-radius: var(--radius);
    border: 2px solid var(--primary);
    background: var(--surface-0);
    transform: rotate(2deg);
}


/* ══════════════════════════════════════════════════════════════
   KANBAN BOARD — Minhas Tarefas
   ══════════════════════════════════════════════════════════════ */

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 0 0 32px;
    min-height: calc(100vh - 170px);
}

.kanban-column {
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
}

.kanban-column-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kanban-column-count {
    margin-left: auto;
    background: var(--gray-200);
    color: var(--gray-600);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.kanban-cards {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    min-height: 60px;
}

.kanban-cards.drag-over {
    background: var(--primary-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    transition: none !important;
}

.kanban-cards.drag-over > * {
    pointer-events: none;
}

.kanban-card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: grab;
    transition: box-shadow var(--transition), transform var(--transition-fast);
    position: relative;
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kanban-card.dragging {
    opacity: 0.6;
    transform: rotate(2deg);
    box-shadow: var(--shadow-lg);
    transition: none !important;
    pointer-events: none;
}

.kanban-card-label {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    margin-bottom: 8px;
}

.kanban-card-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--dark);
    line-height: 1.4;
    margin-bottom: 8px;
    word-break: break-word;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--gray-500);
}

.kanban-card-meta .badge-priority {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 10px;
}

.kanban-card-meta .badge-priority.p1 { background: #dcfce7; color: #166534; }
.kanban-card-meta .badge-priority.p2 { background: #fef9c3; color: #854d0e; }
.kanban-card-meta .badge-priority.p3 { background: #fee2e2; color: #991b1b; }
.kanban-card-meta .badge-priority.p4 { background: #dc2626; color: #fff; }

.kanban-card-meta .due-date {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.kanban-card-meta .due-date.overdue {
    color: var(--error);
    font-weight: 600;
}

.kanban-card-meta .assignee {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.kanban-card-meta .assignee-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
}

.kanban-card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 4px;
}

.kanban-card:hover .kanban-card-actions {
    display: flex;
}

.kanban-card-actions button {
    width: 24px;
    height: 24px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--gray-500);
    transition: all var(--transition-fast);
}

.kanban-card-actions button:hover {
    background: var(--gray-200);
    color: var(--dark);
}

.kanban-card-actions button.delete:hover {
    background: var(--error);
    color: white;
}

/* ── Kanban View Switcher ─────────────────────────────── */
.kanban-view-switcher {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.kanban-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 30px;
    border: none;
    background: var(--surface-0);
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition-fast);
}
.kanban-view-btn:not(:last-child) { border-right: 1px solid var(--border); }
.kanban-view-btn:hover { background: var(--gray-100); color: var(--text-primary); }
.kanban-view-btn.active { background: var(--primary); color: #fff; }

.kanban-view-panel { display: none; }
.kanban-view-panel.active { display: block; }

/* ── Kanban Agenda View ───────────────────────────────── */
.kanban-agenda {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    min-height: calc(100vh - 170px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface-0);
}
.kanban-agenda-sidebar {
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.kanban-agenda-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.kanban-agenda-month {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Mini calendar */
.kanban-mini-calendar {
    font-size: 12px;
}
.kanban-mini-calendar table {
    width: 100%;
    border-collapse: collapse;
}
.kanban-mini-calendar th {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    padding: 4px 0;
    text-align: center;
}
.kanban-mini-calendar td {
    text-align: center;
    padding: 2px;
}
.kanban-mini-cal-day {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
}
.kanban-mini-cal-day:hover { background: var(--gray-100); }
.kanban-mini-cal-day.today {
    font-weight: 700;
    color: #9b1006;
    box-shadow: inset 0 0 0 2px #9b1006;
}
.kanban-mini-cal-day.selected {
    background: #9b1006;
    color: #fff;
    font-weight: 700;
}
.kanban-mini-cal-day.has-tasks::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
}
.kanban-mini-cal-day.selected.has-tasks::after { background: #fff; }
.kanban-mini-cal-day.other-month { color: var(--gray-300); }
.kanban-mini-cal-day.weekend { color: var(--gray-400); }

/* Agenda stats */
.kanban-agenda-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.kanban-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}
.kanban-stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.kanban-stat-item strong {
    margin-left: auto;
    font-weight: 700;
    color: var(--text-primary);
}
.kanban-stat-overdue strong { color: #f59e0b; }

/* Agenda main */
.kanban-agenda-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.kanban-agenda-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-0);
}
.kanban-agenda-day-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.kanban-agenda-day-count {
    font-size: 12px;
    color: var(--text-tertiary);
    background: var(--gray-100);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-weight: 600;
}
.kanban-agenda-timeline {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.kanban-agenda-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--gray-400);
    font-size: 13px;
    text-align: center;
}

/* Agenda task item */
.kanban-agenda-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-0);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 4px solid transparent;
}
.kanban-agenda-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--border-strong);
}
.kanban-agenda-item.status-pendente { border-left-color: #dc2626; }
.kanban-agenda-item.status-em_andamento { border-left-color: #2563eb; }
.kanban-agenda-item.status-concluida { border-left-color: #16a34a; opacity: 0.7; }
.kanban-agenda-item.status-cancelada { border-left-color: #71717a; opacity: 0.5; }
.kanban-agenda-item-body { flex: 1; min-width: 0; }
.kanban-agenda-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}
.kanban-agenda-item-desc {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.4;
    max-height: 32px;
    overflow: hidden;
}
.kanban-agenda-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--gray-500);
    flex-wrap: wrap;
}
.kanban-agenda-item-priority {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 10px;
}
.kanban-agenda-item-priority.p1 { background: #dcfce7; color: #166534; }
.kanban-agenda-item-priority.p2 { background: #fef9c3; color: #854d0e; }
.kanban-agenda-item-priority.p3 { background: #fee2e2; color: #991b1b; }
.kanban-agenda-item-priority.p4 { background: #dc2626; color: #fff; }
.kanban-agenda-item .assignee-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}
.kanban-agenda-item .assignee-chip .assignee-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
}

/* Responsive kanban agenda */
@media (max-width: 768px) {
    .kanban-agenda {
        grid-template-columns: 1fr;
    }
    .kanban-agenda-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

/* ══════════════════════════════════════════════════════════════
   AUDIT LOG — Histórico de Alterações
   ══════════════════════════════════════════════════════════════ */

.audit-log-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0 16px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}

.audit-log-entry {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-0);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    transition: background var(--transition-fast);
}

.audit-log-entry:hover {
    background: var(--surface-1);
}

.audit-log-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    font-size: 14px;
}

.audit-log-content {
    flex: 1;
    min-width: 0;
}

.audit-log-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.audit-log-action {
    font-size: 13px;
    font-weight: 700;
}

.audit-log-entity {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-2);
    padding: 1px 8px;
    border-radius: var(--radius-sm);
}

.audit-log-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 4px;
    word-break: break-word;
}

.audit-log-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.audit-log-meta i {
    margin-right: 4px;
    font-size: 10px;
}

.audit-log-toggle {
    align-self: center;
    padding: 4px 8px !important;
    font-size: 11px;
    color: var(--text-tertiary);
}

.audit-log-details {
    margin: -2px 0 4px 48px;
    padding: 10px 14px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    font-size: 12px;
}

.audit-details-inner {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.audit-detail-block {
    flex: 1;
    min-width: 200px;
}

.audit-detail-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.audit-detail-label i {
    margin-right: 4px;
}

.audit-detail-data {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
    color: var(--text-primary);
}

.audit-log-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    gap: 12px;
}

.audit-pagination-info {
    font-size: 12px;
    color: var(--text-tertiary);
}

.audit-pagination-btns {
    display: flex;
    gap: 4px;
}

/* ══════════════════════════════════════════════════════════════
   ADMIN USERS GRID
   ══════════════════════════════════════════════════════════════ */

.admin-users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    padding: 0 0 32px;
}

.user-card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow var(--transition);
}

.user-card:hover {
    box-shadow: var(--shadow-md);
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-email {
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.user-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.user-badge.admin {
    background: var(--primary-100);
    color: var(--primary);
}

.user-badge.editor {
    background: #dbeafe;
    color: #1e40af;
}

.user-badge.viewer {
    background: var(--gray-100);
    color: var(--gray-600);
}

.user-badge.active {
    background: #dcfce7;
    color: #166534;
}

.user-badge.inactive {
    background: #fee2e2;
    color: #991b1b;
}

.user-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.user-card-actions button {
    flex: 1;
    padding: 6px 0;
    border: 1px solid var(--border);
    background: var(--surface-0);
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--gray-600);
    transition: all var(--transition-fast);
}

.user-card-actions button:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--dark);
}

.user-card-actions button.danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* Permissions Grid */
.permissions-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface-1);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.permission-item:hover {
    border-color: var(--primary-200);
    background: var(--primary-50);
}

.permission-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.permission-item i {
    width: 20px;
    text-align: center;
    color: var(--gray-500);
    font-size: 14px;
}

.permission-item span {
    font-size: 13px;
    font-weight: 500;
}

/* Color picker */
.color-picker-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: var(--dark);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--dark);
}

/* Comments */
.comments-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0;
}

.comment-item {
    padding: 8px 12px;
    background: var(--surface-1);
    border-radius: var(--radius);
    font-size: 12px;
}

.comment-item .comment-author {
    font-weight: 600;
    color: var(--primary);
    margin-right: 6px;
}

.comment-item .comment-date {
    color: var(--gray-400);
    font-size: 10px;
    float: right;
}

.comment-input-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* User modal tabs */
.user-tab-content {
    padding-top: 16px;
}

/* Sidebar divider */
.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 12px;
}

/* User card last access */
.user-card-last-access {
    font-size: 11px;
    color: var(--gray-400);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ══════════════════════════════════════════════════════════════
   KANBAN RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .kanban-board {
        grid-template-columns: 1fr;
    }
    
    .admin-users-grid {
        grid-template-columns: 1fr;
    }
}
