/* =====================================================
   BPCL Logbook – Modern Responsive Stylesheet v2
   Light / Dark Mode  ·  Collapsible Sidebar
   ===================================================== */

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

/* ── Design Tokens (Light) ───────────────────────── */
:root {
    /* Brand */
    --brand:        #003DA5;
    --brand-light:  #0050c8;
    --brand-dark:   #002266;
    --accent:       #FFC20E;
    --accent-light: #ffd04a;
    --accent-bg:    #fff8e0;

    /* Semantic */
    --success:     #16a34a;
    --success-bg:  #dcfce7;
    --danger:      #dc2626;
    --danger-bg:   #fee2e2;

    /* Surfaces */
    --bg-body:     #f0f2f5;
    --bg-surface:  #ffffff;
    --bg-surface2: #f8f9fb;
    --bg-sidebar:  #091a36;
    --bg-sidebar-hover: rgba(255,255,255,0.07);
    --bg-sidebar-active: rgba(255,255,255,0.12);

    /* Text */
    --text-primary:   #111827;
    --text-secondary: #4b5563;
    --text-tertiary:  #6b7280;
    --text-muted:     #9ca3af;
    --text-inverse:   #ffffff;
    --text-sidebar:   rgba(255,255,255,0.72);
    --text-sidebar-active: #FFC20E;

    /* Borders */
    --border:       #e5e7eb;
    --border-light: #f3f4f6;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.12);

    /* Geometry */
    --radius:    8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 68px;
    --topbar-h:  60px;

    /* Animation */
    --ease:  cubic-bezier(0.4, 0, 0.2, 1);
    --speed: 0.28s;
}

/* ── Dark Mode Tokens ────────────────────────────── */
[data-theme="dark"] {
    --bg-body:      #0f1117;
    --bg-surface:   #1a1d27;
    --bg-surface2:  #22252f;
    --bg-sidebar:   #0d1018;
    --bg-sidebar-hover:  rgba(255,255,255,0.05);
    --bg-sidebar-active: rgba(255,255,255,0.1);

    --text-primary:   #e5e7eb;
    --text-secondary: #9ca3af;
    --text-tertiary:  #6b7280;
    --text-muted:     #4b5563;

    --border:       #2d3140;
    --border-light: #23262f;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.45);

    --success-bg: rgba(22,163,74,0.15);
    --danger-bg:  rgba(220,38,38,0.15);
    --accent-bg:  rgba(255,194,14,0.12);
}

[data-theme="dark"] .brand-color-override { --brand: #4d8fec; --brand-light: #6da3f0; }

/* ── Base ─────────────────────────────────────────── */
html { font-size: 15px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-secondary);
    background: var(--bg-body);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

a { color: var(--brand); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--brand-light); }
img { max-width: 100%; height: auto; display: block; }

::selection { background: var(--brand); color: #fff; }

/* ═══════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(255,194,14,0.12) 0%, transparent 70%);
    top: -200px; right: -100px;
    border-radius: 50%;
    pointer-events: none;
}

.login-container {
    width: 100%; max-width: 420px;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 44px 36px;
    animation: fadeUp 0.5s var(--ease);
    position: relative;
    z-index: 1;
}

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

.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { width: 90px; height: auto; border-radius: var(--radius); margin: 0 auto 14px; }
.login-header h1 { font-size: 1.5rem; color: var(--brand); font-weight: 800; letter-spacing: -0.3px; }
.login-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.82rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
}
.login-form label svg { color: var(--text-muted); }

.login-footer { text-align: center; margin-top: 28px; font-size: 0.73rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════
   FORM INPUTS
   ═══════════════════════════════════════════════════ */
.form-input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    outline: none;
    font-family: inherit;
}

.form-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(0,61,165,0.1);
}

[data-theme="dark"] .form-input:focus {
    box-shadow: 0 0 0 3px rgba(77,143,236,0.18);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

select[multiple].form-input { background-image: none; padding-right: 14px; }
.form-checkbox { width: 18px; height: 18px; accent-color: var(--brand); }

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 0.82rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
}

.field-error  { display: block; color: var(--danger); font-size: 0.78rem; margin-top: 4px; }
.error-text   { color: var(--danger); font-size: 0.85rem; margin-bottom: 8px; }
.form-errors  { background: var(--danger-bg); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.help-text    { color: var(--text-muted); font-size: 0.78rem; margin-top: 4px; }

.form-actions {
    display: flex; gap: 12px; margin-top: 32px; flex-wrap: wrap;
    justify-content: flex-end;
}
.form-actions-center { justify-content: center; }
.form-container { max-width: 100%; }

/* Two-column form grid */
.form-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px;
}
.form-grid .form-group-full {
    grid-column: 1 / -1;
}

/* ═══════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 20px; border: none; border-radius: var(--radius);
    font-size: 0.88rem; font-weight: 600; cursor: pointer;
    transition: all 0.2s var(--ease); text-decoration: none;
    font-family: inherit; line-height: 1.4; white-space: nowrap;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-light); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,61,165,0.25); }

.btn-outline { background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-outline:hover { background: var(--bg-surface2); color: var(--text-primary); border-color: var(--text-muted); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; transform: translateY(-1px); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }

.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius);
    color: var(--text-muted); transition: all 0.18s;
}
.btn-icon:hover { background: rgba(0,61,165,0.08); color: var(--brand); }
.btn-icon-danger { color: var(--danger); border: 1px solid rgba(220, 38, 38, 0.2); }
.btn-icon-danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ═══════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════ */
.messages, .content-messages { margin-bottom: 16px; }

.alert {
    padding: 12px 16px; border-radius: var(--radius);
    font-size: 0.86rem; margin-bottom: 8px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; animation: slideIn 0.35s var(--ease);
    backdrop-filter: blur(6px);
}

@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

.alert-success { background: var(--success-bg); color: var(--success); border-left: 4px solid var(--success); }
.alert-error   { background: var(--danger-bg); color: var(--danger); border-left: 4px solid var(--danger); }
.alert-close   { font-size: 1.2rem; font-weight: bold; opacity: 0.5; transition: opacity 0.15s; }
.alert-close:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════ */
.app-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ─────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; z-index: 100;
    transition: width var(--speed) var(--ease), transform var(--speed) var(--ease);
    overflow: visible; /* allow toggle button to overflow */
}

.sidebar-header {
    display: flex; align-items: stretch; justify-content: center;
    padding: 0; min-height: 80px; height: 80px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: relative;
    overflow: visible;
}

.sidebar-logo {
    flex-shrink: 0;
    transition: opacity var(--speed) var(--ease);
}

/* Full logo – visible when sidebar is expanded */
.sidebar-logo-full {
    width: 100%; height: 100%; object-fit: cover;
}

/* Small logo – hidden by default, shown when collapsed */
.sidebar-logo-small {
    display: none;
    width: 100%; height: 100%; object-fit: cover;
}

/* Collapse Toggle Arrow */
.sidebar-toggle {
    position: absolute; right: -14px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--brand); color: #fff; border: 3px solid var(--bg-body);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 200;
    transition: transform 0.25s var(--ease), background 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    outline: none;
}

.sidebar-toggle svg { width: 14px; height: 14px; transition: transform 0.25s var(--ease); }
.sidebar-toggle:hover { background: var(--brand-light); box-shadow: 0 3px 12px rgba(0,61,165,0.4); }

.sidebar-nav {
    flex: 1; padding: 12px 0;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

.nav-section-title {
    padding: 20px 20px 8px; font-size: 0.67rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.3px;
    color: rgba(255,255,255,0.32); white-space: nowrap; overflow: hidden;
    transition: opacity var(--speed);
}

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 18px; margin: 2px 10px; border-radius: var(--radius);
    color: var(--text-sidebar); font-size: 0.88rem; font-weight: 500;
    transition: all 0.18s var(--ease); text-decoration: none;
    white-space: nowrap; overflow: hidden; position: relative;
}

.nav-item:hover { background: var(--bg-sidebar-hover); color: var(--text-inverse); }
.nav-item.active {
    background: var(--bg-sidebar-active); color: var(--text-sidebar-active);
    font-weight: 600;
}
.nav-item.active::before {
    content:''; position:absolute; left:0; top:6px; bottom:6px;
    width:3px; border-radius:0 3px 3px 0; background:var(--accent);
}
.nav-item svg { flex-shrink: 0; width: 20px; height: 20px; }
.nav-item > span:first-of-type {
    overflow: hidden; text-overflow: ellipsis;
    transition: opacity var(--speed), max-width var(--speed);
}

.nav-count-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--brand-dark);
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Tooltip on collapsed sidebar – desktop only */
.nav-item .nav-tooltip {
    display: none; position: absolute; left: calc(var(--sidebar-collapsed-w) + 2px);
    top: 50%; transform: translateY(-50%);
    background: #1e293b; color: #f1f5f9;
    font-size: 0.76rem; font-weight: 600; padding: 5px 12px;
    border-radius: 6px; white-space: nowrap; z-index: 300;
    pointer-events: none; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.nav-item .nav-tooltip::before {
    content: ''; position: absolute; left: -4px; top: 50%; transform: translateY(-50%);
    border: 4px solid transparent; border-right-color: #1e293b;
    border-left: 0;
}
[data-theme="dark"] .nav-item .nav-tooltip {
    background: #334155; color: #e2e8f0;
}
[data-theme="dark"] .nav-item .nav-tooltip::before {
    border-right-color: #334155;
}

/* .sidebar-footer {
    /* border-top: 1px solid rgba(255,255,255,0.08);
    padding: 12px 14px;
    overflow: hidden; */
/* } */ 

.user-info { display: flex; align-items: center; gap: 10px; padding: 8px 6px; overflow: hidden; }
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent); color: var(--brand-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.92rem; flex-shrink: 0;
}
.user-details {
    display: flex; flex-direction: column; min-width: 0;
    overflow: hidden; transition: opacity var(--speed);
}
.user-name {
    font-size: 0.85rem; font-weight: 600; color: #fff;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-role { font-size: 0.72rem; color: rgba(255,255,255,0.45); text-transform: capitalize; }

.logout-btn { margin-top: 6px; border-radius: var(--radius); }
.logout-btn:hover { background: rgba(220,38,38,0.14) !important; color: #f87171 !important; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.55); z-index: 99;
    backdrop-filter: blur(3px); transition: opacity 0.3s;
    -webkit-backdrop-filter: blur(3px);
}

/* ── SIDEBAR COLLAPSED (Desktop) ─────────────────── */
.app-layout.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-w);
}

.app-layout.sidebar-collapsed .sidebar-logo-full {
    display: none;
}
.app-layout.sidebar-collapsed .sidebar-logo-small {
    display: block;
}
.app-layout.sidebar-collapsed .nav-section-title {
    opacity: 0; height: 0; padding: 0; margin: 0; overflow: hidden; pointer-events: none;
}
.app-layout.sidebar-collapsed .user-details {
    opacity: 0; width: 0; overflow: hidden; pointer-events: none;
}
.app-layout.sidebar-collapsed .nav-item > span:first-of-type,
.app-layout.sidebar-collapsed .nav-count-badge,
.app-layout.sidebar-collapsed .logout-btn > span:first-of-type {
    opacity: 0; max-width: 0; overflow: hidden; pointer-events: none;
}

.app-layout.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.app-layout.sidebar-collapsed .nav-item {
    justify-content: center; padding: 12px 0; margin: 2px 8px;
}
.app-layout.sidebar-collapsed .nav-item.active::before { left: 0; }
.app-layout.sidebar-collapsed .user-info { justify-content: center; }
.app-layout.sidebar-collapsed .logout-btn { justify-content: center; padding: 12px 0; }

.app-layout.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed-w); }

/* Tooltip visible on collapsed hover */
.app-layout.sidebar-collapsed .nav-item:hover .nav-tooltip { display: block; }

/* ── MAIN CONTENT ────────────────────────────────── */
.main-content {
    flex: 1; margin-left: var(--sidebar-w);
    min-height: 100vh; display: flex; flex-direction: column;
    transition: margin-left var(--speed) var(--ease);
    background: var(--bg-body);
}

.topbar {
    height: var(--topbar-h); background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 28px; gap: 14px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow-xs);
    transition: background var(--speed), border-color var(--speed);
}

.menu-toggle {
    display: none; background: none; border: none;
    cursor: pointer; color: var(--text-secondary); padding: 6px;
    border-radius: var(--radius);
    transition: background 0.15s;
}
.menu-toggle:hover { background: var(--bg-surface2); }

.page-title { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); flex: 1; letter-spacing: -0.2px; }

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

/* Theme Toggle */
.theme-toggle {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--bg-surface2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-secondary);
    transition: all 0.25s var(--ease); position: relative; overflow: hidden;
}
.theme-toggle:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

.theme-toggle svg { width: 18px; height: 18px; transition: transform 0.4s var(--ease), opacity 0.3s; position: absolute; }
.theme-toggle .icon-sun  { opacity: 0; transform: rotate(90deg) scale(0.5); }
.theme-toggle .icon-moon { opacity: 1; transform: rotate(0) scale(1); }

[data-theme="dark"] .theme-toggle .icon-sun  { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.5); }

.role-badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.role-admin  { background: rgba(0,61,165,0.1); color: var(--brand); }
.role-head   { background: var(--accent-bg); color: #92600a; }
.role-worker { background: var(--success-bg); color: var(--success); }

[data-theme="dark"] .role-admin { color: #6da3f0; }
[data-theme="dark"] .role-head  { color: var(--accent); }

.content-area { flex: 1; padding: 28px; }
.content-messages { padding: 16px 28px 0; }

/* ═══════════════════════════════════════════════════
   STATS GRID
   ═══════════════════════════════════════════════════ */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px; margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-surface); border-radius: var(--radius-lg);
    padding: 22px 24px; display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    transition: all 0.22s var(--ease);
    position: relative; overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute; top: 0; left: 0; bottom: 0;
    width: 4px; border-radius: 0 4px 4px 0;
}
.stat-blue::after   { background: var(--brand); }
.stat-green::after  { background: var(--success); }
.stat-yellow::after { background: var(--accent); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-icon {
    width: 52px; height: 52px; border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-blue   .stat-icon { background: rgba(0,61,165,0.1);  color: var(--brand); }
.stat-green  .stat-icon { background: var(--success-bg);    color: var(--success); }
.stat-yellow .stat-icon { background: var(--accent-bg);     color: #b07c0a; }

[data-theme="dark"] .stat-blue .stat-icon   { color: #6da3f0; }
[data-theme="dark"] .stat-yellow .stat-icon { color: var(--accent); }

.stat-info { display: flex; flex-direction: column; }
.stat-number { font-size: 1.65rem; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.stat-label  { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ═══════════════════════════════════════════════════
   SECTIONS & CARDS
   ═══════════════════════════════════════════════════ */
.section { margin-bottom: 30px; }

.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.section-header h3 { font-size: 1.08rem; font-weight: 700; color: var(--text-primary); }

.card {
    background: var(--bg-surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    overflow: hidden; margin-bottom: 18px;
    transition: background var(--speed), border-color var(--speed), box-shadow var(--speed);
}

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px; border-bottom: 1px solid var(--border);
    flex-wrap: wrap; gap: 10px;
}
.card-header h4 { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 24px; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.head-cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.head-dept-card {
    margin-bottom: 0;
    border-radius: 16px;
    box-shadow: 0 12px 26px rgba(14, 24, 48, 0.08);
}

.head-dept-card-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(0, 61, 165, 0.08), rgba(255, 193, 7, 0.12));
}

.head-dept-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.head-dept-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    color: #fff;
    background: var(--brand);
    flex-shrink: 0;
}

.head-dept-subtitle {
    margin-top: 2px;
    font-size: 0.77rem;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.head-dept-card-body {
    padding: 18px 20px 20px;
}

.head-dept-metric-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-surface2);
}

.head-dept-metric-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--brand);
    background: rgba(0, 61, 165, 0.1);
    flex-shrink: 0;
}

.head-dept-metric-label {
    margin: 0;
    font-size: 0.72rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
}

.head-dept-metric-value {
    margin: 2px 0 0;
    font-size: 1.35rem;
    line-height: 1;
    font-weight: 800;
    color: var(--text-primary);
}

.head-dept-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.head-dept-actions .btn {
    min-width: 150px;
    justify-content: center;
}

/* ── Department Card (Worker View) ───────────────── */
.dept-card {
    padding: 28px; text-align: center;
    transition: all 0.22s var(--ease);
}
.dept-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.dept-card-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(0,61,165,0.08); color: var(--brand);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    transition: background 0.2s;
}
.dept-card:hover .dept-card-icon { background: rgba(0,61,165,0.14); }
[data-theme="dark"] .dept-card-icon { color: #6da3f0; }

/* ── Logbook Card Icon ───────────────────────────── */
.logbook-card-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(0,61,165,0.08); color: var(--brand);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    transition: background 0.2s;
}
.logbook-card:hover .logbook-card-icon { background: rgba(0,61,165,0.14); }
[data-theme="dark"] .logbook-card-icon { color: #6da3f0; }

.dept-card h4 { font-size: 1.04rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.dept-meta { margin-bottom: 6px; }
.dept-head-info { color: var(--text-muted); font-size: 0.84rem; }

/* ═══════════════════════════════════════════════════
   TABLE
   ═══════════════════════════════════════════════════ */
.table-responsive {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    background: var(--bg-surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    transition: background var(--speed), border-color var(--speed);
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table thead { background: var(--bg-surface2); }
.data-table th {
    padding: 14px 18px; text-align: left; font-weight: 700;
    color: var(--text-tertiary); font-size: 0.73rem;
    text-transform: uppercase; letter-spacing: 0.7px;
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td {
    padding: 14px 18px; border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary); vertical-align: middle;
}
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover { background: var(--bg-surface2); }
.data-table tbody tr:last-child td { border-bottom: none; }

.actions-cell {
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
}

.actions-cell > button,
.actions-cell > form {
    display: inline-flex;
    vertical-align: middle;
    margin: 0 3px;
}

.actions-cell > form {
    margin-block: 0;
}
.empty-state { text-align: center; color: var(--text-muted); padding: 28px 16px !important; }

.workers-table,
.all-workers-table {
    border: 1px solid var(--border);
    min-width: 980px;
}

.workers-table th,
.workers-table td,
.all-workers-table th,
.all-workers-table td {
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.workers-table th:last-child,
.workers-table td:last-child,
.all-workers-table th:last-child,
.all-workers-table td:last-child {
    border-right: none;
}

.workers-table tbody tr:last-child td,
.all-workers-table tbody tr:last-child td {
    border-bottom: none;
}

.actions-cell .btn-icon {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--bg-surface2);
}

.btn-icon-edit {
    color: #0f766e;
    border-color: rgba(15, 118, 110, 0.25);
    background: rgba(13, 148, 136, 0.1);
}

.btn-icon-edit:hover {
    color: #0b5f58;
    background: rgba(13, 148, 136, 0.18);
}

.btn-icon-view {
    color: #1d4ed8;
    border-color: rgba(37, 99, 235, 0.25);
    background: rgba(37, 99, 235, 0.1);
}

.btn-icon-view:hover {
    color: #1e40af;
    background: rgba(37, 99, 235, 0.18);
}

.table-tools {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.table-search-input {
    max-width: 320px;
}

/* ── Status Badges ───────────────────────────────── */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.73rem; font-weight: 600; }
.status-badge.active   { background: var(--success-bg); color: var(--success); }
.status-badge.inactive { background: var(--bg-surface2); color: var(--text-muted); }

/* ── Worker Chips ────────────────────────────────── */
.worker-list { margin-top: 18px; }
.worker-list h5 { font-size: 0.84rem; font-weight: 700; color: var(--text-tertiary); margin-bottom: 10px; }

.worker-chips { display: flex; flex-wrap: wrap; gap: 10px; }

.worker-chip {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-surface2); border: 1px solid var(--border);
    padding: 8px 14px; border-radius: var(--radius);
    transition: all 0.15s;
}
.worker-chip:hover { background: var(--bg-surface); box-shadow: var(--shadow-xs); }

.chip-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.78rem; flex-shrink: 0;
}
.chip-info  { display: flex; flex-direction: column; }
.chip-name  { font-size: 0.84rem; font-weight: 600; color: var(--text-primary); }
.chip-email { font-size: 0.7rem; color: var(--text-muted); }

.info-text  { font-size: 0.88rem; margin-bottom: 4px; color: var(--text-secondary); }
.empty-hint { color: var(--text-muted); font-size: 0.86rem; font-style: italic; margin-top: 8px; }

.empty-state-box {
    background: var(--bg-surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    padding: 52px 24px; text-align: center; color: var(--text-muted);
}
.empty-state-box svg { margin-bottom: 12px; opacity: 0.35; }
.empty-state-box p { font-size: 0.94rem; }
.full-width { grid-column: 1 / -1; }

.assign-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 18px;
    overflow-y: auto;
}

.assign-modal-overlay.show { display: flex; }

.assign-modal {
    width: min(640px, calc(100vw - 24px));
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
    padding: 20px 20px 10px;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
}

.assign-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 12px;
}

.assign-modal-header h3 {
    font-size: 1.04rem;
    color: var(--text-primary);
    margin: 0;
}

.assign-modal-subtitle {
    margin: 4px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.assign-modal-group {
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--bg-surface2);
    min-width: 0;
}

.assign-form-error {
    margin-bottom: 10px;
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.82rem;
    font-weight: 600;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-light);
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.detail-row:last-child { border-bottom: none; }
.detail-row span { text-align: right; max-width: 62%; word-break: break-word; }

.assign-logbook-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding: 2px;
}

.assign-logbook-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 10px;
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
}

.assign-logbook-item:hover {
    border-color: var(--brand);
    background: var(--bg-surface2);
}

.assign-logbook-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    flex-shrink: 0;
}

/* ── Role Tag in Tables ──────────────────────────── */
.role-tag {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
}
.role-tag.admin  { background: rgba(0,61,165,0.1); color: var(--brand); }
.role-tag.head   { background: var(--accent-bg); color: #92600a; }
.role-tag.worker { background: var(--success-bg); color: var(--success); }
[data-theme="dark"] .role-tag.admin  { color: #6da3f0; }
[data-theme="dark"] .role-tag.head   { color: var(--accent); }

/* ── Confirm Delete ──────────────────────────────── */
.confirm-delete { text-align: center; padding: 16px 0; }
.delete-icon { margin-bottom: 16px; }
.confirm-delete p { font-size: 1rem; margin-bottom: 4px; color: var(--text-primary); }
.delete-warning { color: var(--text-muted); font-size: 0.84rem; margin-bottom: 24px; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */

/* Tablet & below: hide sidebar collapse, show mobile toggle */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%); width: var(--sidebar-w) !important;
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    .sidebar-overlay.show { display: block; }
    .sidebar-toggle { display: none !important; }

    .main-content { margin-left: 0 !important; }
    .menu-toggle { display: flex; }
}

@media (max-width: 768px) {
    html { font-size: 14px; }
    .content-area { padding: 18px; }
    .content-messages { padding: 12px 18px 0; }
    .topbar { padding: 0 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-number { font-size: 1.3rem; }
    .cards-grid { grid-template-columns: 1fr 1fr; }
    .head-cards-grid { grid-template-columns: 1fr 1fr; }
    .head-dept-actions .btn { min-width: 136px; justify-content: center; }
    .login-container { padding: 32px 24px; }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .workers-table,
    .all-workers-table {
        min-width: 920px;
    }

    .table-tools {
        justify-content: stretch;
    }

    .table-search-input {
        max-width: 100%;
        width: 100%;
    }

    .assign-modal-overlay {
        align-items: flex-start;
        padding: 14px;
    }

    .assign-modal {
        width: 100%;
        max-height: calc(100dvh - 28px);
        padding: 16px 16px 8px;
        border-radius: 14px;
    }

    .assign-modal-header {
        position: sticky;
        top: 0;
        background: var(--bg-surface);
        z-index: 2;
    }

    .assign-logbook-list {
        max-height: 32vh;
    }

    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .detail-row span {
        text-align: left;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    html { font-size: 13.5px; }
    .stats-grid { grid-template-columns: 1fr; }
    .cards-grid { grid-template-columns: 1fr; }
    .head-cards-grid { grid-template-columns: 1fr; }
    .head-dept-card-header { padding: 16px; }
    .head-dept-card-body { padding: 16px; }
    .head-dept-actions { justify-content: center; }
    .head-dept-actions .btn { width: 100%; justify-content: center; }
    .content-area { padding: 14px; }
    .content-messages { padding: 10px 14px 0; }
    .topbar { padding: 0 12px; gap: 8px; }
    .page-title { font-size: 1rem; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .card-header { padding: 14px 16px; }
    .card-body { padding: 16px; }
    .data-table th, .data-table td { padding: 10px 12px; font-size: 0.82rem; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; justify-content: center; }
    .form-grid { grid-template-columns: 1fr; }
    .login-container { padding: 28px 20px; }
    .login-logo { width: 74px; }
    .login-header h1 { font-size: 1.3rem; }
    .worker-chips { flex-direction: column; }
    .worker-chip { width: 100%; }
    .role-badge { font-size: 0.65rem; padding: 2px 8px; }

    .assign-modal-overlay {
        padding: 10px;
    }

    .assign-modal {
        width: 100%;
        max-height: 92vh;
        border-radius: 12px;
    }

    .assign-logbook-list {
        max-height: 26vh;
    }
}

@media (max-width: 360px) {
    .stat-icon { width: 42px; height: 42px; }
    .stat-icon svg { width: 22px; height: 22px; }
    .sidebar { width: 260px !important; }
    .topbar-right { gap: 6px; }
}

