/* =================================================================
   CA Firm ERP - Stylesheet
   Brand refresh: firm palette navy #002061 / green #54B848 / amber #FCA900,
   Poppins typeface (bundled offline). Mobile-first.
================================================================== */

/* Poppins — bundled (offline), applied app-wide. */
@font-face{font-family:'Poppins';font-style:normal;font-weight:400;font-display:swap;src:url('../fonts/poppins-latin-400-normal.woff2') format('woff2');}
@font-face{font-family:'Poppins';font-style:normal;font-weight:500;font-display:swap;src:url('../fonts/poppins-latin-500-normal.woff2') format('woff2');}
@font-face{font-family:'Poppins';font-style:normal;font-weight:600;font-display:swap;src:url('../fonts/poppins-latin-600-normal.woff2') format('woff2');}
@font-face{font-family:'Poppins';font-style:normal;font-weight:700;font-display:swap;src:url('../fonts/poppins-latin-700-normal.woff2') format('woff2');}

:root {
    /* Brand palette (locked): navy #002061, green #54B848, amber #FCA900 */
    --navy: #002061;
    --navy-2: #1a3a6e;
    --navy-3: #2c5aa0;
    --navy-deep: #001640;
    /* Paper: slightly cooler and lighter for calmer, more modern feel */
    --paper: #f5f6f7;
    --paper-2: #eef0f3;
    /* Surface (cards): bright white to stand out from the page bg */
    --surface: #ffffff;
    --surface-2: #f8fafc;
    /* Ink: softer and more refined */
    --ink: #1f2937;
    --ink-2: #4b5563;
    --ink-3: #6b7280;
    --ink-soft: #9ca3af;
    /* Lines: subtle blue-grey */
    --line: #e5e7eb;
    --line-2: #d1d5db;
    /* Accent = brand green (active markers, focus, links); amber for badges */
    --accent: #54b848;
    --accent-2: #47a03b;
    --accent-soft: #eef7e9;  /* very light green tint for backgrounds */
    --amber: #fca900;
    --amber-soft: #fff4dd;
    --danger: #b91c1c;
    --warn: #c2410c;
    --success: #15803d;
    --info: #1e6091;
    --critical-bg: #fef2f2;
    --warn-bg: #fff7ed;
    --success-bg: #f0fdf4;

    /* Type — Poppins across the board (brand) */
    --font-serif: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
    --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

    /* Layout */
    --topbar-h: 56px;
    --sidebar-w: 260px;
    --bottomnav-h: 64px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 41, 66, 0.04);
    --shadow: 0 1px 3px rgba(15, 41, 66, 0.06);
    --shadow-lg: 0 4px 16px rgba(15, 41, 66, 0.10);
}

/* Pull in google fonts */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

html, body {
    font-family: var(--font-sans);
    color: var(--ink);
    background: var(--paper);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    padding-top: var(--topbar-h);
    padding-bottom: var(--bottomnav-h);
}

a { color: var(--navy-3); text-decoration: none; }
a:hover { color: var(--accent); }

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; color: var(--navy); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }

.subtitle { color: var(--ink-3); font-size: 0.95rem; margin-bottom: 1.5rem; }

/* ============ TOPBAR ============ */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
    background: var(--navy);
    color: var(--paper);
    z-index: 100;
    box-shadow: var(--shadow);
}
.topbar-inner {
    height: 100%;
    display: flex; align-items: center;
    padding: 0 1rem;
    gap: 1rem;
}
.menu-btn {
    background: none; border: none; color: var(--paper);
    cursor: pointer; padding: 0.4rem;
    border-radius: var(--radius);
    display: flex; align-items: center;
}
.menu-btn:hover { background: rgba(255,255,255,0.08); }
.brand {
    display: flex; align-items: center; gap: 0.6rem;
    color: var(--paper); font-family: var(--font-serif);
    font-size: 1.25rem; font-weight: 600;
}
.brand:hover { color: var(--accent-2); }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    background: var(--accent); color: var(--navy);
    border-radius: 6px; font-weight: 700; font-size: 0.85rem;
    font-family: var(--font-sans);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.35rem; }
.user-pill {
    background: rgba(255,255,255,0.1);
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* ============ SIDEBAR (mobile drawer / desktop fixed) ============ */
.sidebar {
    position: fixed; top: var(--topbar-h); left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - var(--topbar-h));
    background: var(--paper-2);
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 95;
    overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.sidebar-inner { padding: 1rem 0; display: flex; flex-direction: column; min-height: 100%; }
.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
.logout-form { width: 100%; }
.logout-btn { background: none; border: none; cursor: pointer; width: 100%; text-align: left; font: inherit; color: inherit; }
.nav-section {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--ink-3); padding: 1rem 1.25rem 0.4rem;
    font-weight: 600;
}
.nav-link {
    display: flex; align-items: center;
    padding: 0.75rem 1.25rem;
    color: var(--ink-2);
    font-size: 0.95rem;
    gap: 0.75rem;
    border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(15,41,66,0.05); color: var(--navy); }
.nav-link.active { background: rgba(15,41,66,0.08); color: var(--navy); border-left-color: var(--accent); font-weight: 600; }
.nav-icon {
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--navy); color: var(--accent-2);
    border-radius: 4px; font-size: 0.8rem;
    flex-shrink: 0;
}
.badge {
    margin-left: auto;
    background: var(--amber); color: #3a2300;
    font-size: 0.7rem; font-weight: 600;
    padding: 0.15rem 0.45rem; border-radius: 10px;
}
.badge-warn { background: var(--warn); color: #fff; }
.sidebar-overlay {
    position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(0,0,0,0.3);
    z-index: 90;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

/* ============ MAIN ============ */
.main {
    padding: 1.25rem 1rem;
    max-width: 1280px;
    margin: 0 auto;
}

/* ============ BOTTOM NAV (mobile) ============ */
.bottomnav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: var(--paper);
    border-top: 1px solid var(--line);
    display: flex; justify-content: space-around; align-items: stretch;
    z-index: 80;
    padding-bottom: env(safe-area-inset-bottom);
}
.bn-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--ink-3); font-size: 0.7rem; gap: 0.15rem;
}
.bn-item:hover, .bn-item.active { color: var(--navy); }
.bn-icon {
    font-size: 1.1rem;
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
}
.bn-fab .bn-icon {
    background: var(--accent); color: var(--navy);
    border-radius: 50%; width: 36px; height: 36px;
    font-size: 1.4rem; font-weight: 700;
    margin-top: -16px;
    box-shadow: var(--shadow);
}

/* ============ MESSAGES ============ */
.msgs { margin-bottom: 1rem; }
.msg {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    border-left: 3px solid;
    font-size: 0.92rem;
}
.msg-success { background: var(--success-bg); border-left-color: var(--success); color: var(--success); }
.msg-error, .msg-danger { background: var(--critical-bg); border-left-color: var(--danger); color: var(--danger); }
.msg-warning { background: var(--warn-bg); border-left-color: var(--warn); color: var(--warn); }
.msg-info { background: #eff6ff; border-left-color: var(--info); color: var(--info); }

/* ============ CARDS ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; gap: 1rem;
    flex-wrap: wrap;
}
.card-title { font-family: var(--font-serif); font-size: 1.3rem; color: var(--navy); }
.card-subtitle { color: var(--ink-3); font-size: 0.85rem; }

/* ============ STAT TILES ============ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem; margin-bottom: 1.5rem;
}
.stat {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: var(--accent);
}
.stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; }
.stat-value {
    font-family: var(--font-sans);
    font-size: 1.85rem;
    color: var(--navy);
    font-weight: 600;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums lining-nums;
    letter-spacing: -0.01em;
}
.stat-foot { font-size: 0.78rem; color: var(--ink-3); margin-top: 0.25rem; }
.stat.stat-danger::before { background: var(--danger); }
.stat.stat-warn::before { background: var(--warn); }
.stat.stat-success::before { background: var(--success); }
.stat.stat-danger .stat-value { color: var(--danger); }

/* ============ ENGAGEMENT / DUE-DATE LIST ============ */
.eng-list { display: flex; flex-direction: column; gap: 0.6rem; }
.eng-row {
    display: block;
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.eng-row:hover { border-color: var(--navy-3); box-shadow: var(--shadow-sm); color: var(--ink); }
.eng-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.eng-title { font-weight: 600; color: var(--navy); font-size: 0.98rem; }
.eng-client { color: var(--ink-3); font-size: 0.85rem; margin-top: 0.1rem; }
.eng-meta { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.4rem; font-size: 0.78rem; color: var(--ink-3); }
.eng-meta span { display: inline-flex; align-items: center; gap: 0.25rem; }

.urgency-tag {
    display: inline-block; padding: 0.2rem 0.6rem;
    border-radius: 4px; font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    flex-shrink: 0;
}
.urgency-overdue { background: #fee2e2; color: #991b1b; border: 1px solid #991b1b; }
.urgency-critical { background: #ffedd5; color: #c2410c; border: 1px solid #fdba74; }  /* orange */
.urgency-soon { background: #fef9c3; color: #854d0e; }  /* yellow */
.urgency-normal { background: #d1fae5; color: #065f46; }  /* green */

/* status badges - refined pastel pills (Option B refresh) */
.status-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 0.2rem 0.55rem;
    border-radius: 6px; font-size: 0.72rem; font-weight: 500;
    background: var(--paper-2); color: var(--ink-2);
    border: none;
    letter-spacing: 0.01em;
}
.status-not_started { background: #f1f3f5; color: #475569; }
.status-in_progress { background: #e6f1fb; color: #185fa5; }
.status-pending_client { background: #faeeda; color: #854f0b; }
.status-under_review { background: #eeedfe; color: #534ab7; }
.status-pending_partner { background: #fbeaf0; color: #993556; }
.status-completed, .status-filed { background: #e1f5ee; color: #1d9e75; }
.status-on_hold { background: #f1f3f5; color: #64748b; }
.status-cancelled { background: #fee2e2; color: #b91c1c; }
/* task/issue statuses */
.status-open { background: #faeeda; color: #854f0b; }
.status-resolved { background: #eeedfe; color: #534ab7; }
.status-closed { background: #e1f5ee; color: #1d9e75; }
/* timesheet & leave statuses */
.status-draft { background: #f1f3f5; color: #475569; }
.status-submitted { background: #e6f1fb; color: #185fa5; }
.status-approved { background: #e1f5ee; color: #1d9e75; }
.status-rejected { background: #fee2e2; color: #b91c1c; }
.status-pending { background: #faeeda; color: #854f0b; }
.status-add { background: #e1f5ee; color: #1d9e75; }
.status-edit { background: #e6f1fb; color: #185fa5; }
.status-delete { background: #fee2e2; color: #b91c1c; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
    width: 100%; border-collapse: collapse; font-size: 0.875rem;
    font-family: var(--font-sans);
    background: var(--surface); border-radius: 10px; overflow: hidden;
    border: 1px solid var(--line);
}
.table th, .table td { padding: 0.75rem 0.9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th {
    background: var(--surface-2);
    font-weight: 600; color: var(--ink-3);
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num {
    text-align: right; font-variant-numeric: tabular-nums;
    font-family: var(--font-sans); font-feature-settings: "tnum";
}

/* ============ FORMS ============ */
.form { display: flex; flex-direction: column; gap: 1rem; max-width: 600px; }
.form-row { display: flex; flex-direction: column; gap: 0.3rem; }
.form-row label { font-size: 0.82rem; color: var(--ink-2); font-weight: 500; }
.form-row input[type=text], .form-row input[type=email], .form-row input[type=password],
.form-row input[type=number], .form-row input[type=date], .form-row input[type=tel],
.form-row select, .form-row textarea {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    font: inherit; font-size: 0.92rem;
    background: var(--surface-2);
    color: var(--ink);
    transition: all 0.12s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none; border-color: var(--accent); background: var(--surface);
    box-shadow: 0 0 0 3px rgba(184,134,11,0.12);
}
.form-row .help { font-size: 0.78rem; color: var(--ink-3); }
.form-row .errors { color: var(--danger); font-size: 0.82rem; }
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--navy);
    background: var(--navy); color: white;
    border-radius: var(--radius);
    font: inherit; font-weight: 500; font-size: 0.88rem;
    cursor: pointer; transition: all 0.12s;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { background: var(--navy-2); color: white; border-color: var(--navy-2); }
.btn-secondary { background: var(--surface); color: var(--navy); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--surface-2); color: var(--navy); border-color: var(--navy); }
.btn-accent { background: var(--navy); border-color: var(--navy); color: white; font-weight: 600; }
.btn-accent:hover { background: var(--navy-2); border-color: var(--navy-2); color: white; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-danger:hover { background: #991b1b; border-color: #991b1b; color: white; }
.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.8rem; }
.btn-ghost { background: none; border: 1px solid transparent; color: var(--ink-3); padding: 0.35rem 0.55rem; }
.btn-ghost:hover { background: var(--paper-2); color: var(--navy); }

/* ============ FILTER BAR ============ */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 0.5rem;
    margin-bottom: 1rem; align-items: center;
}
.filter-bar select, .filter-bar input[type=search], .filter-bar input[type=text] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    font: inherit; font-size: 0.9rem;
    background: white;
}

/* ============ DUE DATE GROUPS ============ */
.due-group { margin-bottom: 2rem; }
.due-group-head {
    display: flex; align-items: center; gap: 0.6rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--line);
}
.due-group-head h2 { font-size: 1.15rem; margin: 0; }
.due-count {
    background: var(--paper-2); padding: 0.1rem 0.5rem;
    border-radius: 10px; font-size: 0.8rem; color: var(--ink-3);
    font-weight: 600;
}
.due-group.overdue h2 { color: var(--danger); }
.due-group.critical h2 { color: var(--warn); }

/* ============ STEPS / CHECKLIST ============ */
.steps { list-style: none; }
.step {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 0.4rem;
    background: white;
}
.step.done { background: var(--success-bg); border-color: #bbf7d0; }
.step.done .step-title { text-decoration: line-through; color: var(--ink-3); }
.step-toggle {
    width: 22px; height: 22px;
    border: 2px solid var(--line-2); border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; background: white; padding: 0;
    flex-shrink: 0;
}
.step.done .step-toggle { background: var(--success); border-color: var(--success); color: white; }
.step-title { flex: 1; font-size: 0.92rem; }
.step-meta { font-size: 0.75rem; color: var(--ink-3); }

/* ============ LOGIN PAGE ============ */
.login-wrap {
    min-height: 100vh;
    margin-top: calc(-1 * var(--topbar-h));
    padding-bottom: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 2rem 1rem;
    background: var(--paper);
    /* Subtle gradient for visual interest without being heavy */
    background-image:
        radial-gradient(ellipse 800px 600px at 50% -200px, rgba(15, 41, 66, 0.04), transparent),
        radial-gradient(ellipse 600px 400px at 0% 100%, rgba(184, 134, 11, 0.04), transparent);
}
.login-card {
    background: var(--surface);
    padding: 2.5rem 2.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    max-width: 400px; width: 100%;
    box-shadow: var(--shadow);
}
.login-brand {
    text-align: center; margin-bottom: 1.75rem;
}
.login-brand .brand-mark {
    width: 56px; height: 56px; font-size: 1.4rem;
    margin: 0 auto 1rem;
    background: var(--navy); color: white;
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif); font-weight: 600;
}
.login-brand h1 {
    font-size: 1.5rem; color: var(--navy);
    font-family: var(--font-serif); font-weight: 600;
}
.login-brand p { color: var(--ink-3); font-size: 0.9rem; margin-top: 0.25rem; }

/* ============ TIMESHEET WEEKLY GROUPS ============ */
.day-group { margin-bottom: 1.5rem; }
.day-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 0.5rem; padding-bottom: 0.3rem;
    border-bottom: 1px dashed var(--line);
}
.day-head h3 { font-family: var(--font-sans); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); margin: 0; }
.day-total { font-family: var(--font-mono); font-weight: 600; color: var(--navy); font-size: 0.9rem; }
.ts-entry {
    display: flex; gap: 0.75rem; align-items: flex-start;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: white; margin-bottom: 0.4rem;
}
.ts-hours { font-family: var(--font-mono); font-weight: 600; color: var(--accent); font-size: 1.05rem; min-width: 48px; }
.ts-body { flex: 1; min-width: 0; }
.ts-eng { font-weight: 500; color: var(--navy); font-size: 0.92rem; }
.ts-desc { color: var(--ink-3); font-size: 0.82rem; margin-top: 0.1rem; }
.ts-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }

/* ============ DESKTOP LAYOUT ============ */
@media (min-width: 900px) {
    body { padding-bottom: 0; }
    .menu-btn { display: none; }
    .sidebar { transform: translateX(0); }
    .sidebar-overlay { display: none; }
    .main { margin-left: var(--sidebar-w); max-width: none; padding: 2rem; }
    .bottomnav { display: none; }
    h1 { font-size: 1.6rem; }
}

@media (min-width: 1280px) {
    .main { max-width: calc(1280px); margin: 0 auto 0 var(--sidebar-w); }
}

/* small mobile tweaks (Round 5 polish) */
@media (max-width: 480px) {
    h1 { font-size: 1.25rem; }
    .stat-value { font-size: 1.6rem; }
    .main { padding: 1rem 0.75rem; }
    /* Bigger touch targets */
    .btn { padding: 0.6rem 0.85rem; min-height: 40px; }
    .btn-sm { padding: 0.45rem 0.65rem; min-height: 36px; }
    .nav-link { padding: 0.85rem 1rem; }
    .bn-item { padding: 0.5rem 0.3rem; min-height: 56px; }
    /* Inputs more tappable */
    input[type=text], input[type=email], input[type=password],
    input[type=number], input[type=date], input[type=tel],
    select, textarea {
        font-size: 16px;  /* prevents iOS zoom */
        padding: 0.65rem 0.75rem;
    }
    /* Tighter tables */
    table.table { font-size: 0.82rem; }
    table.table th, table.table td { padding: 0.5rem 0.4rem; }
    /* Simpler topbar on mobile */
    .topbar { padding: 0.5rem 0.75rem; }
    .brand-text { font-size: 1rem; }
}

/* Floating "Log Time" button on engagement page (mobile) */
@media (max-width: 768px) {
    .fab-log-time {
        position: fixed;
        bottom: 75px; /* above bottom nav */
        right: 16px;
        z-index: 50;
        background: var(--accent);
        color: white;
        border: none;
        border-radius: 50%;
        width: 56px; height: 56px;
        font-size: 1.6rem;
        font-weight: bold;
        box-shadow: 0 4px 12px rgba(0,0,0,0.25);
        cursor: pointer;
    }
    .fab-log-time:active { transform: scale(0.95); }
}
@media (min-width: 769px) {
    .fab-log-time { display: none; }
}

/* Print */
@media print {
    .topbar, .sidebar, .bottomnav, .filter-bar, .form-actions { display: none; }
    body { padding: 0; }
    .main { margin: 0; padding: 1rem; }
}

/* Auto-uppercase visual hint for PAN/TAN/GSTIN inputs */
input[name="pan"], input[name="tan"], input[name$="-pan"], input[name$="-gstin"],
input[name="cin_llpin_din"], input[name$="-din"] {
    text-transform: uppercase;
}

/* User menu in top-right header */
.user-menu { position: relative; }
.user-menu-trigger {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: rgba(255,255,255,0.08); color: white;
    border: 1px solid rgba(255,255,255,0.18);
    padding: 0.4rem 0.85rem; border-radius: 100px;
    cursor: pointer; font: inherit; font-size: 0.9rem;
}
.user-menu-trigger:hover { background: rgba(255,255,255,0.14); }
.user-menu-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 600; object-fit: cover;
}
.user-menu-panel {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: white; color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius);
    min-width: 220px; padding: 0.4rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    display: none; z-index: 100;
}
.user-menu.open .user-menu-panel { display: block; }
.user-menu-panel a, .user-menu-panel button {
    display: block; width: 100%; text-align: left;
    padding: 0.55rem 0.75rem; border: 0; background: none;
    color: var(--ink); text-decoration: none; font: inherit; font-size: 0.88rem;
    border-radius: 4px; cursor: pointer;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--paper-2); }
.user-menu-divider { border-top: 1px solid var(--line); margin: 0.3rem 0; }

/* Round 6: Daily timesheet reminder banner */
.timesheet-reminder {
    background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-left: 4px solid #d97706;
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    animation: tr-slide 0.3s ease-out;
}
.timesheet-reminder .tr-icon { font-size: 1.4rem; }
.timesheet-reminder .tr-body { flex: 1; font-size: 0.92rem; color: #78350f; }
.timesheet-reminder .tr-sub { font-size: 0.8rem; color: #92400e; margin-top: 2px; }
.timesheet-reminder .tr-action { white-space: nowrap; }
@keyframes tr-slide {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@media (max-width: 480px) {
    .timesheet-reminder { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .timesheet-reminder .tr-action { align-self: stretch; text-align: center; }
}

/* Meeting notification banner (in-app; mirrors the timesheet reminder) */
.meeting-alert {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-left: 4px solid var(--accent-2);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    animation: tr-slide 0.3s ease-out;
}
.meeting-alert .ma-icon { font-size: 1.3rem; }
.meeting-alert .ma-body { flex: 1; font-size: 0.92rem; color: var(--ink); }
.meeting-alert .ma-list { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.3rem; }
.meeting-alert .ma-item { font-size: 0.84rem; color: var(--ink-2); text-decoration: none; }
.meeting-alert .ma-item:hover { color: var(--navy); }
.meeting-alert .ma-when {
    display: inline-block; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.03em;
    padding: 0.05rem 0.4rem; border-radius: 999px; margin-right: 0.4rem; vertical-align: middle;
}
.meeting-alert .ma-today { background: var(--amber); color: #3a2300; }
.meeting-alert .ma-tmw { background: var(--accent); color: #fff; }
.meeting-alert .ma-action { white-space: nowrap; }
@media (max-width: 480px) {
    .meeting-alert { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .meeting-alert .ma-action { align-self: stretch; text-align: center; }
}

/* Breadcrumb / back-arrow bar (shown on every page except the dashboard) */
.crumbbar {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 1rem; font-size: 0.85rem; color: var(--ink-3);
    flex-wrap: wrap;
}
.crumb-back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 8px;
    border: 1px solid var(--line-2); background: var(--surface);
    color: var(--navy); font-size: 1.15rem; line-height: 1;
    cursor: pointer; text-decoration: none; flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}
.crumb-back:hover { background: var(--accent-soft); border-color: var(--accent); }
.crumb-home { color: var(--navy); text-decoration: none; font-weight: 600; }
.crumb-home:hover { text-decoration: underline; }
.crumb-sep { color: var(--ink-soft); }
.crumb-link { color: var(--navy); text-decoration: none; font-weight: 500; }
.crumb-link:hover { text-decoration: underline; }
.crumb-cur { color: var(--ink-2); font-weight: 600; }
.crumbbar { flex-wrap: wrap; }
.crumb-link, .crumb-cur { max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ MOBILE APP-SHELL (installed PWA) ============
   Pin the header and bottom tab bar, and scroll ONLY the middle.
   On installed iOS PWAs position:fixed bars drift during scroll; a
   full-height flex column with an internal scroll area is rock-solid.
   Also pads the header below the status bar / notch (safe-area). */
@media (max-width: 899px) {
    html { height: 100%; }
    body {
        height: 100vh;          /* fallback for older iOS */
        height: 100dvh;         /* dynamic viewport on modern iOS */
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;       /* the body itself no longer scrolls */
        padding: 0;             /* drop the old fixed-bar offsets */
    }
    .topbar {
        position: static;
        flex: 0 0 auto;
        height: auto;
        min-height: var(--topbar-h);
        padding: 0.5rem 0.75rem;
        padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
    }
    .main {
        flex: 1 1 auto;
        min-height: 0;          /* allow the flex child to scroll */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0;
    }
    .bottomnav {
        position: static;
        flex: 0 0 auto;
    }
    /* Drawer sits just below the (now static) header */
    .sidebar {
        top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
        height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top, 0px));
    }
    /* Login page: fill the scroll area without the fixed-bar offset hack */
    .login-wrap { min-height: 100%; margin-top: 0; }
}

/* ===== Flatpickr — Smart Business Suite brand theme ===== */
/* navy = #002061, green = #54B848, amber = #FCA900 */
.flatpickr-calendar{font-family:'Poppins',sans-serif;border-radius:14px;box-shadow:0 8px 30px rgba(0,32,97,.16);border:1px solid var(--line-2)}
.flatpickr-months{background:#002061;border-radius:14px 14px 0 0;padding:6px 0}
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year{color:#fff;fill:#fff}
.flatpickr-monthDropdown-months{background:#002061}
/* month dropdown OPTIONS render on a white native list — force readable text */
.flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{color:#1f2937;background:#fff}
.flatpickr-monthDropdown-months .flatpickr-monthDropdown-month:hover{background:#eaf6ec;color:#002061}
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg{fill:#fff}
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg{fill:#FCA900}
.numInputWrapper span.arrowUp:after{border-bottom-color:#fff}
.numInputWrapper span.arrowDown:after{border-top-color:#fff}
span.flatpickr-weekday{color:#002061;font-weight:600}
.flatpickr-day{border-radius:8px}
.flatpickr-day.selected,.flatpickr-day.selected:hover,
.flatpickr-day.startRange,.flatpickr-day.endRange{
   background:#54B848;border-color:#54B848;color:#fff;font-weight:600}
.flatpickr-day.today{border-color:#FCA900}
.flatpickr-day.today:hover{background:#FCA900;border-color:#FCA900;color:#fff}
.flatpickr-day:hover{background:#eaf6ec;border-color:#eaf6ec}
.flatpickr-day.inRange{background:#eaf6ec;border-color:#eaf6ec;box-shadow:-5px 0 0 #eaf6ec,5px 0 0 #eaf6ec}

/* ============ NOTIFICATION BELL ============ */
.notif-bell { position: relative; margin-right: 0.5rem; }
.notif-trigger {
    background: transparent; border: none; cursor: pointer; color: #fff;
    padding: 0.3rem; display: inline-flex; align-items: center; justify-content: center;
    position: relative; border-radius: 8px;
}
.notif-trigger:hover { background: rgba(255,255,255,0.12); }
.notif-badge {
    position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px;
    padding: 0 5px; background: #e24b4a; color: #fff; font-size: 0.68rem; font-weight: 700;
    border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
    line-height: 1; border: 2px solid var(--navy, #002061);
}
.notif-panel {
    position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-width: 90vw;
    background: #fff; border: 1px solid var(--line-2, #d1d5db); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); z-index: 1000; display: none; overflow: hidden;
}
.notif-bell.open .notif-panel { display: block; }
.notif-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line, #eef0f2);
    font-weight: 600; font-size: 0.9rem; color: var(--ink, #1f2937);
}
.notif-readall { background: none; border: none; color: var(--navy-3, #2c5aa0); font-size: 0.78rem; cursor: pointer; }
.notif-readall:hover { text-decoration: underline; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
    display: block; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line, #f1f3f5);
    text-decoration: none; color: var(--ink, #1f2937); font-size: 0.85rem; line-height: 1.4;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #f4f8ff; }
.notif-item.unread:hover { background: #eef5ff; }
.notif-item .notif-when { display: block; font-size: 0.72rem; color: var(--ink-3, #6b7280); margin-top: 0.2rem; }
.notif-empty { padding: 1.2rem 0.9rem; text-align: center; color: var(--ink-3, #6b7280); font-size: 0.85rem; }
@media (max-width: 480px) { .notif-panel { position: fixed; top: 56px; right: 8px; left: 8px; width: auto; } }
/* Mobile top bar: match the clean layout — avatar + caret only, no cut-off name */
@media (max-width: 640px) {
    .user-menu-name { display: none; }
    .user-menu-trigger { padding: 0.3rem 0.4rem; gap: 0.25rem; }
    .topbar-right { gap: 0.15rem; }
    .brand-text {
        max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
}

/* ---- notification alert animations + enable-sound pill ---- */
@keyframes notifPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.4); }
    60% { transform: scale(1); }
    100% { transform: scale(1); }
}
.notif-badge.pulse { animation: notifPulse 0.55s ease 3; }
@keyframes notifRing {
    0%,100% { transform: rotate(0); }
    20% { transform: rotate(16deg); }
    40% { transform: rotate(-13deg); }
    60% { transform: rotate(9deg); }
    80% { transform: rotate(-5deg); }
}
.notif-bell.ring .notif-trigger svg { animation: notifRing 0.7s ease; transform-origin: 50% 10%; }
.notif-enable {
    position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
    background: var(--navy, #002061); color: #fff; border: none; border-radius: 999px;
    padding: 0.6rem 1.05rem; font-size: 0.85rem; font-weight: 500; z-index: 2000;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25); cursor: pointer;
    display: inline-flex; align-items: center; gap: 0.3rem; font-family: inherit;
    max-width: 92vw;
}
.notif-enable:hover { background: var(--navy-2, #1a3a6e); }

/* notification panel close button (esp. mobile, where the panel covers the bell) */
.notif-close { background:none; border:none; color:var(--ink-3); font-size:0.95rem; cursor:pointer; padding:0.1rem 0.35rem; line-height:1; border-radius:6px; }
.notif-close:hover { color:var(--ink); background:var(--line); }
