:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --success: #10b981;
    --success-light: #ecfdf5;
    --bg: #f4f6f8;
    --surface: #fff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --sidebar-bg: #111827;
    --sidebar-width: 190px;
    --topbar-height: 44px;
    --radius: 6px;
    --shadow: 0 1px 2px rgba(0,0,0,.05);
    --transition: .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 12.5px;
    line-height: 1.45;
}

a { color: var(--primary); text-decoration: none; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    border-right: 1px solid rgba(255,255,255,.05);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.65rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.logo { display: flex; align-items: center; gap: 0.45rem; }

.logo-icon {
    width: 28px; height: 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
}
.logo-icon svg { width: 15px; height: 15px; }

.logo-text { font-weight: 700; font-size: 0.95rem; color: #fff; }

.sidebar-close {
    display: none;
    background: none; border: none;
    color: #94a3b8; cursor: pointer;
    width: 26px; height: 26px;
    align-items: center; justify-content: center;
}
.sidebar-close svg { width: 16px; height: 16px; }

.sidebar-nav { padding: 0.4rem 0.5rem; flex: 1; overflow-y: auto; }

.nav-section {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #4b5563;
    padding: 0.5rem 0.5rem 0.2rem;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.5rem;
    border-radius: 5px;
    color: #9ca3af;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1px;
    transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e5e7eb; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }

.nav-icon { width: 16px; height: 16px; display: flex; flex-shrink: 0; }
.nav-icon svg { width: 14px; height: 14px; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 150;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 0.85rem;
    gap: 0.5rem;
    position: sticky; top: 0; z-index: 100;
}

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    width: 30px; height: 30px;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text);
    align-items: center; justify-content: center;
}
.menu-toggle svg { width: 16px; height: 16px; }

.page-heading {
    flex: 0 1 auto;
    max-width: 28%;
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-alerts {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 0;
}

.topbar-alert-wrap {
    position: relative;
}

.topbar-alert-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #f8fafc;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.topbar-alert-btn:hover,
.topbar-alert-btn.active {
    background: var(--primary-light);
    border-color: #c7d2fe;
    color: var(--primary);
}

.topbar-alert-label { line-height: 1; }

.topbar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
}
.topbar-badge-overdue {
    background: var(--danger-light);
    color: var(--danger);
}
.topbar-badge-overdue.is-zero {
    background: #f1f5f9;
    color: var(--text-muted);
}
.topbar-badge-today {
    background: #fef3c7;
    color: #b45309;
}

.topbar-alert-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 260px;
    max-width: 85vw;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.12));
    z-index: 200;
}
.topbar-alert-menu.open { display: block; }

.topbar-alert-menu-head {
    padding: 0.45rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
.topbar-alert-menu-head span {
    display: inline-block;
    margin-left: 0.25rem;
    min-width: 18px;
    text-align: center;
    background: #fef3c7;
    color: #b45309;
    border-radius: 8px;
    font-size: 0.62rem;
    padding: 0.05rem 0.35rem;
}

.topbar-alert-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

.topbar-alert-item {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.68rem;
}
.topbar-alert-item:last-child { border-bottom: none; }

.topbar-alert-item-title {
    display: block;
    font-weight: 600;
    line-height: 1.3;
}
.topbar-alert-item-meta {
    display: block;
    color: var(--text-muted);
    font-size: 0.62rem;
    margin-top: 0.1rem;
}

.topbar-alert-empty {
    padding: 0.6rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
}

.topbar-alert-link {
    display: block;
    padding: 0.4rem 0.6rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--primary);
    text-align: center;
    border-top: 1px solid var(--border);
}
.topbar-alert-link:hover { background: #f8fafc; }

.user-avatar {
    width: 26px; height: 26px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.topbar-user-name {
    font-size: 0.72rem;
    color: var(--text-muted);
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    padding: 0.2rem 0.55rem;
    font-size: 0.68rem;
}

.main-content { flex: 1; padding: 0.65rem 0.85rem; }

.footer {
    padding: 0.4rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 0.65rem;
}

.card-header {
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.card-header h2 { font-size: 0.85rem; font-weight: 600; }
.card-header-left { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.card-subtitle { font-size: 0.7rem; color: var(--text-muted); }
.card-body { padding: 0.65rem; }
.card-body-flush { padding: 0; }

.card-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.55rem 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow);
}

.stat-card-icon {
    width: 30px; height: 30px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-card-icon svg { width: 15px; height: 15px; }
.stat-card-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-card-icon.muted { background: #f1f5f9; color: var(--text-muted); }
.stat-card-icon.success { background: var(--success-light); color: var(--success); }

.stat-label { font-size: 0.68rem; color: var(--text-muted); }
.stat-value { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.stat-card-muted .stat-value { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }
.stat-link { font-size: 0.68rem; font-weight: 600; color: var(--primary); }

.dashboard-finance-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.stat-card-finance .stat-value { font-size: 0.95rem; }

.dashboard-panels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.dash-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.dash-panel-wide { grid-column: 1 / -1; }

.dash-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}

.dash-panel-header h3 {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 700;
}

.dash-panel-body {
    max-height: 220px;
    overflow-y: auto;
    padding: 0.35rem 0;
}

.dash-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dash-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0.65rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.72rem;
}

.dash-item:last-child { border-bottom: none; }

.dash-item-main { flex: 1; min-width: 0; }

.dash-item-title {
    display: block;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.dash-item-meta {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.dash-empty, .dash-loading {
    padding: 0.75rem 0.65rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
}

.tat-badge {
    display: inline-block;
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
}
.tat-overdue { background: var(--danger-light); color: var(--danger); }
.tat-upcoming { background: var(--primary-light); color: var(--primary); }
.tat-today { background: #fef3c7; color: #b45309; }

@media (max-width: 768px) {
    .dashboard-finance-grid { grid-template-columns: 1fr; }
    .dashboard-panels { grid-template-columns: 1fr; }
    .dash-panel-wide { grid-column: auto; }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    border-radius: 5px;
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background var(--transition);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: #f8fafc; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f1f5f9; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 0.25rem 0.45rem; font-size: 0.7rem; }
.btn-icon-only { width: 26px; height: 26px; padding: 0; }

.btn-edit { background: var(--primary-light); color: var(--primary); }
.btn-edit:hover { background: #e0e7ff; }
.btn-delete { background: var(--danger-light); color: var(--danger); }
.btn-delete:hover { background: #fee2e2; }

.btn svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Forms */
.form-group { margin-bottom: 0.65rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.75rem; }
.required { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.8rem;
    font-family: inherit;
    background: var(--surface);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99,102,241,.12);
}

.search-box { position: relative; width: 180px; }
.search-box .search-icon {
    position: absolute; left: 0.5rem; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}
.search-box .search-icon svg { width: 13px; height: 13px; }
.search-box .form-control { padding-left: 1.85rem; }

.form-select-sm {
    width: auto;
    min-width: 120px;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
}
.filter-tat { min-width: 140px; max-width: 160px; }

.type-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
}
.type-badge.t1 { background: #eef2ff; color: #4338ca; }
.type-badge.t2 { background: #fef3c7; color: #b45309; }
.type-badge.t3 { background: #fce7f3; color: #be185d; }
.type-badge.t4 { background: #ecfdf5; color: #047857; }

.priority-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
}
.priority-badge.pri-low { background: #f1f5f9; color: #475569; }
.priority-badge.pri-medium { background: #dbeafe; color: #1d4ed8; }
.priority-badge.pri-high { background: #ffedd5; color: #c2410c; }
.priority-badge.pri-critical { background: #fee2e2; color: #b91c1c; }
.type-badge.status-active { background: #ecfdf5; color: #047857; }
.type-badge.status-inactive { background: #f1f5f9; color: #64748b; }

.mobile-card-meta { margin-bottom: 0.45rem; }
.mobile-card-detail { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.2rem; }
.mobile-card-detail span { font-weight: 600; color: var(--text); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-hint { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.15rem; display: block; }

.modal-md { max-width: 380px; }
.modal-lg { max-width: 420px; }

.modal-compact {
    max-width: 380px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}
.modal-sm.modal-compact { max-width: 300px; }
.modal-compact .modal-header {
    padding: 0.4rem 0.55rem;
    flex-shrink: 0;
}
.modal-compact .modal-header h3 { font-size: 0.8rem; }
.modal-compact .modal-body {
    padding: 0.45rem 0.55rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.modal-compact .modal-footer {
    padding: 0.4rem 0.55rem;
    flex-shrink: 0;
}
.modal-compact .form-group { margin-bottom: 0.4rem; }
.modal-compact .form-group label { font-size: 0.68rem; margin-bottom: 0.15rem; }
.modal-compact .form-control {
    padding: 0.3rem 0.45rem;
    font-size: 0.75rem;
}
.modal-compact .form-control[type="date"],
.modal-compact .form-control[type="time"] { min-height: 28px; }
.modal-compact textarea.form-control { min-height: 44px; font-size: 0.75rem; }
.modal-compact .form-row { gap: 0.35rem; }
.modal-compact .form-row-3 { grid-template-columns: 1fr 1fr; }
.modal-compact .multi-check-box {
    max-height: 68px;
    padding: 0.25rem 0.4rem;
}
.modal-compact .multi-check-item { font-size: 0.7rem; padding: 0.1rem 0; }
.modal-compact .text-muted { font-size: 0.68rem; }

.data-table-compact th,
.data-table-compact td { padding: 0.35rem 0.5rem; font-size: 0.72rem; }
.cell-email { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-pwd { font-family: monospace; font-size: 0.68rem; color: var(--text-muted); max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-salary { font-weight: 600; color: #047857; white-space: nowrap; }
.cell-name { font-weight: 500; }

@media (max-width: 480px) {
    .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
    .modal-compact { max-width: 100%; }
    .modal-compact .form-row-3 { grid-template-columns: 1fr; }
}

.page-toolbar { display: flex; gap: 0.4rem; margin-bottom: 0.65rem; flex-wrap: wrap; }
.form-actions { display: flex; gap: 0.4rem; justify-content: flex-end; margin-top: 0.75rem; }
.form-control[type="date"], .form-control[type="time"] { min-height: 32px; }
textarea.form-control { resize: vertical; min-height: 60px; }

.multi-check-box {
    border: 1px solid var(--border);
    border-radius: 5px;
    max-height: 120px;
    overflow-y: auto;
    padding: 0.35rem 0.5rem;
    background: #fafbfc;
}
.multi-check-item {
    display: block;
    font-size: 0.75rem;
    padding: 0.2rem 0;
    cursor: pointer;
}
.multi-check-item input { margin-right: 0.35rem; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.65rem;
    font-size: 0.78rem;
}
.detail-label { display: block; font-size: 0.65rem; color: var(--text-muted); margin-bottom: 0.1rem; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-full { grid-column: 1 / -1; }

.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }

.cell-type { display: flex; flex-direction: column; gap: 0.15rem; }
.cell-users {
    display: block;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
}
.tat-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}
.tat-ok { background: #ecfdf5; color: #047857; }
.tat-warning { background: #fef3c7; color: #b45309; }
.tat-overdue { background: #fee2e2; color: #b91c1c; }
.tat-done { background: #f1f5f9; color: #64748b; }
.tat-na { background: transparent; color: var(--text-muted); font-weight: 500; }

.hours-total-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
}
.hours-total-bar strong { color: var(--primary); font-size: 0.85rem; }
.hours-table-wrap { max-height: 160px; overflow-y: auto; margin-top: 0.35rem; }
.hours-add-form { margin-bottom: 0.35rem; }

.modal-hours {
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}
.modal-hours .modal-header {
    padding: 0.55rem 0.7rem;
    flex-shrink: 0;
}
.modal-hours .modal-header h3 { font-size: 0.88rem; }
.modal-hours .modal-body {
    padding: 0.6rem 0.7rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.modal-hours .modal-footer {
    padding: 0.5rem 0.7rem;
    flex-shrink: 0;
}
.modal-hours .form-group { margin-bottom: 0.45rem; }
.modal-hours .form-group label { font-size: 0.72rem; margin-bottom: 0.2rem; }
.modal-hours .form-control {
    padding: 0.38rem 0.5rem;
    font-size: 0.78rem;
}
.modal-hours .form-row { gap: 0.45rem; }
.modal-hours .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.modal-hours .hours-total-bar { font-size: 0.78rem; margin-bottom: 0.5rem; }
.modal-hours .hours-total-bar strong { font-size: 0.9rem; }
.modal-hours .hours-table-wrap { max-height: 220px; margin-top: 0.45rem; }
.modal-hours .hours-add-form { margin-bottom: 0.45rem; }
.modal-hours .cell-notes { max-width: 160px; font-size: 0.74rem; }
.modal-hours .data-table-compact th,
.modal-hours .data-table-compact td { padding: 0.38rem 0.5rem; font-size: 0.74rem; }
.modal-hours .tox-tinymce { font-size: 0.8rem; }

@media (max-width: 640px) {
    .modal-hours .form-row-3 { grid-template-columns: 1fr; }
}

.form-error { color: var(--danger); font-size: 0.7rem; margin-top: 0.2rem; display: block; }

.rich-content { font-size: 0.8rem; line-height: 1.5; }
.rich-content p { margin: 0 0 0.35rem; }
.rich-content ul, .rich-content ol { margin: 0.25rem 0 0.35rem 1.1rem; padding: 0; }
.rich-content table { border-collapse: collapse; width: 100%; margin: 0.25rem 0; }
.rich-content td, .rich-content th { border: 1px solid var(--border); padding: 0.2rem 0.35rem; font-size: 0.75rem; }

.cell-notes { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.72rem; color: var(--text-muted); }

.renewal-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary);
    font-size: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.renewal-link:hover { color: #1d4ed8; }
.renewal-link-inline { font-size: 0.72rem; }
.renewal-project-name {
    font-size: 0.78rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--text);
}

.tox-tinymce { border-radius: var(--radius) !important; border-color: var(--border) !important; }
.modal-compact .tox-tinymce { font-size: 0.8rem; }
.modal-body .tox .tox-edit-area__iframe { background: #fff; }

/* Compact TinyMCE toolbar & editor */
.tox:not(.tox-tinymce-inline) .tox-editor-header {
    padding: 0 2px !important;
    box-shadow: none !important;
}
.tox .tox-toolbar-overlord {
    padding: 1px 0 !important;
}
.tox .tox-toolbar__primary {
    background: transparent !important;
}
.tox .tox-toolbar__group {
    padding: 0 1px !important;
}
.tox .tox-tbtn {
    height: 22px !important;
    width: 22px !important;
    margin: 1px 0 !important;
}
.tox .tox-tbtn svg {
    transform: scale(0.78);
}
.tox .tox-split-button {
    margin: 1px 0 !important;
}
.tox .tox-split-button .tox-tbtn {
    width: auto !important;
    min-width: 22px !important;
}
.tox .tox-edit-area__iframe {
    background: #fff !important;
}

.record-count {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Table */
.table-responsive { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 0.4rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.78rem;
}
.data-table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tbody tr:last-child td { border-bottom: none; }

.id-badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    background: #f1f5f9;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}

.type-name { font-weight: 500; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 0.75rem; }
.loading-cell { padding: 1.5rem !important; color: var(--text-muted); }

.loading-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
    margin-right: 0.35rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.action-btns { display: flex; gap: 0.25rem; }

/* Mobile list */
.mobile-list { display: none; }

.mobile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.45rem;
}
.mobile-card-top { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.45rem; }
.mobile-card-title { font-weight: 600; font-size: 0.8rem; flex: 1; }
.mobile-card-actions { display: flex; gap: 0.3rem; padding-top: 0.45rem; border-top: 1px solid #f1f5f9; }

/* Toast */
.alert {
    padding: 0.45rem 0.65rem;
    border-radius: 5px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.35rem;
}
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert svg { width: 14px; height: 14px; flex-shrink: 0; }

.toast-container {
    position: fixed;
    top: 0.5rem; right: 0.5rem;
    z-index: 400;
    max-width: 280px;
}

.empty-state { padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.78rem; }

/* Pagination */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}

.pagination-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

.per-page-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

.per-page-select {
    min-width: 58px;
    padding: 0.2rem 0.35rem;
    font-size: 0.68rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 26px;
    height: 26px;
    padding: 0 0.35rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.68rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.page-btn:hover:not(:disabled):not(.active) {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.page-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.page-ellipsis {
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 0 0.15rem;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface);
    border-radius: 6px;
    width: 100%;
    max-width: 340px;
    border: 1px solid var(--border);
    box-shadow: 0 6px 24px rgba(0,0,0,.1);
}

.modal-sm { max-width: 300px; }

.modal.modal-hours {
    max-width: 580px;
    width: 100%;
}

#hoursModal .modal.modal-hours {
    max-height: 88vh;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 0.85rem; font-weight: 600; }

.modal-close {
    background: none; border: none;
    width: 24px; height: 24px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
}
.modal-close svg { width: 14px; height: 14px; }

.modal-body { padding: 0.65rem; }
.modal-footer {
    padding: 0.5rem 0.65rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    background: #fafbfc;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: flex; }
    .sidebar-overlay.active { display: block; }
    .main-wrapper { margin-left: 0; }
    .menu-toggle { display: flex; }
    .main-content { padding: 0.5rem; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .search-box { width: 100%; }
    .card-header { flex-direction: column; align-items: stretch; }
    .card-toolbar { width: 100%; }
    .card-toolbar .btn { flex: 1; }
    .table-responsive { display: none; }
    .mobile-list { display: block; }
}

@media (max-width: 480px) {
    .modal-footer { flex-direction: column-reverse; }
    .modal-footer .btn { width: 100%; }
}

.report-filters {
    display: grid;
    grid-template-columns: 2fr 1.5fr auto;
    gap: 0.65rem;
    align-items: end;
}
.report-filters-4 {
    grid-template-columns: 1.5fr 1fr 1fr auto;
}
.report-filters-3 {
    grid-template-columns: 1.5fr 1fr auto;
}
.finance-date-bar {
    padding: 0.65rem 0.85rem 0;
    border-bottom: 1px solid var(--border);
}
.finance-date-filters {
    grid-template-columns: 1fr 1fr auto;
    max-width: 520px;
}
.finance-preset-group {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.dashboard-finance-filter {
    margin-bottom: 0.75rem;
}
.dashboard-finance-filter .card-body {
    padding: 0.65rem 0.85rem;
}
.dashboard-finance-filter .finance-date-filters {
    max-width: none;
}
.report-subtitle {
    font-size: 0.78rem;
    margin: 0.65rem 0 0.35rem;
    color: var(--text-muted);
    font-weight: 600;
}
.report-project-totals {
    font-size: 0.78rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--border);
}
.report-filter-action .btn { width: 100%; }
.report-cost-note {
    margin: 0.65rem 0 0;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.55rem;
    margin-bottom: 0.75rem;
}
.report-summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.report-summary-card small { font-size: 0.68rem; color: var(--text-muted); }
.report-summary-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; }
.report-cost { color: #c2410c; }
.report-positive { color: #047857; }
.report-negative { color: #b91c1c; }
.report-section-card { margin-bottom: 0.75rem; }
.report-block {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.55rem;
    overflow: hidden;
}
.report-block-head {
    background: #f8fafc;
    padding: 0.45rem 0.6rem;
    font-size: 0.76rem;
    border-bottom: 1px solid var(--border);
}
.report-no-entries { padding: 0.45rem 0.6rem; margin: 0; font-size: 0.72rem; }
.report-total-row td {
    background: #f8fafc;
    border-top: 2px solid var(--border);
    font-size: 0.76rem;
}

@media (max-width: 768px) {
    .report-filters, .report-filters-4, .report-filters-3, .finance-date-filters { grid-template-columns: 1fr; }
}

.eod-project-block {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.7rem;
    margin-bottom: 0.65rem;
    background: #fafbfc;
}
.eod-project-head {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    margin-bottom: 0.45rem;
}
.eod-project-select { flex: 1; margin-bottom: 0; }
.eod-points { margin-bottom: 0.35rem; }
.eod-point-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.3rem;
}
.eod-bullet {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
    width: 12px;
    flex-shrink: 0;
}
.eod-point-input { flex: 1; }
.eod-remove-point {
    min-width: 28px;
    padding: 0.15rem 0.4rem;
    line-height: 1;
}

.eod-day-report { margin-top: 0.5rem; }
.eod-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.eod-day-header h2 { font-size: 0.95rem; margin: 0; }
.eod-employee-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.65rem;
}
.eod-employee-empty { opacity: 0.75; }
.eod-employee-name {
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.eod-project-entry { margin-bottom: 0.55rem; }
.eod-project-entry:last-child { margin-bottom: 0; }
.eod-project-title {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}
.eod-point-list {
    margin: 0 0 0 1rem;
    padding: 0;
    list-style: none;
}
.eod-point-list li {
    font-size: 0.78rem;
    line-height: 1.45;
    margin-bottom: 0.15rem;
    position: relative;
    padding-left: 0.65rem;
}
.eod-point-list li::before {
    content: '*';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 700;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(145deg, #eef2ff 0%, var(--bg) 45%, #f8fafc 100%);
}

.login-wrap {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    padding: 1.35rem 1.25rem 1.25rem;
}

.login-brand {
    text-align: center;
    margin-bottom: 1rem;
}

.login-brand h1 {
    font-size: 1.1rem;
    margin: 0.45rem 0 0.2rem;
}

.login-brand p {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin: 0;
}

.login-logo {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
}

.login-logo svg {
    width: 22px;
    height: 22px;
}

.login-form .form-group {
    margin-bottom: 0.75rem;
}

.btn-login {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .topbar-user-name { display: none; }
    .page-heading { display: none; }
    .topbar-alerts { justify-content: flex-start; }
    .topbar-alert-menu { left: 0; right: auto; }
}
