/* ============================================================
   TomFit Maintenance Dashboard — Branded Stylesheet
   Matches the machine_dashboard TomFit branding:
   
   Brand green (tomfit):
     50: #ecfdf3 | 100: #d1fae1 | 200: #a7f3c9 | 300: #6ee7a8
     400: #50c878 | 500: #34b466 | 600: #22964f | 700: #1a7a41
     800: #186137 | 900: #154f2e

   Charcoal:
     50: #f6f7f8 | 100: #ebedf0 | 200: #d3d7de | 300: #adb5c1
     400: #82899a | 500: #636b7e | 600: #4e5568 | 700: #404555
     800: #373b48 | 900: #32373c | 950: #1e2127

   Font: Outfit
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* TomFit green (shared across themes) */
    --tomfit-50: #ecfdf3;
    --tomfit-100: #d1fae1;
    --tomfit-200: #a7f3c9;
    --tomfit-300: #6ee7a8;
    --tomfit-400: #50c878;
    --tomfit-500: #34b466;
    --tomfit-600: #22964f;
    --tomfit-700: #1a7a41;
    --tomfit-800: #186137;
    --tomfit-900: #154f2e;

    /* Charcoal (shared across themes) */
    --charcoal-50: #f6f7f8;
    --charcoal-100: #ebedf0;
    --charcoal-200: #d3d7de;
    --charcoal-300: #adb5c1;
    --charcoal-400: #82899a;
    --charcoal-500: #636b7e;
    --charcoal-600: #4e5568;
    --charcoal-700: #404555;
    --charcoal-800: #373b48;
    --charcoal-900: #32373c;
    --charcoal-950: #1e2127;

    /* Shared constants */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.2s ease;
}

/* ══════════════════════════════════════════
   DARK THEME (default)
   ══════════════════════════════════════════ */
:root,
[data-theme="dark"] {
    --accent: var(--tomfit-400);
    --accent-hover: var(--tomfit-300);
    --accent-glow: rgba(80, 200, 120, 0.15);
    --accent-glow-strong: rgba(80, 200, 120, 0.5);
    --accent-on: var(--charcoal-950);

    --success: #06D6A0;
    --success-bg: rgba(6, 214, 160, 0.1);
    --warning: #FFD166;
    --warning-bg: rgba(255, 209, 102, 0.1);
    --error: #EF476F;
    --error-bg: rgba(239, 71, 111, 0.1);
    --info: var(--tomfit-400);
    --info-bg: rgba(80, 200, 120, 0.1);

    --bg: var(--charcoal-950);
    --bg-card: var(--charcoal-900);
    --bg-card-hover: var(--charcoal-800);
    --bg-input: var(--charcoal-800);
    --bg-thead: var(--charcoal-800);
    --border: var(--charcoal-800);
    --border-light: var(--charcoal-700);
    --border-input: var(--charcoal-700);

    --text-primary: #f3f4f6;
    --text-secondary: var(--charcoal-300);
    --text-muted: var(--charcoal-400);
    --text-faint: var(--charcoal-500);
    --text-dark: var(--charcoal-950);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(80, 200, 120, 0.2);

    --scrollbar-track: #1e2127;
    --scrollbar-thumb: #404555;
    --scrollbar-thumb-hover: #4e5568;

    --modal-overlay: rgba(30, 33, 39, 0.7);
    --login-glow: rgba(80, 200, 120, 0.05);

    --status-open-text: #e5b94e;
    --status-closed-bg: rgba(99, 107, 126, 0.15);
    --priority-high: #E85D04;

    --logo-filter: none;
}

/* ══════════════════════════════════════════
   LIGHT THEME
   ══════════════════════════════════════════ */
[data-theme="light"] {
    --accent: var(--tomfit-600);
    --accent-hover: var(--tomfit-500);
    --accent-glow: rgba(34, 150, 79, 0.1);
    --accent-glow-strong: rgba(34, 150, 79, 0.35);
    --accent-on: #ffffff;

    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.08);
    --warning: #b45309;
    --warning-bg: rgba(180, 83, 9, 0.08);
    --error: #be123c;
    --error-bg: rgba(190, 18, 60, 0.08);
    --info: var(--tomfit-600);
    --info-bg: rgba(34, 150, 79, 0.08);

    --bg: #eef1f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f4f5f7;
    --bg-input: #ffffff;
    --bg-thead: #f3f4f6;
    --border: #d1d5db;
    --border-light: #b8bec8;
    --border-input: #b8bec8;

    --text-primary: #0f172a;
    --text-secondary: #374151;
    --text-muted: #4b5563;
    --text-faint: #6b7280;
    --text-dark: #0f172a;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(34, 150, 79, 0.15);

    --scrollbar-track: #e5e7eb;
    --scrollbar-thumb: #b8bec8;
    --scrollbar-thumb-hover: #6b7280;

    --modal-overlay: rgba(17, 24, 39, 0.4);
    --login-glow: rgba(80, 200, 120, 0.08);

    --status-open-text: #B45309;
    --status-closed-bg: rgba(107, 114, 128, 0.1);
    --priority-high: #EA580C;

    --logo-filter: none;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden {
    display: none !important;
}

/* Role-based visibility */
body:not([data-role="admin"]) .role-admin-only {
    display: none !important;
}

body:not([data-superadmin="true"]) .role-superadmin-only {
    display: none !important;
}

/* Role manager form */
.role-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
}

.role-add-form {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.role-entry-row {
    background: color-mix(in srgb, var(--bg-input) 82%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.role-add-form input,
.role-add-form select {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
}

.role-add-form input { flex: 1; min-width: 140px; }

.role-incharge-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-right: 8px;
    min-width: 92px;
}

.role-incharge-toggle input[type="checkbox"] {
    margin: 0;
}

.role-add-form input:focus,
.role-add-form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(80,200,120,0.12);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-glow-strong), 0 0 0 4px var(--bg);
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-on);
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--accent-hover);
}
.btn-primary:active {
    background: var(--tomfit-500);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-input);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-icon {
    padding: 6px;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
}
.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* ── Login Screen ── */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    position: relative;
    overflow: hidden;
    padding: 16px;
}

/* Subtle green glow */
.login-screen::before {
    content: '';
    position: fixed;
    top: 33%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    background: var(--login-glow);
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
}

.login-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-logo {
    margin-bottom: 24px;
}

.login-logo img {
    height: 40px;
    margin: 0 auto;
}

.login-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
    line-height: 1.6;
}

.btn-login {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    justify-content: center;
}

.ms-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.login-hint {
    margin-top: 20px;
    font-size: 0.8rem;
    color: var(--text-faint);
}

/* Logo inversion for light theme */
.login-logo img,
.nav-logo {
    filter: var(--logo-filter);
}

/* ── Top Navigation ── */
.top-nav {
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-logo {
    height: 32px;
}

.nav-divider {
    width: 1px;
    height: 32px;
    background: var(--border-light);
}

.nav-title {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.nav-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.sync-icon {
    font-size: 18px;
}

.sync-icon.spinning {
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.sync-status.synced {
    color: var(--accent);
}

.sync-status.error {
    color: var(--error);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-on);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-name {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
}

.top-nav .btn-icon:hover {
    color: var(--error);
    background: var(--error-bg);
}

/* ── Main Content ── */
.main-content {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Stats Bar ── */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.stat-clickable {
    cursor: pointer;
}

.stat-clickable:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.stat-clickable:active {
    transform: translateY(0);
}

.stat-card:hover {
    border-color: var(--border-light);
}

.stat-active {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 1px var(--accent), var(--shadow-glow) !important;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon .material-symbols-rounded {
    font-size: 24px;
}

.stat-icon-total {
    background: var(--info-bg);
    color: var(--accent);
}

.stat-icon-open {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-icon-progress {
    background: rgba(80, 200, 120, 0.1);
    color: var(--accent);
}

.stat-icon-resolved {
    background: var(--success-bg);
    color: var(--success);
}

.stat-icon-critical {
    background: var(--error-bg);
    color: var(--error);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Toolbar ── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-count {
    background: var(--accent-glow);
    color: var(--accent);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-faint);
    font-size: 20px;
    pointer-events: none;
}

.search-input {
    padding: 10px 12px 10px 40px;
    width: 260px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-input);
    transition: all var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow-strong);
}

.search-input::placeholder {
    color: var(--text-faint);
}

.filter-group {
    display: flex;
    gap: 8px;
}

.filter-select {
    padding: 10px 32px 10px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2382899a'/%3E%3C/svg%3E") no-repeat right 12px center;
    appearance: none;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow-strong);
}

/* ── Table ── */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow-x: auto;
}

.tickets-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* Column widths — 10 columns */
.tickets-table th:nth-child(1),
.tickets-table td:nth-child(1) { width: 42px; }    /* ID */
.tickets-table th:nth-child(2),
.tickets-table td:nth-child(2) { width: auto; }    /* Title — remaining space */
.tickets-table th:nth-child(3),
.tickets-table td:nth-child(3) { width: 90px; }    /* TomBot SN */
.tickets-table th:nth-child(4),
.tickets-table td:nth-child(4) { width: 80px; }    /* Status */
.tickets-table th:nth-child(5),
.tickets-table td:nth-child(5) { width: 95px; }    /* Issue Type */
.tickets-table th:nth-child(6),
.tickets-table td:nth-child(6) { width: 70px; }    /* Priority */
.tickets-table th:nth-child(7),
.tickets-table td:nth-child(7) { width: 90px; }    /* Reporter */
.tickets-table th:nth-child(8),
.tickets-table td:nth-child(8) { width: 90px; }    /* In Charge */
.tickets-table th:nth-child(9),
.tickets-table td:nth-child(9) { width: 70px; }    /* Created */
.tickets-table th:nth-child(10),
.tickets-table td:nth-child(10) { width: 70px; }   /* Last Updated */

.tickets-table thead {
    background: var(--bg-thead);
    border-bottom: 1px solid var(--border);
}

.tickets-table th {
    padding: 12px 10px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    user-select: none;
}

.th-sortable {
    cursor: pointer;
    transition: color var(--transition);
}

.th-sortable:hover {
    color: var(--accent);
}

.sort-icon {
    font-size: 16px;
    vertical-align: middle;
    opacity: 0.4;
}

.th-sortable:hover .sort-icon {
    opacity: 1;
}

.tickets-table td {
    padding: 12px 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.tickets-table tbody tr {
    transition: background var(--transition);
    cursor: pointer;
}

.tickets-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.tickets-table tbody tr:last-child td {
    border-bottom: none;
}

.ticket-id {
    font-weight: 600;
    color: var(--accent);
    font-size: 0.85rem;
}

.ticket-title {
    font-weight: 500;
    color: var(--text-primary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket-machine {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.machine-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.machine-location {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.ticket-reporter {
    color: var(--text-secondary);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.ticket-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-open {
    background: var(--warning-bg);
    color: var(--status-open-text);
}
.status-open::before { background: var(--warning); }

.status-in-progress {
    background: var(--accent-glow);
    color: var(--accent);
}
.status-in-progress::before { background: var(--accent); }

.status-resolved {
    background: var(--success-bg);
    color: var(--success);
}
.status-resolved::before { background: var(--success); }

.status-closed {
    background: var(--status-closed-bg);
    color: var(--text-muted);
}
.status-closed::before { background: var(--text-muted); }

/* Priority badges */
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.priority-critical {
    color: var(--error);
}
.priority-high {
    color: var(--priority-high);
}
.priority-medium {
    color: var(--warning);
}
.priority-low {
    color: var(--text-muted);
}

/* ── Issue Type Badges ── */
.issue-type-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.issue-type-hardware {
    background: rgba(239, 71, 111, 0.12);
    color: #EF476F;
    border-color: rgba(239, 71, 111, 0.25);
}

.issue-type-hub {
    background: rgba(255, 209, 102, 0.12);
    color: #FFD166;
    border-color: rgba(255, 209, 102, 0.25);
}

.issue-type-software {
    background: rgba(6, 214, 160, 0.12);
    color: #06D6A0;
    border-color: rgba(6, 214, 160, 0.25);
}

.issue-type-software-tomconnect {
    background: rgba(99, 102, 241, 0.12);
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.25);
}

.issue-type-software-tomly {
    background: rgba(6, 182, 212, 0.12);
    color: #06b6d4;
    border-color: rgba(6, 182, 212, 0.25);
}

/* ── Empty & Loading States ── */
.empty-state, .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
}

.empty-icon {
    font-size: 64px;
    color: var(--text-faint);
    opacity: 0.4;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.loading-state p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ── Top loading bar (like machine_dashboard) ── */
.top-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    height: 2px;
    background: var(--charcoal-800);
    overflow: hidden;
}

.top-loading-bar-inner {
    height: 100%;
    background: var(--accent);
    animation: loadingBar 1.8s ease-in-out infinite;
}

@keyframes loadingBar {
    0% { width: 0%; margin-left: 0%; }
    20% { width: 40%; margin-left: 0%; }
    50% { width: 30%; margin-left: 40%; }
    80% { width: 40%; margin-left: 60%; }
    100% { width: 0%; margin-left: 100%; }
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-close {
    color: var(--text-muted);
}
.modal-close:hover {
    color: var(--error);
    background: var(--error-bg);
}

.modal-body {
    padding: 28px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.detail-description {
    margin-top: 4px;
}

.detail-description .detail-value {
    font-weight: 400;
    line-height: 1.7;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ── Attachments in Modal ── */
.attachments-section {
    margin-top: 20px;
}

.attachments-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.attachments-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.attachments-title .material-symbols-rounded {
    color: var(--accent);
}

/* Image gallery grid */
.attachment-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.attachment-thumb {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.attachment-thumb:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
    transform: scale(1.02);
}

.attachment-thumb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.attachment-thumb-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-faint);
    font-size: 0.75rem;
    text-align: center;
    padding: 8px;
}

.attachment-thumb-error .material-symbols-rounded {
    font-size: 32px;
    opacity: 0.4;
}

.attachment-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

/* File attachment rows */
.attachment-files {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.attachment-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.attachment-file:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.attachment-file-icon {
    font-size: 20px;
    color: var(--accent);
    flex-shrink: 0;
}

.attachment-file-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.attachment-file-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.attachment-download {
    flex-shrink: 0;
}

/* Attachment indicator in table */
.attachment-indicator {
    font-size: 15px;
    color: var(--text-faint);
    vertical-align: middle;
    margin-left: 4px;
}

/* ── Image Lightbox ── */
.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
    cursor: pointer;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    cursor: default;
}

.lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
    margin-bottom: 8px;
}

.lightbox-name {
    color: #f3f4f6;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.8;
}

.lightbox-close {
    color: #f3f4f6 !important;
}

.lightbox-close:hover {
    color: var(--error) !important;
    background: rgba(239, 71, 111, 0.2) !important;
}

.lightbox-img {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* ── Comments Section ── */
.comments-section {
    margin-top: 4px;
}

.comments-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.comments-title .material-symbols-rounded {
    color: var(--accent);
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-on);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}

.comment-content {
    flex: 1;
    min-width: 0;
}

.comment-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.comment-author {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comment-time {
    font-size: 0.75rem;
    color: var(--text-faint);
}

.comment-text {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
    word-break: break-word;
}

/* ── Comment Compose ── */
.comment-compose {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    position: relative;
}

.comment-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--text-primary);
    background: var(--bg-input);
    resize: vertical;
    min-height: 44px;
    transition: border-color var(--transition);
    line-height: 1.5;
}

.comment-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow-strong);
}

.comment-input::placeholder {
    color: var(--text-faint);
}

.comment-compose-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.comment-mention-hint {
    margin-top: 6px;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.comment-mention-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 48px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 20;
    max-height: 220px;
    overflow-y: auto;
}

.mention-option {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    font-family: inherit;
    font-size: 0.84rem;
    cursor: pointer;
}

.mention-option:last-child { border-bottom: none; }
.mention-option:hover,
.mention-option.active {
    background: var(--accent-glow);
}

.mention-option-name {
    font-weight: 600;
}

.mention-option-email {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.btn-sm {
    padding: 6px 14px !important;
    font-size: 0.8rem !important;
}

/* ── Issue Picture ── */
.issue-picture-container {
    margin-top: 6px;
}

.issue-picture {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.issue-picture:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    max-width: 400px;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.toast-success .material-symbols-rounded { color: var(--success); }
.toast.toast-error .material-symbols-rounded { color: var(--error); }
.toast.toast-info .material-symbols-rounded { color: var(--accent); }
.toast.toast-warning .material-symbols-rounded { color: var(--warning); }

.toast .material-symbols-rounded {
    font-size: 22px;
    flex-shrink: 0;
}

/* ── Highlight animation for updated rows ── */
@keyframes rowHighlight {
    0% { background: var(--accent-glow); }
    100% { background: transparent; }
}

.row-updated {
    animation: rowHighlight 2s ease;
}

.row-new {
    animation: rowHighlight 3s ease;
}

/* ── Theme Toggle ── */
.theme-toggle {
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-family: inherit;
}

.theme-toggle:hover {
    background: var(--bg-card-hover);
    color: var(--accent);
    border-color: var(--accent);
}

.theme-toggle .material-symbols-rounded {
    font-size: 20px;
}

/* ── View Tabs ── */
.view-tabs-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tombot-filter {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tombot-filter .filter-select {
    min-width: 140px;
}

.view-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    width: fit-content;
}

.view-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
}

.view-tab .material-symbols-rounded {
    font-size: 18px;
}

.view-tab:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.view-tab.active {
    color: var(--accent-on);
    background: var(--accent);
    font-weight: 600;
}

/* ── Statistics View ── */
.stats-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.stats-toolbar-right {
    display: flex;
    gap: 8px;
}

/* Issue Type Quick-Filter Pills */
.stats-type-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stats-type-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.stats-type-pill .material-symbols-rounded {
    font-size: 18px;
}

.stats-type-pill:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.stats-type-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(80, 200, 120, 0.25);
}
.stats-type-pill[data-type="Hardware"].active  { background: #f97316; border-color: #f97316; box-shadow: 0 2px 8px rgba(249,115,22,0.3); }
.stats-type-pill[data-type="Hub"].active       { background: #06b6d4; border-color: #06b6d4; box-shadow: 0 2px 8px rgba(6,182,212,0.3); }
.stats-type-pill[data-type="Admin TomFit"].active  { background: #ef476f; border-color: #ef476f; box-shadow: 0 2px 8px rgba(239,71,111,0.3); }
.stats-type-pill[data-type="Admin User"].active    { background: #f87171; border-color: #f87171; box-shadow: 0 2px 8px rgba(248,113,113,0.3); }
.stats-type-pill[data-type="Software - General"].active  { background: #22c55e; border-color: #22c55e; box-shadow: 0 2px 8px rgba(34,197,94,0.3); }
.stats-type-pill[data-type="Software - Tomly"].active    { background: #16a34a; border-color: #16a34a; box-shadow: 0 2px 8px rgba(22,163,74,0.3); }
.stats-type-pill[data-type="Software - TomConnect"].active { background: #0d9488; border-color: #0d9488; box-shadow: 0 2px 8px rgba(13,148,136,0.3); }
.stats-type-pill[data-type="Hardware"]:hover   { border-color: #f97316; color: #f97316; }
.stats-type-pill[data-type="Hub"]:hover        { border-color: #06b6d4; color: #06b6d4; }
.stats-type-pill[data-type="Admin TomFit"]:hover  { border-color: #ef476f; color: #ef476f; }
.stats-type-pill[data-type="Admin User"]:hover    { border-color: #f87171; color: #f87171; }
.stats-type-pill[data-type="Software - General"]:hover  { border-color: #22c55e; color: #22c55e; }
.stats-type-pill[data-type="Software - Tomly"]:hover    { border-color: #16a34a; color: #16a34a; }
.stats-type-pill[data-type="Software - TomConnect"]:hover { border-color: #0d9488; color: #0d9488; }

/* KPI Row */
.stats-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stats-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    transition: all var(--transition);
}

.stats-kpi:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.stats-kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stats-kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: all var(--transition);
}

.chart-card:hover {
    border-color: var(--border-light);
}

.chart-card-wide {
    grid-column: 1 / -1;
}

.chart-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.chart-title-with-control {
    flex-wrap: wrap;
}

.timeline-mode-select {
    margin-left: auto;
    min-width: 260px;
    width: auto;
    font-size: 0.82rem;
    padding: 8px 12px;
}

.chart-title .material-symbols-rounded {
    font-size: 20px;
    color: var(--accent);
}

.chart-container {
    position: relative;
    height: 280px;
}

.chart-container-wide {
    height: 320px;
}

.chart-loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    opacity: 0.7;
}

@media (max-width: 900px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .chart-card-wide {
        grid-column: 1;
    }
    .timeline-mode-select {
        margin-left: 0;
        min-width: 100%;
        width: 100%;
    }
    .stats-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .stats-kpi-row {
        grid-template-columns: 1fr 1fr;
    }
    .chart-container,
    .chart-container-wide {
        height: 240px;
    }
}

/* ── Footer ── */
.dashboard-footer {
    margin-top: 32px;
    border-top: 1px solid var(--border);
    padding: 16px 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-faint);
}

/* ── Smooth theme transition ── */
body,
body * {
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
    .stats-bar {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .toolbar-right {
        width: 100%;
    }
    .search-input {
        width: 100%;
    }
    .filter-group {
        flex-wrap: wrap;
        width: 100%;
    }
    .filter-select {
        flex: 1;
        min-width: 120px;
    }
    .top-nav {
        padding: 0 16px;
    }
    .nav-title {
        display: none;
    }
    .nav-divider:first-of-type {
        display: none;
    }
}

@media (max-width: 640px) {
    html {
        font-size: 13px;
    }
    .stats-bar {
        grid-template-columns: 1fr;
    }
    .main-content {
        padding: 16px;
    }
    .top-nav {
        height: 56px;
    }
    .user-name {
        display: none;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .table-container {
        overflow-x: auto;
    }
    .tickets-table {
        min-width: 900px;
    }
}

/* ══════════════════════════════════════
   Features & Guide Panel
   ══════════════════════════════════════ */
.btn-features {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-features:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.features-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.features-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 480px;
    z-index: 91;
    background: var(--bg);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    animation: slideInRight 0.25s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.features-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    backdrop-filter: blur(8px);
}

.features-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.features-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.features-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.features-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.features-intro {
    padding: 20px 24px 8px;
}

.features-intro p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    background: rgba(80, 200, 120, 0.06);
    border: 1px solid rgba(80, 200, 120, 0.15);
    border-radius: 12px;
    padding: 14px 18px;
}

.features-intro strong {
    color: var(--accent);
}

.features-list {
    padding: 12px 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ── Feature Item ── */
.feature-item {
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    overflow: hidden;
}

.feature-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    font-family: inherit;
}
.feature-toggle:hover {
    background: var(--bg-hover);
}

.feature-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(80, 200, 120, 0.1);
    flex-shrink: 0;
}
.feature-icon .material-symbols-rounded {
    font-size: 18px;
    color: var(--accent);
}

.feature-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.feature-chevron {
    font-size: 20px;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.feature-item.expanded .feature-chevron {
    transform: rotate(180deg);
}

.feature-body {
    display: none;
    padding: 0 16px 16px 62px;
}
.feature-item.expanded .feature-body {
    display: block;
}

.feature-body p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.feature-body ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.feature-body li {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
    padding-left: 14px;
    position: relative;
}

.feature-body li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(80, 200, 120, 0.5);
}

.feature-body li strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ══════════════════════════════════════
   QR Codes View
   ══════════════════════════════════════ */
.qr-view-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 12px;
}

.qr-view-actions {
    display: flex;
    gap: 8px;
}

.qr-view-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.qr-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ── QR Card ── */
.qr-dash-card {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    padding: 20px 20px 16px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.qr-dash-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

/* Green corner accents */
.qr-dash-corners { position: absolute; inset: 0; pointer-events: none; }
.qr-c {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--accent);
    border-style: solid;
    border-width: 0;
}
.qr-c-tl { top: 10px; left: 10px; border-top-width: 4px; border-left-width: 4px; border-radius: 8px 0 0 0; }
.qr-c-tr { top: 10px; right: 10px; border-top-width: 4px; border-right-width: 4px; border-radius: 0 8px 0 0; }
.qr-c-bl { bottom: 10px; left: 10px; border-bottom-width: 4px; border-left-width: 4px; border-radius: 0 0 0 8px; }
.qr-c-br { bottom: 10px; right: 10px; border-bottom-width: 4px; border-right-width: 4px; border-radius: 0 0 8px 0; }

/* Logo overlay */
.qr-dash-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -75%);
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 6px;
    padding: 3px;
    z-index: 2;
    pointer-events: none;
}
.qr-dash-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.qr-dash-canvas {
    display: block;
    margin: 0 auto;
    border-radius: 8px;
}

.qr-dash-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 10px;
}

.qr-dash-label {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a1d23;
}

.qr-dash-sn {
    font-size: 0.75rem;
    font-weight: 500;
    color: #82899a;
}

.qr-dash-hub {
    font-size: 0.72rem;
    color: #50c878;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ══════════════════════════════════════
   Notifications View
   ══════════════════════════════════════ */
.notif-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}

.notif-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
    line-height: 1.5;
}

.notif-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.notif-empty p { margin: 8px 0; }

/* Location card */
.notif-loc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.notif-loc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.notif-loc-header h3 {
    margin: 0;
    font-size: 1rem;
    flex: 1;
}

.notif-loc-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

.notif-loc-body { padding: 12px 20px 16px; }

.notif-role-group { margin-bottom: 14px; }
.notif-role-group:last-child { margin-bottom: 0; }

.notif-role-group h4 {
    margin: 0 0 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.notif-empty-loc {
    color: var(--text-muted);
    font-size: 0.88rem;
    padding: 8px 0;
}

/* Person row */
.notif-person-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.notif-person-row:last-child { border-bottom: none; }

.notif-person-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
    flex: 1;
}

.notif-person-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.notif-person-name {
    font-weight: 600;
    font-size: 0.92rem;
    margin-right: 6px;
}

.notif-person-role-badge {
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.notif-role-hub-manager { background: rgba(80,200,120,0.15); color: var(--accent); }
.notif-role-technician  { background: rgba(59,130,246,0.15); color: #3b82f6; }
.notif-role-admin       { background: rgba(168,85,247,0.15); color: #a855f7; }
.notif-role-ticket-creator { background: rgba(245,158,11,0.16); color: #f59e0b; }

.notif-person-channel {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 140px;
}

.notif-person-contact {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.notif-person-triggers {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 120px;
}

.notif-person-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition);
}

.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon-danger:hover { background: rgba(239,68,68,0.12); color: #ef4444; }

/* Notification modal */
.notif-modal {
    max-width: 520px;
}

.notif-modal .form-row {
    margin-bottom: 16px;
}

.notif-modal .form-row label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.notif-modal .form-row input[type="text"],
.notif-modal .form-row select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.92rem;
}

.notif-modal .form-row input:focus,
.notif-modal .form-row select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(80,200,120,0.12);
}

.notif-loc-checks,
.notif-trigger-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.notif-loc-checks label,
.notif-trigger-checks label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 400;
    cursor: pointer;
    color: var(--text-primary);
}

.notif-loc-checks input,
.notif-trigger-checks input {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.notif-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

@media (max-width: 600px) {
    .notif-person-row { flex-direction: column; align-items: flex-start; gap: 6px; }
    .notif-person-actions { margin-left: 0; }
}

/* ── Permission Rules Overview ── */

.rules-overview {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}
.rules-overview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}
.rules-overview-header:hover { background: var(--bg-card-hover); }
.rules-overview-header h3 { flex: 1; margin: 0; font-size: 0.9rem; font-weight: 600; }
.rules-overview-header .material-symbols-rounded { font-size: 20px; color: var(--text-muted); }
.rules-chevron { transition: transform var(--transition); }
.rules-detail:not(.hidden) ~ .rules-overview-header .rules-chevron,
.rules-overview-header:has(+ .rules-detail:not(.hidden)) .rules-chevron { transform: rotate(180deg); }

.rules-detail { padding: 0 16px 16px; }

.rules-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}
.rules-table th {
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}
.rules-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.rules-table tr:last-child td { border-bottom: none; }

.rules-role-label {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ── Person-centric Team UI ── */

.team-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 14px;
    margin-bottom: 18px;
}
.team-search-bar .material-symbols-rounded { color: var(--text-muted); font-size: 20px; }
.team-search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.92rem;
    outline: none;
}

.team-section-title {
    font-size: 0.88rem;
    font-weight: 600;
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.team-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.team-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.team-card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(80, 200, 120, 0.15);
}
.team-card-dim { opacity: 0.55; }
.team-card-dim:hover { opacity: 1; }
.team-card-readonly { cursor: default; }
.team-card-readonly:hover { border-color: var(--border); box-shadow: none; }

.team-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.team-row:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(80, 200, 120, 0.15);
}
.team-row.team-card-readonly { cursor: default; }
.team-row.team-card-readonly:hover { border-color: var(--border); box-shadow: none; }
.team-row.team-card-dim { opacity: 0.55; }
.team-row.team-card-dim:hover { opacity: 1; }

.team-row-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.team-row-info .team-card-name { font-weight: 600; font-size: 0.9rem; }
.team-row-info .team-card-email { font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }

.team-row-badges { display: flex; gap: 4px; flex-shrink: 0; }

.team-row-detail {
    font-size: 0.76rem;
    color: var(--text-muted);
    flex-shrink: 0;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.team-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.team-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.team-card-name { font-weight: 600; font-size: 0.92rem; line-height: 1.2; }
.team-card-email { font-size: 0.78rem; color: var(--text-muted); }

.team-card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.team-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.team-badge-admin { background: var(--error); color: #fff; }
.team-badge-owner { background: var(--primary); color: #fff; }
.team-badge-assignee { background: var(--warning); color: #111; }

.team-card-detail {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.team-loading {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
}
.team-loading p { margin-top: 12px; }
.team-spin { animation: spin-slow 1.2s linear infinite; display: inline-block; font-size: 36px; }
@keyframes spin-slow { to { transform: rotate(360deg); } }

.team-empty { text-align: center; padding: 48px 16px; }
.team-empty p { margin-top: 8px; color: var(--text-muted); }

/* ── User Config Modal sections ── */

.ucfg-email {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.ucfg-section {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.ucfg-section:last-of-type { border-bottom: none; }
.ucfg-section h4 {
    margin: 0 0 4px;
    font-size: 0.92rem;
    font-weight: 600;
}

.ucfg-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 8px;
}

.ucfg-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 4px;
}
.ucfg-toggle input { width: 16px; height: 16px; }

.ucfg-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
}
.ucfg-checks label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    cursor: pointer;
}
.ucfg-checks input { width: 15px; height: 15px; }

.ucfg-sub {
    font-size: 0.82rem;
    margin: 8px 0 4px;
}

.ucfg-select {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .team-grid { grid-template-columns: 1fr; }
    .team-row { flex-wrap: wrap; }
    .team-row-badges { width: 100%; margin-top: 4px; }
    .team-row-detail { max-width: 100%; }
}

/* ══════════════════════════════════════
   Version Badge & Changelog
   ══════════════════════════════════════ */
.version-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(80, 200, 120, 0.25);
    white-space: nowrap;
}

.nav-title-group:hover .nav-title {
    color: var(--accent);
}
.nav-title-group:hover .version-badge {
    background: var(--accent);
    color: var(--accent-on);
}

.changelog-body {
    max-height: 60vh;
    overflow-y: auto;
}

.cl-entry {
    position: relative;
    padding: 16px 0 16px 20px;
    border-left: 2px solid var(--border);
    margin-left: 6px;
}

.cl-entry:last-child {
    border-left-color: transparent;
}

.cl-entry::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 20px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
}

.cl-version {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2px;
}

.cl-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 1px;
}

.cl-author {
    font-size: 0.75rem;
    color: var(--text-faint);
    font-weight: 500;
    margin-bottom: 8px;
}

.cl-changes {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cl-changes li {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    padding-left: 16px;
    position: relative;
}

.cl-changes li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-faint);
}

/* ══════════════════════════════════════
   Hub Visit Calendar
   ══════════════════════════════════════ */
.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.cal-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cal-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.cal-nav-btn {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    padding: 6px !important;
}
.cal-nav-btn:hover {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}

.cal-month-label {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 200px;
    text-align: center;
}

.cal-today-btn {
    margin-left: 8px;
    padding: 6px 16px !important;
    font-size: 0.8rem !important;
}

/* Calendar Grid */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-card);
}

.cal-header-cell {
    padding: 10px 8px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--bg-thead);
    border-bottom: 1px solid var(--border);
}

.cal-day-cell {
    min-height: 100px;
    padding: 6px 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.cal-day-cell:nth-child(7n + 14) {
    border-right: none;
}

.cal-day-cell:hover {
    background: var(--bg-card-hover);
}

.cal-day-empty {
    background: var(--bg);
    cursor: default;
}
.cal-day-empty:hover {
    background: var(--bg);
}

.cal-today {
    background: var(--accent-glow);
}
.cal-today:hover {
    background: var(--accent-glow);
}

.cal-day-num {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.cal-today .cal-day-num {
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-on);
    font-size: 0.75rem;
}

/* Visit chips inside day cells */
.cal-visit-chip {
    display: block;
    padding: 3px 6px;
    margin-bottom: 3px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: filter 0.15s;
}

.cal-visit-chip:hover {
    filter: brightness(1.15);
}

.cal-chip-time {
    font-weight: 700;
    margin-right: 2px;
}

.cal-pm-chip {
    background: rgba(139, 92, 246, 0.18) !important;
    border-left: 3px solid #8b5cf6 !important;
    color: #8b5cf6 !important;
}

/* Visit Modal Form */
.visit-field {
    margin-bottom: 16px;
}

.visit-field-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.visit-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.visit-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-input);
    transition: border-color var(--transition);
}

.visit-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow-strong);
}

.visit-textarea {
    resize: vertical;
    min-height: 60px;
}

.visit-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.visit-actions #visit-delete-btn {
    color: var(--error);
    border-color: var(--error);
}
.visit-actions #visit-delete-btn:hover {
    background: var(--error-bg);
}

/* Responsive calendar */
@media (max-width: 900px) {
    .cal-day-cell {
        min-height: 72px;
        padding: 4px 4px;
    }
    .cal-visit-chip {
        font-size: 0.62rem;
        padding: 2px 4px;
    }
    .cal-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .cal-day-cell {
        min-height: 56px;
    }
    .cal-header-cell {
        font-size: 0.65rem;
        padding: 6px 2px;
    }
    .cal-month-label {
        font-size: 1rem;
        min-width: 160px;
    }
}

/* ══════════════════════════════════════════════
   Pre-Maintenance Kanban Board
   ══════════════════════════════════════════════ */

.pm-view-desc {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Toolbar */
.pm-readonly-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.88rem;
}
.pm-readonly-banner .material-symbols-rounded { font-size: 24px; color: var(--warning); flex-shrink: 0; }

.pm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 10px 16px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
}
.pm-toolbar-left, .pm-toolbar-right {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pm-toolbar-info {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.85rem; color: var(--text-secondary);
}
.pm-nav-btn {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; padding: 0;
}
.pm-nav-today {
    font-size: 0.78rem; padding: 4px 12px;
}

/* ── Hub / Locations popover ── */
.pm-hub-popover-wrap {
    position: relative; display: inline-block;
}
.pm-hub-popover {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 50;
    background: var(--bg-card, #fff); border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: 10px 14px; min-width: 200px;
    animation: pm-pop-in .15s ease;
}
@keyframes pm-pop-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.pm-hub-popover.hidden { display: none; }
.pm-hub-popover-title {
    font-size: 0.78rem; font-weight: 600; color: var(--text-muted, #6b7280);
    margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em;
}
.pm-hub-check-row {
    display: flex; align-items: center; gap: 8px; padding: 5px 0;
    font-size: 0.88rem; cursor: pointer;
}
.pm-hub-check-row input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: var(--primary, #6366f1);
    cursor: pointer;
}

/* ── Packing list banner (inside Kanban board, full-width) ── */
.pm-packlist-banner {
    background: linear-gradient(135deg, rgba(239,68,68,0.08), rgba(239,68,68,0.03));
    border: 2px solid rgba(239,68,68,0.25);
    border-radius: 12px;
    padding: 12px 16px;
}
.pm-packlist-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 8px; color: #ef4444;
}
.pm-packlist-title {
    font-size: 0.9rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.03em; flex: 1;
}
.pm-packlist-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 24px; border-radius: 12px;
    font-size: 0.75rem; font-weight: 700; color: #fff;
    background: #ef4444; padding: 0 8px;
}
.pm-packlist-items {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 6px;
}
.pm-packlist-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; background: var(--card-bg);
    border-radius: 8px; border: 1px solid var(--border-color);
    font-size: 0.84rem; flex-wrap: wrap;
}
.pm-packlist-sn {
    font-family: monospace; font-size: 0.78rem; font-weight: 700;
    color: var(--accent); min-width: 60px;
}
.pm-packlist-label {
    font-weight: 600; color: var(--text-primary); min-width: 90px;
}
.pm-packlist-material {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.8rem; font-weight: 600; color: #ef4444;
    background: rgba(239,68,68,0.08); padding: 3px 10px; border-radius: 6px;
}
.pm-packlist-issue {
    font-size: 0.78rem; color: var(--text-muted); flex-basis: 100%;
}

/* ── Issue cards in machine detail modal ── */
.pm-issues-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.pm-issue-card {
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 10px; overflow: hidden;
}
.pm-issue-card.pm-issue-fixed { border-left: 3px solid #22c55e; }
.pm-issue-card.pm-issue-not-fixed { border-left: 3px solid #ef4444; }
.pm-issue-card-header {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; background: rgba(99,102,241,0.04);
    border-bottom: 1px solid var(--border-color);
}
.pm-issue-type-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 6px;
}
.pm-issue-badge-fixed { background: rgba(34,197,94,0.12); color: #16a34a; }
.pm-issue-badge-not-fixed { background: rgba(239,68,68,0.12); color: #dc2626; }
.pm-issue-num { font-size: 0.72rem; color: var(--text-muted); margin-left: auto; }
.pm-issue-toggle-btn, .pm-issue-delete-btn {
    background: none; border: none; cursor: pointer; padding: 2px 4px;
    color: var(--text-muted); border-radius: 4px;
    transition: color .15s, background .15s;
}
.pm-issue-toggle-btn:hover { color: var(--accent); background: rgba(99,102,241,0.08); }
.pm-issue-delete-btn:hover { color: #ef4444; background: rgba(239,68,68,0.08); }
.pm-issue-card-body { padding: 10px 12px; }
.pm-no-issues-active {
    display: flex; align-items: center; gap: 10px;
    padding: 16px; margin: 10px 0;
    background: rgba(34,197,94,0.06); border-radius: 10px;
    font-size: 0.88rem; font-weight: 600; color: #16a34a;
}
.pm-mcard-issue-count {
    font-size: 0.72rem; font-weight: 700; color: var(--text-secondary);
}
.pm-mcard-issue-breakdown {
    font-size: 0.68rem; color: var(--text-muted); margin-left: 4px;
}

/* ── Kanban layout with flowchart sidebar ── */
.pm-kanban-layout {
    display: flex;
    gap: 16px;
    min-height: 500px;
}

/* ── Sidebars ── */
.pm-sidebar {
    flex: 0 0 210px;
    min-width: 190px;
}
.pm-sidebar-left { flex: 0 0 210px; }
.pm-sidebar-right { flex: 0 0 240px; min-width: 220px; }
.pm-flowchart {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 12px;
    position: sticky;
    top: 80px;
}
.pm-flow-title {
    font-size: 0.82rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 4px;
    text-align: center;
}
.pm-flow-hint {
    font-size: 0.7rem; color: var(--text-muted); text-align: center;
    margin-bottom: 10px; font-style: italic;
}
.pm-flow-step { display: flex; flex-direction: column; align-items: center; }
.pm-flow-node {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 8px;
    background: var(--bg); border: 1px solid var(--border);
    font-size: 0.78rem; font-weight: 500; width: 100%;
    color: var(--text-primary);
    cursor: pointer; transition: border-color 0.15s, background 0.15s;
    position: relative;
}
.pm-flow-node:hover {
    border-color: var(--accent);
    background: rgba(80,200,120,0.04);
}
.pm-flow-node .material-symbols-rounded:first-child { font-size: 16px; color: var(--accent); }
.pm-flow-expand {
    font-size: 14px !important;
    color: var(--text-muted) !important;
    margin-left: auto;
    opacity: 0.5;
}
.pm-flow-node:hover .pm-flow-expand { opacity: 1; }
.pm-flow-detail {
    width: 100%; padding: 8px 10px; margin-top: 4px;
    background: rgba(80,200,120,0.06);
    border: 1px solid rgba(80,200,120,0.2);
    border-radius: 6px;
    font-size: 0.72rem; line-height: 1.4;
    color: var(--text-secondary);
}
.pm-flow-detail ul {
    margin: 2px 0; padding-left: 16px; list-style: disc;
}
.pm-flow-detail ul ul {
    margin: 1px 0; padding-left: 14px; list-style: circle;
}
.pm-flow-detail li {
    margin-bottom: 2px;
}
.pm-flow-detail b {
    display: block; margin-top: 4px; color: var(--text-primary, #e5e7eb); font-size: 0.72rem;
}
.pm-flow-detail.hidden { display: none; }
.pm-flow-arrow { color: var(--text-muted); line-height: 1; padding: 2px 0; }
.pm-flow-arrow .material-symbols-rounded { font-size: 16px; }

/* ── Kanban board ── */
.pm-kanban-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.pm-kanban-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    align-items: start;
}

/* Kanban column */
.pm-kanban-col {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pm-kanban-previous { opacity: 0.7; }
.pm-kanban-previous:hover { opacity: 1; }
.pm-col-header {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.pm-col-title { display: flex; align-items: center; gap: 4px; font-weight: 600; font-size: 0.9rem; }
.pm-col-label { white-space: nowrap; }
.pm-col-date { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; }
.pm-col-badge {
    font-size: 0.7rem; font-weight: 600; padding: 2px 8px;
    border-radius: 8px; text-transform: capitalize;
}
.pm-col-status-planned { background: rgba(99,102,241,0.15); color: #818cf8; }
.pm-col-status-in-progress { background: rgba(255,209,102,0.15); color: #ffd166; }
.pm-col-status-completed { background: rgba(80,200,120,0.15); color: #50c878; }
.pm-col-empty {
    text-align: center; padding: 24px 8px;
    color: var(--text-muted); font-size: 0.85rem;
}
.pm-col-actions { display: flex; gap: 6px; justify-content: center; }

/* Packing list inside "Next" column */
/* (packing list is now rendered as .pm-packlist-banner above the columns) */

/* Hub group inside column */
.pm-hub-group { display: flex; flex-direction: column; gap: 6px; }
.pm-hub-label {
    display: flex; align-items: center; gap: 4px;
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.03em; color: var(--text-muted);
    padding: 4px 0 2px;
}

/* ── Machine card (compact, in column) ── */
.pm-mcard {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.pm-mcard:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.pm-mcard-top {
    display: flex; justify-content: space-between; align-items: center;
}
.pm-mcard-label { font-weight: 600; font-size: 0.85rem; }
.pm-mcard-status-icon { font-size: 18px; }
.pm-card-grey .pm-mcard-status-icon { color: var(--text-muted); }
.pm-card-green .pm-mcard-status-icon { color: #50c878; }
.pm-card-red .pm-mcard-status-icon { color: #ef4444; }
.pm-card-green { border-left: 3px solid #50c878; }
.pm-card-red { border-left: 3px solid #ef4444; }
.pm-mcard-sn { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.pm-mcard-summary {
    margin-top: 4px;
    display: flex; align-items: center; gap: 4px;
    flex-wrap: wrap;
}

/* ── Machine detail modal ── */
.pm-detail-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.pm-detail-overlay.hidden { display: none; }
.pm-detail-modal {
    background: var(--bg-card); border-radius: 16px;
    width: 100%; max-width: 640px; max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.pm-detail-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.pm-detail-header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.pm-detail-body {
    flex: 1; overflow-y: auto; padding: 16px 20px 20px;
}

/* Status choice buttons */
.pm-status-choose {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 8px; margin-bottom: 20px;
}
.pm-choice-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 14px 8px; border-radius: 10px; border: 2px solid var(--border);
    background: var(--bg); cursor: pointer;
    font-family: inherit; font-size: 0.82rem; font-weight: 600;
    color: var(--text-secondary); transition: all 0.15s;
}
.pm-choice-btn:hover { border-color: var(--text-muted); }
.pm-choice-btn .material-symbols-rounded { font-size: 28px; }
.pm-choice-ok .material-symbols-rounded { color: #50c878; }
.pm-choice-fixed .material-symbols-rounded { color: var(--accent); }
.pm-choice-notfixed .material-symbols-rounded { color: #ef4444; }
.pm-choice-ok.active { border-color: #50c878; background: rgba(80,200,120,0.08); color: #50c878; }
.pm-choice-fixed.active { border-color: var(--accent); background: rgba(80,200,120,0.08); color: var(--accent); }
.pm-choice-notfixed.active { border-color: #ef4444; background: rgba(239,68,68,0.06); color: #ef4444; }

.pm-status-readonly {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 14px; margin-bottom: 16px;
    background: var(--bg); border-radius: 8px;
    font-weight: 600; font-size: 0.9rem;
}

/* Detail sections */
.pm-detail-section {
    margin-bottom: 16px;
}
.pm-detail-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.03em;
    margin-bottom: 6px;
}
.pm-detail-textarea {
    width: 100%; min-height: 80px; padding: 10px 12px;
    background: var(--bg); border: 1.5px solid var(--border); border-radius: 8px;
    color: var(--text-primary); font-family: inherit; font-size: 0.88rem;
    resize: vertical;
}
.pm-detail-textarea:focus { outline: none; border-color: var(--accent); }
.pm-materials-input { border-color: rgba(239,68,68,0.3); }
.pm-materials-input:focus { border-color: #ef4444; }
.pm-detail-hint {
    font-size: 0.72rem; color: var(--text-muted); margin-top: 4px;
    font-style: italic;
}

/* Photos */
.pm-photo-upload {
    display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.pm-photo-upload-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px; border-radius: 10px; cursor: pointer;
    background: var(--accent); color: #fff; font-weight: 600; font-size: 0.88rem;
    font-family: inherit; transition: opacity 0.15s;
}
.pm-photo-upload-btn:hover { opacity: 0.85; }
.pm-photo-upload-btn .material-symbols-rounded { font-size: 18px; }
.pm-photo-upload-hint { font-size: 0.78rem; color: var(--text-muted); }
.pm-photo-gallery {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}
.pm-photo-thumb {
    border-radius: 8px; overflow: hidden; cursor: pointer;
    border: 1.5px solid var(--border); transition: border-color 0.15s;
    background: var(--bg);
}
.pm-photo-thumb:hover { border-color: var(--accent); }
.pm-photo-thumb img {
    width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
}
.pm-photo-empty {
    padding: 16px; text-align: center; color: var(--text-muted); font-size: 0.85rem;
}

/* Loading indicator */
.pm-loading {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 24px; color: var(--text-muted);
}

/* ── History timeline ── */
.pm-history-empty {
    text-align: center; padding: 24px 12px; color: var(--text-muted);
}
.pm-history-timeline {
    position: relative; padding-left: 28px;
}
.pm-history-timeline::before {
    content: ''; position: absolute; left: 11px; top: 0; bottom: 0;
    width: 2px; background: var(--border);
}
.pm-history-entry {
    position: relative; padding-bottom: 16px;
}
.pm-history-dot {
    position: absolute; left: -28px; top: 2px;
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-card); border: 2px solid var(--border);
}
.pm-history-pre-maint .pm-history-dot { border-color: var(--accent); color: var(--accent); }
.pm-history-ticket .pm-history-dot { border-color: #ffd166; color: #ffd166; }
.pm-history-content {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 14px;
}
.pm-history-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 8px; flex-wrap: wrap;
}
.pm-history-title { font-weight: 600; font-size: 0.85rem; }
.pm-history-date { font-size: 0.72rem; color: var(--text-muted); }
.pm-history-meta {
    display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap;
}
.pm-history-type-badge {
    font-size: 0.7rem; font-weight: 600; padding: 2px 8px;
    border-radius: 6px; text-transform: uppercase;
}
.pm-htype-pre-maint { background: rgba(80,200,120,0.12); color: #50c878; }
.pm-htype-ticket { background: rgba(255,209,102,0.12); color: #ffd166; }
.pm-history-status {
    font-size: 0.72rem; color: var(--text-muted); text-transform: capitalize;
}
.pm-history-recurring {
    display: inline-flex; align-items: center; gap: 2px;
    font-size: 0.72rem; font-weight: 600; color: #ef4444;
    background: rgba(239,68,68,0.1); padding: 2px 8px; border-radius: 6px;
}
.pm-history-detail {
    font-size: 0.78rem; color: var(--text-secondary);
    margin-top: 4px; line-height: 1.4;
}

/* ── History sidebar (right panel) ── */
.pm-history-sidebar {
    position: sticky; top: 80px;
}
.pm-histpanel-title {
    display: flex; align-items: center; gap: 6px;
    font-weight: 700; font-size: 0.88rem; color: var(--text-primary);
    margin-bottom: 10px; padding-bottom: 8px;
    border-bottom: 2px solid var(--accent);
}
.pm-histpanel-hub {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
    margin: 12px 0 4px; padding-left: 2px;
}
.pm-histpanel-machine {
    margin-bottom: 2px;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}
.pm-histpanel-machine-header {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 10px; cursor: pointer;
    font-size: 0.82rem; font-weight: 600; color: var(--text-primary);
    transition: background .15s;
}
.pm-histpanel-machine-header:hover { background: rgba(99,102,241,0.06); }
.pm-histpanel-machine-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-histpanel-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; border-radius: 10px;
    font-size: 0.7rem; font-weight: 700; color: #fff;
    background: #ef4444; padding: 0 6px;
}
.pm-histpanel-chevron {
    font-size: 18px; color: var(--text-muted);
    transition: transform .2s;
}
.pm-histpanel-body {
    padding: 0 10px 10px;
    max-height: 320px; overflow-y: auto;
}
.pm-histpanel-body .pm-history-timeline { gap: 6px; }
.pm-histpanel-body .pm-history-entry { padding: 6px 0 6px 18px; }
.pm-histpanel-body .pm-history-dot { width: 22px; height: 22px; left: -11px; }
.pm-histpanel-body .pm-history-dot .material-symbols-rounded { font-size: 12px; }
.pm-histpanel-body .pm-history-title { font-size: 0.75rem; }
.pm-histpanel-body .pm-history-date { font-size: 0.68rem; }
.pm-histpanel-body .pm-history-meta { gap: 4px; }
.pm-histpanel-body .pm-history-type-badge { font-size: 0.62rem; padding: 1px 5px; }
.pm-histpanel-body .pm-history-status { font-size: 0.68rem; }
.pm-histpanel-body .pm-history-detail { font-size: 0.72rem; }
.pm-histpanel-body .pm-history-recurring { font-size: 0.65rem; padding: 1px 5px; }
.pm-histpanel-body .pm-history-empty { padding: 10px; }
.pm-histpanel-body .pm-history-empty p { font-size: 0.75rem; }
.pm-histpanel-body .pm-history-empty .material-symbols-rounded { font-size: 24px; }

/* ── Responsive ── */
@media (max-width: 1400px) {
    .pm-sidebar-right { flex: 0 0 200px; min-width: 180px; }
}
@media (max-width: 1100px) {
    .pm-kanban-layout { flex-direction: column; }
    .pm-sidebar { flex: none; width: 100%; }
    .pm-sidebar-right { width: 100%; }
    .pm-history-sidebar { position: static; }
    .pm-flowchart {
        position: static;
        display: flex; flex-wrap: wrap; gap: 6px;
        padding: 12px 16px; align-items: flex-start;
    }
    .pm-flow-step { flex-direction: row; align-items: flex-start; }
    .pm-flow-arrow { transform: rotate(-90deg); padding: 0 4px; }
    .pm-flow-title { width: 100%; margin-bottom: 4px; text-align: left; }
    .pm-flow-hint { width: 100%; text-align: left; margin-bottom: 6px; }
    .pm-flow-node { width: auto; }
    .pm-flow-detail { width: auto; max-width: 240px; }
}
@media (max-width: 820px) {
    .pm-kanban-columns { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .pm-detail-modal { max-width: 100%; border-radius: 12px; }
    .pm-status-choose { grid-template-columns: 1fr; }
    .pm-photo-gallery { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}

/* ── Print styles for QR view ── */
@media print {
    body { background: #fff !important; }
    nav, .stats-bar, .view-tabs, .qr-view-toolbar,
    .qr-view-desc, .qr-view-actions, footer,
    #view-tickets, #view-statistics, #view-calendar, #view-notifications, #view-premaint { display: none !important; }
    #view-qrcodes { display: block !important; }
    .main-content { padding: 0 !important; }
    .qr-view-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 16px !important;
        padding: 10px !important;
    }
    .qr-dash-card {
        box-shadow: none !important;
        border: 2px solid #e0e0e0 !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }
}
