:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #0f172a;
    --accent: #f59e0b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ---------- Navbar ---------- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--secondary);
    color: white;
    padding: 0 1rem;
    min-height: 60px;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.nav-brand { font-size: 1.3rem; font-weight: 700; color: white; white-space: nowrap; }
.nav-brand i { color: var(--accent); margin-right: 0.4rem; }

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.25rem;
    flex: 1;
    flex-wrap: wrap;
    margin-left: 1rem;
}
.nav-links a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.2s;
    font-size: 0.9rem;
    white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active { background: var(--primary); color: white; }

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.user-name { color: #e2e8f0; font-size: 0.85rem; white-space: nowrap; }
.btn-logout {
    color: white;
    text-decoration: none;
    background: var(--danger);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}
.btn-logout:hover { background: #b91c1c; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 170px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    list-style: none;
    padding: 0.4rem 0;
    z-index: 100;
}
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a { color: var(--text) !important; padding: 0.5rem 1rem; display: block; }
.dropdown-menu a:hover { background: var(--bg); }

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 1rem auto; padding: 0 1rem; width: 100%; }

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
    overflow-x: auto;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
}
.card-title { font-size: 1.1rem; font-weight: 600; color: var(--secondary); }

/* ---------- Tables ---------- */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 0.6rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
th { background: #f8fafc; font-weight: 600; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; white-space: nowrap; }
tr:hover { background: #f8fafc; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 0.75rem; min-width: 0; }
label { display: block; font-weight: 500; margin-bottom: 0.25rem; color: var(--secondary); font-size: 0.9rem; }
input, select, textarea {
    width: 100%;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: center;
}
.btn:hover { background: var(--primary-dark); }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); }

/* ---------- Alerts ---------- */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ---------- Dashboard ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}
.stat-card {
    background: var(--card);
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 4px solid var(--primary);
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--secondary); }
.stat-label { color: var(--muted); font-size: 0.8rem; }

/* ---------- Overtime ---------- */
.overtime-row { background: #fef3c7 !important; }
.overtime-badge {
    background: var(--warning);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
}

/* ---------- Week nav ---------- */
.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.week-label { font-size: 1rem; font-weight: 600; }

/* ---------- Login ---------- */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: white; border-radius: 12px; padding: 1.5rem; box-shadow: 0 10px 40px rgba(0,0,0,0.15); }
.login-card h2 { text-align: center; margin-bottom: 1.5rem; color: var(--secondary); }
.login-brand { text-align: center; font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-bottom: 0.5rem; }

/* ---------- Footer ---------- */
.footer { text-align: center; padding: 1.5rem 1rem; color: var(--muted); font-size: 0.8rem; }

/* ---------- Action button groups in tables ---------- */
td[style*="display:flex"] { flex-wrap: wrap; gap: 0.3rem; }

/* ============================================================
   MOBILE RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Tablet */
@media (max-width: 900px) {
    .nav-links { margin-left: 0.5rem; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

/* Phone */
@media (max-width: 640px) {
    .navbar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    .nav-brand { font-size: 1.1rem; text-align: center; }
    .nav-links {
        margin-left: 0;
        justify-content: center;
        gap: 0.25rem;
    }
    .nav-links a { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
    .nav-links a span, .nav-links a i { font-size: 0.8rem; }
    .nav-user {
        justify-content: center;
        border-top: 1px solid rgba(255,255,255,0.1);
        padding-top: 0.5rem;
    }
    .container { margin: 0.5rem auto; padding: 0 0.5rem; }
    .card { padding: 0.75rem; border-radius: 8px; }
    .card-title { font-size: 1rem; }
    .week-nav { flex-direction: column; align-items: stretch; }
    .week-nav > div { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
    .week-label { font-size: 0.9rem; text-align: center; flex: 1; }
    .stat-value { font-size: 1.3rem; }
    th, td { padding: 0.45rem; font-size: 0.75rem; }
    .btn { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
    .btn-sm { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
    .login-card { padding: 1.25rem; }
    /* Make form grids single-column on phones */
    div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

/* Very small phones */
@media (max-width: 380px) {
    .nav-links { flex-direction: column; align-items: stretch; }
    .nav-links a { justify-content: center; }
    .nav-user { flex-direction: column; }
}