/* =============================================================
   style.css — Time Tracker
   Colour variables live in theme.css
   ============================================================= */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---- Base body ---- */
body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    min-height: 100vh;
    --environment-banner-height: 0px;
    --app-header-offset: calc(var(--environment-banner-height) + var(--header-height) + env(safe-area-inset-top, 0px));
}
body:not(.login-page) {
    padding-top: var(--app-header-offset);
}
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh; /* smooths iOS Safari chrome behaviour */
    padding-top: var(--environment-banner-height);
}

/* ---- Header / app shell ---- */
.environment-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--environment-banner-height);
    padding: 0 1rem;
    overflow: hidden;
    background: var(--environment-banner-background);
    color: var(--environment-banner-foreground);
    font-size: .9rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-align: center;
}
header {
    position: fixed;
    top: var(--environment-banner-height);
    left: 0;
    right: 0;
    z-index: 40;
    background: var(--primary);
    color: #fff;
    padding: 0 1.5rem;
}
.header-inner {
    max-width: none;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    gap: 1rem;
}
.logo { font-size: 1.1rem; font-weight: 700; letter-spacing: -.3px; color: #fff; white-space: nowrap; }

.app-sidebar {
    position: fixed;
    top: var(--app-header-offset);
    left: 0;
    height: calc(100dvh - var(--app-header-offset));
    width: 260px;
    background: #fff;
    border-right: 1px solid #dbe3ee;
    display: flex;
    flex-direction: column;
    z-index: 35;
    overflow-y: auto;
}
.app-sidebar-brand {
    display: none;
    padding: 1rem 1.25rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid #e2e8f0;
}
.app-nav { padding: 1rem 0 .75rem; }
.app-nav-group { margin: .1rem 0; }
.app-nav-group > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.app-nav-group > summary::-webkit-details-marker { display: none; }
.app-nav-group > summary::after {
    content: "";
    float: right;
    width: .45rem;
    height: .45rem;
    margin-top: .38rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform .15s ease;
}
.app-nav-group[open] > summary::after { transform: rotate(225deg); margin-top: .58rem; }
.app-nav-heading {
    min-height: 34px;
    padding: .6rem 1.2rem;
    color: #526174;
    font-size: .875rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}
.app-nav-heading:hover { color: #64748b; }
.app-nav-section {
    padding: .9rem 1.2rem .35rem;
    color: #94a3b8;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.app-nav > .app-nav-group {
    margin: .35rem 0;
}
.app-nav > .app-nav-group > .app-nav-heading {
    color: #334155;
    border-left: 4px solid transparent;
}
.app-nav-muted-group > .app-nav-heading {
    color: #64748b;
    font-weight: 600;
}
.app-nav-muted-group[open] > .app-nav-heading {
    color: #475569;
}
.app-nav-parent {
    padding: .7rem 1.2rem .25rem;
    color: #334155;
    font-size: .875rem;
    font-weight: 600;
}
.app-nav-link {
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: .42rem 1.2rem;
    color: #526174;
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: background .12s, color .12s, border-color .12s;
}
.app-nav-link:hover { background: #f8fafc; color: var(--primary); }
.app-nav-link.active {
    background: #eef6f4;
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 700;
}
.app-nav-sub {
    min-height: 34px;
    padding-left: 2rem;
    font-size: .875rem;
}
.app-nav-subgroup > .app-nav-heading {
    border-left: 4px solid transparent;
    padding-left: 2rem;
    font-size: .875rem;
    color: #64748b;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
}
.app-nav > .app-nav-group > .app-nav-subgroup > .app-nav-heading {
    padding-left: 2rem;
}
.app-nav > .app-nav-subgroup > .app-nav-heading {
    padding-left: 1.2rem;
}
.app-nav > .app-nav-group > .app-nav-subgroup > .app-nav-link {
    padding-left: 2.8rem;
}
.app-nav > .app-nav-subgroup > .app-nav-link {
    padding-left: 2rem;
}
.app-nav-subdeep {
    min-height: 32px;
    padding-left: 2.8rem;
    font-size: .875rem;
    font-weight: 500;
}
.app-nav-logout {
    margin-top: auto;
    border-top: 1px solid #e2e8f0;
    color: #64748b;
}

/* Admin header links */
.header-links a       { color: var(--primary-tint-text); text-decoration: none; font-size: .85rem; }
.header-links a:hover { color: #fff; }

.user-info        { font-size: .85rem; opacity: .9; white-space: nowrap; }
.user-info a       { color: var(--primary-tint-text); text-decoration: none; }
.user-info a:hover { color: #fff; }

/* ---- Main container ---- */
main {
    max-width: 1280px;
    margin: 0 auto;
    margin-left: 260px;
    padding: 1.5rem;
}

/* ---- Flash messages ---- */
.flash { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1.25rem; font-size: .875rem; }
.flash-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; }
.flash-success { background: #f0fdf4; border: 1px solid #86efac; color: #15803d; }

/* ---- Cards (admin panels, quick, import) ---- */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; margin-bottom: 1.25rem; }
.card-header { padding: .75rem 1rem; background: #f8fafc; border-bottom: 1px solid #e2e8f0; font-weight: 600; font-size: .9rem; color: #334155; }
.card-body { padding: 1rem; }

/* ---- List table (admin panels) ---- */
.list-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.list-table th {
    padding: .45rem .75rem;
    text-align: left;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    font-weight: 600;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.list-table td { padding: .55rem .75rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.list-table tbody tr:last-child td { border-bottom: none; }
.list-table tbody tr:hover td { background: #fafafa; }
.td-actions { text-align: right; width: 100px; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-row td { text-align: center; color: #94a3b8; padding: 1.5rem; font-size: .875rem; }

.customer-list-table { table-layout: fixed; }
.customer-list-table .customer-list-name { width: 26%; }
.customer-list-table .customer-list-bc { width: 16%; }
.customer-list-table .customer-list-xsp { width: 22%; }
.customer-list-table .customer-list-rate { width: 14%; }
.customer-list-table .customer-list-projects { width: 12%; }
.customer-list-table .customer-list-actions { width: 100px; }
.customer-list-table th:nth-child(4),
.customer-list-table th:nth-child(5),
.customer-list-table td:nth-child(4),
.customer-list-table td:nth-child(5) {
    text-align: right;
}
.customer-list-table th:last-child,
.customer-list-table td:last-child {
    text-align: right;
}
.customer-list-table td:nth-child(2),
.customer-list-table td:nth-child(3) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.customer-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.customer-list-header-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.customer-filter-input {
    width: min(280px, 36vw);
    min-width: 180px;
    padding: .35rem .55rem;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #1e293b;
    font: inherit;
    font-size: .82rem;
    font-weight: 400;
}
.customer-filter-input:focus {
    outline: 2px solid var(--primary-tint-mid);
    outline-offset: 1px;
    border-color: var(--primary);
}

.integration-run-json {
    min-width: 420px;
    margin-top: .6rem;
    padding: .75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
.integration-run-json strong {
    display: block;
    margin: .65rem 0 .3rem;
    font-size: .75rem;
    color: #475569;
    text-transform: uppercase;
}
.integration-run-json strong:first-of-type { margin-top: 0; }
.integration-run-json pre {
    max-width: 720px;
    max-height: 280px;
    overflow: auto;
    padding: .7rem;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 5px;
    font-size: .75rem;
    white-space: pre-wrap;
}

/* ---- Entry table (week view & admin sheet) ---- */
.entry-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.entry-table thead tr { background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.entry-table th {
    padding: .45rem .75rem;
    text-align: left;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    font-weight: 600;
}
.entry-table td { padding: .5rem .75rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.entry-table tbody tr:last-child td { border-bottom: none; }
.entry-table tbody tr:hover td { background: #fafafa; }
.col-customer { width: 140px; }
.col-project  { width: 120px; }
.col-desc     { width: auto; }
.col-hours    { width: 75px; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; }
.col-worked   { width: 75px; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; }
.col-bill     { width: 80px; text-align: center; }
.col-actions  { width: 120px; text-align: right; }
.col-user     { width: 110px; font-size: .82rem; color: #475569; }
.center       { text-align: center; }

/* ---- Form inputs ---- */
.input-customer {
    padding: .4rem .6rem;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: .875rem;
    color: #1e293b;
    background: #fff;
    min-width: 130px;
    max-width: 180px;
}
.input-desc {
    flex: 1;
    min-width: 180px;
    padding: .4rem .6rem;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: .875rem;
    color: #1e293b;
}
.input-hours {
    width: 88px;
    padding: .4rem .6rem;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: .875rem;
    color: #1e293b;
}
.input-customer:focus, .input-desc:focus, .input-hours:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 2px var(--focus-ring);
}
.bill-label { display: flex; align-items: center; gap: .3rem; font-size: .85rem; color: #475569; white-space: nowrap; cursor: pointer; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .35rem .7rem;
    border-radius: 5px;
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background .12s, border-color .12s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn-nav     { background: #fff; border-color: #cbd5e1; color: #374151; }
.btn-nav:hover { background: #f1f5f9; border-color: #94a3b8; }
.btn-disabled { background: #f1f5f9; border-color: #e2e8f0; color: #cbd5e1; cursor: default; display: inline-flex; align-items: center; justify-content: center; padding: .35rem .7rem; border-radius: 5px; font-size: .8rem; border: 1px solid; white-space: nowrap; line-height: 1.4; }
.btn-add     { background: transparent; border-color: #cbd5e1; color: var(--primary); font-size: .8rem; }
.btn-add:hover { background: var(--primary-tint-light); border-color: var(--primary-tint-mid); }
.btn-save    { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-save:hover { background: var(--secondary); border-color: var(--secondary); }
.btn-cancel  { background: #fff; color: #475569; border-color: #cbd5e1; }
.btn-cancel:hover { background: #f8fafc; }
.btn-edit    { background: #fff; color: #475569; border-color: #cbd5e1; font-size: .78rem; }
.btn-edit:hover { background: #f1f5f9; }
.btn-delete  { background: transparent; color: #dc2626; border-color: transparent; font-size: .78rem; padding: .35rem .4rem; }
.btn-delete:hover { background: #fef2f2; border-color: #fca5a5; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--secondary); border-color: var(--secondary); }
.btn-link    { background: transparent; color: var(--secondary); border-color: transparent; padding-left: 0; }
.btn-link:hover { text-decoration: underline; }
/* Full-width form submit — extend .btn in markup */
.btn-full    { width: 100%; padding: .6rem; background: var(--primary); color: #fff; border: none; border-radius: 6px; font-size: .95rem; font-weight: 600; }
.btn-full:hover { background: var(--secondary); }
.btn-complete { background: var(--primary); color: #fff; border-color: var(--primary); padding: .5rem 1rem; font-size: .875rem; }
.btn-complete:hover { background: var(--secondary); border-color: var(--secondary); }
/* Destructive — extend .btn in markup */
.btn-danger  { background: transparent; color: #dc2626; border: 1px solid #fca5a5; border-radius: 5px; padding: .35rem .75rem; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.btn-danger:hover { background: #fef2f2; border-color: #dc2626; }
.btn-purge-day { background: transparent; border: none; color: #fca5a5; font-size: .72rem; cursor: pointer; padding: .15rem .4rem; border-radius: 3px; transition: color .12s, background .12s; line-height: 1.4; }
.btn-purge-day:hover { color: #dc2626; background: #fef2f2; }
/* Export actions — extend .btn in markup */
.btn-download       { background: var(--primary); color: #fff; border: none; border-radius: 5px; padding: .5rem 1.1rem; font-size: .875rem; font-weight: 600; }
.btn-download:hover { background: var(--secondary); }
.btn-download-plain { background: #fff; color: #475569; border: 1px solid #cbd5e1; border-radius: 5px; padding: .5rem 1.1rem; font-size: .875rem; font-weight: 500; }
.btn-download-plain:hover { background: #f8fafc; }

/* Shared disabled state for real <button disabled> and .btn-disabled */
button:disabled,
.btn:disabled,
.btn-full:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ---- Badges & labels ---- */
.billable-badge { display: inline-block; background: #dcfce7; color: #15803d; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 10px; }
.customer-cell  { color: var(--secondary); font-size: .82rem; font-weight: 500; }
.customer-none  { color: #cbd5e1; font-size: .82rem; }
.internal-badge { display: inline-block; background: #f1f5f9; color: #64748b; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 10px; margin-left: .35rem; vertical-align: middle; }
.internal-label { display: inline-flex; align-items: center; gap: .3rem; font-size: .875rem; color: #475569; white-space: nowrap; cursor: pointer; }
.completed-chip { display: inline-flex; align-items: center; background: #dcfce7; color: #15803d; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 10px; }
.meta           { color: #64748b; font-size: .82rem; }
.billable-total { color: #15803d; font-weight: 500; }

/* ---- Day cards ---- */
.day-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: .75rem; overflow: hidden; }
.day-card.today { border-color: var(--primary-tint-mid); }
.day-card.today .day-header { background: var(--primary-tint-light); }
.day-header { display: flex; align-items: center; justify-content: space-between; padding: .6rem 1rem; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.day-header-right { display: flex; align-items: center; gap: .5rem; }
.day-name { font-weight: 600; font-size: .9rem; color: #334155; }
.day-card.today .day-name { color: var(--secondary); }
.day-total         { font-size: .8rem; font-weight: 600; color: #475569; background: #e2e8f0; padding: .15rem .5rem; border-radius: 12px; }
.day-total-ok      { background: #dcfce7; color: #15803d; font-size: .8rem; font-weight: 600; padding: .15rem .5rem; border-radius: 12px; }
.day-total-low     { background: #fee2e2; color: #b91c1c; font-size: .8rem; font-weight: 600; padding: .15rem .5rem; border-radius: 12px; }
.day-total-neutral { background: #e2e8f0; color: #475569;  font-size: .8rem; font-weight: 600; padding: .15rem .5rem; border-radius: 12px; }

/* ---- Week view ---- */
.week-nav   { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.week-label { flex: 1; text-align: center; font-size: 1rem; font-weight: 600; color: #334155; }
.edit-row td { padding: .6rem .75rem; background: #fffbeb; }
.edit-form-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.add-form { padding: .6rem .75rem; background: #f8fafc; border-top: 1px solid #e2e8f0; }
.add-form-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.add-entry-row { padding: .5rem .75rem; }
.week-locked-banner { background: #f0fdf4; border: 1px solid #86efac; color: #15803d; padding: .6rem 1rem; border-radius: 6px; margin-bottom: 1.25rem; font-size: .875rem; }
.complete-bar { margin-top: .75rem; display: flex; justify-content: flex-end; }
.week-summary { margin-top: 1rem; padding: .8rem 1rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; display: flex; gap: 1.5rem; font-size: .9rem; color: #334155; }
.week-summary strong { font-weight: 600; }

/* ---- Quick registration ---- */
.date-heading { font-size: 1.05rem; font-weight: 600; color: #334155; margin-bottom: 1rem; }
.quick-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 1.25rem 1rem; }
.quick-form-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.entries-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; margin-top: 1.25rem; overflow: hidden; }
.entries-header { display: flex; align-items: center; justify-content: space-between; padding: .6rem 1rem; background: #f8fafc; border-bottom: 1px solid #e2e8f0; font-size: .85rem; font-weight: 600; color: #334155; }
.week-link { display: inline-block; margin-top: 1rem; font-size: .85rem; color: var(--primary); text-decoration: none; }
.week-link:hover { text-decoration: underline; }

/* ---- Login / setup ---- */
.login-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 2.5rem 2rem; width: 100%; max-width: 380px; box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.login-card .logo { font-size: 1.4rem; letter-spacing: -.5px; margin-bottom: 1.8rem; display: block; text-align: center; color: var(--primary); }
.login-card label { display: block; font-size: .8rem; font-weight: 600; color: #475569; margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.login-card input[type=text],
.login-card input[type=password] { width: 100%; padding: .6rem .8rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .95rem; color: #1e293b; margin-bottom: 1.1rem; transition: border-color .15s; }
.login-card input:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px var(--focus-ring); }
/* Login submit — extend .btn in markup */
.btn-login { width: 100%; padding: .7rem; background: var(--primary); color: #fff; border: none; border-radius: 6px; font-size: .95rem; font-weight: 600; }
.btn-login:hover { background: var(--secondary); }

/* Microsoft SSO button */
.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    width: 100%;
    padding: .65rem;
    margin-top: .6rem;
    background: #fff;
    color: #1e293b;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}
.btn-microsoft:hover { background: #f8fafc; border-color: #9ca3af; }

/* ---- Admin: gate ---- */
.gate-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.gate-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 2.5rem 2rem; width: 100%; max-width: 360px; box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.gate-card h1 { font-size: 1.2rem; margin-bottom: 1.5rem; }
.gate-label { display: block; font-size: .78rem; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem; }
.gate-input { width: 100%; padding: .6rem .8rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .95rem; margin-bottom: 1rem; }
.gate-input:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 2px var(--focus-ring); }
.msg-error { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; padding: .6rem .8rem; border-radius: 6px; font-size: .875rem; margin-bottom: 1rem; }
.back { display: block; text-align: center; margin-top: 1rem; font-size: .85rem; color: var(--primary); text-decoration: none; }
.back:hover { text-decoration: underline; }

/* ---- Admin: tabs ---- */
.tabs { display: flex; border-bottom: 2px solid #e2e8f0; margin-bottom: 1.5rem; }
.tab { padding: .6rem 1.2rem; font-size: .9rem; font-weight: 500; color: #64748b; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .12s; }
.tab:hover { color: #1e293b; }
.tab.active { color: var(--secondary); border-bottom-color: var(--secondary); font-weight: 600; }

/* ---- Admin: inline add row ---- */
.add-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.add-row input[type=text] { flex: 1; min-width: 200px; padding: .5rem .7rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .9rem; }
.add-row input:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 2px var(--focus-ring); }

/* ---- Admin: user form ---- */
.user-form label { display: block; font-size: .78rem; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .3rem; }
.user-form input[type=text],
.user-form input[type=password],
.user-form input[type=email],
.user-form input[type=number],
.user-form select { width: 100%; padding: .55rem .75rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .9rem; margin-bottom: .9rem; background: #fff; color: #1e293b; }
.user-form input:focus,
.user-form select:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 2px var(--focus-ring); }

/* ---- Admin: breadcrumb ---- */
.breadcrumb { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: #64748b; margin-bottom: 1.25rem; }
.breadcrumb a { color: var(--secondary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: #cbd5e1; }
.sheet-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.sheet-summary { margin-top: 1rem; padding: .8rem 1rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; display: flex; gap: 1.5rem; font-size: .9rem; color: #334155; }
.sheet-summary strong { font-weight: 600; }

/* ---- Admin: reports ---- */
.sub-tabs { display: flex; gap: .35rem; margin-bottom: 1.25rem; }
.sub-tab { padding: .35rem .9rem; font-size: .85rem; font-weight: 500; color: #64748b; text-decoration: none; border: 1px solid #e2e8f0; border-radius: 5px; background: #fff; transition: background .12s, color .12s; }
.sub-tab:hover { background: #f8fafc; color: #334155; }
.sub-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.report-nav { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.report-nav-label { flex: 1; text-align: center; font-weight: 600; font-size: 1rem; color: #334155; }

/* ---- Admin: pivot table ---- */
.pivot-wrap { overflow-x: auto; margin-bottom: 1.25rem; }
.pivot-table { border-collapse: collapse; font-size: .8rem; white-space: nowrap; width: 100%; }
.pivot-table th { padding: .4rem .6rem; background: #f8fafc; border: 1px solid #e2e8f0; text-align: center; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; font-weight: 600; }
.pivot-table th.th-left { text-align: left; min-width: 170px; }
/* Sticky first column so customer names stay visible when scrolling horizontally */
.pivot-table th:first-child { position: sticky; left: 0; z-index: 3; background: #f8fafc; }
.pivot-table td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; }
.pivot-table tbody tr:hover td:first-child { background: #fafafa; }
.pivot-table td { padding: .35rem .6rem; border: 1px solid #f1f5f9; vertical-align: top; }
.pivot-table tbody tr:hover td { background: #fafafa; }
.pivot-table tfoot td { padding: .4rem .6rem; border: 1px solid #e2e8f0; background: #f8fafc; font-weight: 600; }
.pcell { text-align: right; min-width: 58px; }
.pcell-total  { display: block; font-variant-numeric: tabular-nums; }
.pcell-bill   { display: block; font-size: .7rem; color: #15803d; font-variant-numeric: tabular-nums; }
.pcell-empty  { color: #d1d5db; }

/* ---- xSP invoice matrix ---- */
.xsp-matrix-wrap { overflow: auto; }
.xsp-matrix-table { width: 100%; table-layout: fixed; }
.xsp-matrix-customer-col { width: 210px; }
.entry-table th.xsp-matrix-month-col,
.entry-table td.xsp-matrix-cell {
    width: 68px;
    text-align: center;
    padding-left: .2rem;
    padding-right: .2rem;
}
.xsp-matrix-ref {
    font-size: .7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.xsp-matrix-pill {
    border-radius: 999px;
    padding: .14rem .42rem;
    font-size: .74rem;
    font-weight: 700;
    cursor: pointer;
}
.xsp-matrix-pill-yes {
    border: 1px solid #86efac;
    background: #dcfce7;
    color: #166534;
}
.xsp-matrix-pill-ready {
    border: 1px solid #facc15;
    background: #fef9c3;
    color: #854d0e;
}
.xsp-matrix-pill-warn {
    border: 1px solid #c4b5fd;
    background: #ede9fe;
    color: #6d28d9;
}
.xsp-matrix-pill-na {
    border: 1px solid #93c5fd;
    background: #dbeafe;
    color: #1e40af;
}
.xsp-matrix-pill-no {
    border: 1px solid #fecaca;
    background: #fee2e2;
    color: #991b1b;
}
.pcell-strong { background: #f8fafc; }

/* ---- Admin: export ---- */
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem 1rem; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.filter-bar select { padding: .35rem .6rem; border: 1px solid #cbd5e1; border-radius: 5px; font-size: .85rem; color: #1e293b; background: #fff; }
.filter-bar label { font-size: .8rem; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.filter-group { display: flex; align-items: center; gap: .3rem; }
.exp-badge-yes { display: inline-block; background: #dcfce7; color: #15803d; font-size: .7rem; font-weight: 600; padding: .1rem .4rem; border-radius: 10px; white-space: nowrap; }
.exp-badge-no  { display: inline-block; background: #f1f5f9; color: #94a3b8; font-size: .7rem; font-weight: 600; padding: .1rem .4rem; border-radius: 10px; }
.download-bar  { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; background: #f8fafc; border-top: 1px solid #e2e8f0; flex-wrap: wrap; }

/* ---- Import ---- */
.format-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin: .75rem 0; }
.format-table th { text-align: left; padding: .4rem .6rem; background: #f8fafc; border: 1px solid #e2e8f0; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; }
.format-table td { padding: .4rem .6rem; border: 1px solid #f1f5f9; vertical-align: top; }
.format-table tbody tr:nth-child(even) td { background: #fafafa; }
code { font-family: ui-monospace, monospace; font-size: .82rem; background: #f1f5f9; padding: .1rem .3rem; border-radius: 3px; }
.example-row { font-family: ui-monospace, monospace; font-size: .82rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 5px; padding: .5rem .75rem; margin-top: .5rem; color: #334155; word-break: break-all; }
.import-ok td  { background: #f0fdf4 !important; }
.import-err td { background: #fef2f2 !important; }
.reason-cell   { color: #b91c1c; font-size: .8rem; }
.raw-cell      { font-family: ui-monospace, monospace; font-size: .75rem; color: #64748b; }
.for-user-banner { display: flex; align-items: center; gap: .6rem; background: var(--primary-tint-light); border: 1px solid var(--primary-tint-mid); border-radius: 6px; padding: .6rem 1rem; margin-bottom: 1.25rem; font-size: .875rem; }
.for-user-banner strong { color: var(--primary); }
.field-label   { display: block; font-size: .78rem; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem; }
.check-label   { display: flex; align-items: center; gap: .4rem; font-size: .875rem; color: #475569; margin-bottom: 1rem; cursor: pointer; }

/* ---- Admin tab burger (desktop: hidden) ---- */
.admin-tabs-burger { display: none; }

/* ---- Burger button (desktop: hidden) ---- */
.nav-burger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .3rem .4rem;
    flex-direction: column;
    gap: 5px;
    margin-left: auto;
    flex-shrink: 0;
}
.nav-burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(255,255,255,.9);
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
    pointer-events: none;
}
.nav-burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; }
.nav-burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Mobile styles ---- */
@media (max-width: 680px) {

    /* Burger visible, user-info hidden (logout is in the nav) */
    .nav-burger { display: flex; }
    .user-info   { display: none; }

    .app-sidebar {
        top: var(--app-header-offset);
        width: min(86vw, 320px);
        height: calc(100dvh - var(--app-header-offset));
        transform: translateX(-100%);
        transition: transform .18s ease;
        box-shadow: 12px 0 28px rgba(15,23,42,.16);
    }
    .app-sidebar.open { transform: translateX(0); }

    /* Main padding */
    main { margin-left: 0; padding: 1rem .75rem; }

    /* Scrollable cards for wide tables */
    .card     { overflow-x: auto; }
    .list-table,
    .entry-table { min-width: 480px; }
    .pivot-table  { min-width: 600px; }

    /* Week navigation */
    .week-nav { gap: .5rem; }
    .week-label { font-size: .875rem; }

    /* Stacked entry forms */
    .add-form-row,
    .edit-form-row,
    .quick-form-row {
        flex-direction: column;
        align-items: stretch;
    }
    .input-customer { max-width: 100%; width: 100%; min-width: 0; }
    .input-desc     { min-width: 0; }
    .input-hours    { width: 100%; }
    .bill-label     { justify-content: flex-start; }

    /* Day header: tighter */
    .day-name { font-size: .85rem; }
    .day-header { padding: .5rem .75rem; }

    /* Week summary wraps */
    .week-summary  { flex-wrap: wrap; gap: .6rem; }
    .sheet-summary { flex-wrap: wrap; gap: .6rem; }
    .complete-bar  { justify-content: flex-start; }

    /* Login card full-width */
    .login-card { margin: 1rem; max-width: 100%; }

    /* Report nav */
    .report-nav { flex-wrap: wrap; }
    .report-nav-label { min-width: 100%; text-align: center; order: -1; }

    /* Filter bar wraps */
    .filter-bar { flex-direction: column; align-items: flex-start; }
    .customer-list-header { align-items: stretch; flex-direction: column; }
    .customer-list-header-actions { width: 100%; }
    .customer-filter-input { flex: 1; width: auto; min-width: 0; }

    /* Download bar */
    .download-bar { flex-direction: column; align-items: stretch; }
    .btn-download,
    .btn-download-plain { width: 100%; }

    /* ---- Admin tab navigation ---- */
    .admin-tabs-burger {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: .7rem 1rem;
        background: #f8fafc;
        border: none;
        border-bottom: 1px solid #e2e8f0;
        cursor: pointer;
        font-size: .9rem;
        font-weight: 600;
        color: #334155;
    }
    #admin-tabs.open .admin-tabs-burger svg { transform: rotate(180deg); }
    .tabs {
        flex-direction: column;
        border-bottom: none;
        border-radius: 8px;
        border: 1px solid #e2e8f0;
        overflow: hidden;
        background: #fff;
        margin-bottom: 1.25rem;
    }
    .tab {
        display: none;
        border-bottom: 2px solid transparent;
        border-top: 1px solid #f1f5f9;
        padding: .7rem 1rem;
        margin-bottom: 0;
        border-radius: 0;
        font-size: .9rem;
    }
    #admin-tabs.open .tab { display: block; }
    .tab.active {
        background: var(--primary-tint-light);
        color: var(--secondary);
        border-left: 3px solid var(--secondary);
        border-bottom-color: transparent;
    }

    /* Admin header */
    .header-links a { font-size: .8rem; }

    /* 44px minimum tap targets — beneficial on all mobile, not just 430px */
    .btn, .app-nav-link { min-height: 44px; display: inline-flex; align-items: center; }
    input[type=text], input[type=password], input[type=email],
    input[type=file], select { min-height: 44px; }
    .btn-login, .btn-full { min-height: 48px; }
}

/* ---- Safe-area insets (notch / home bar) — requires viewport-fit=cover ---- */
header {
    /* Background extends under the notch; content stays in the normal header zone */
    padding-top: env(safe-area-inset-top, 0px);
}
main {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
}
@media (max-width: 680px) {
    .app-sidebar { padding-bottom: max(.85rem, env(safe-area-inset-bottom, 0px)); }
}

/* ---- Entry table → card rows (≤ 480px covers all iPhone Pro/Max portrait widths) ---- */
@media (max-width: 480px) {
    /* Remove horizontal scroll — entries become stacked cards */
    .day-card .entry-table,
    .entries-card .entry-table { min-width: 0; }
    .day-card .entry-table thead,
    .entries-card .entry-table thead { display: none; }
    .day-card .entry-table tbody tr,
    .entries-card .entry-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: .55rem .75rem;
        gap: 0 .4rem;
    }
    .day-card .entry-table td,
    .entries-card .entry-table td { border: none; padding: .1rem 0; width: auto; }
    /* Description: full-width first line */
    .day-card .entry-table .col-desc,
    .entries-card .entry-table .col-desc {
        flex: 0 0 100%; order: 0;
        font-size: .875rem; color: #1e293b;
        padding-bottom: .2rem;
    }
    /* Customer, project, hours, billable: compact meta row */
    .day-card .entry-table .col-customer,
    .day-card .entry-table .col-project,
    .day-card .entry-table .col-hours,
    .day-card .entry-table .col-worked,
    .day-card .entry-table .col-bill,
    .entries-card .entry-table .col-customer,
    .entries-card .entry-table .col-project,
    .entries-card .entry-table .col-hours,
    .entries-card .entry-table .col-worked,
    .entries-card .entry-table .col-bill {
        order: 1; font-size: .75rem; white-space: nowrap;
    }
    /* Edit: right edge of meta row */
    .day-card .entry-table .col-actions,
    .entries-card .entry-table .col-actions { order: 1; margin-left: auto; }
    /* Edit row spans full card */
    .day-card .entry-table .edit-row td,
    .entries-card .entry-table .edit-row td { flex: 0 0 100%; }
}

/* ---- iPhone / small-phone tweaks (≤ 430px) ---- */
@media (max-width: 430px) {

    /* 16px prevents iOS auto-zoom on input focus */
    input, select, textarea { font-size: 16px; }
    .input-customer, .input-desc, .input-hours { font-size: 16px; }

    /* Tighter chrome */
    main        { padding: .75rem .6rem; }
    .card-body  { padding: .75rem; }
    .card-header { padding: .6rem .75rem; font-size: clamp(.8rem, 3.5vw, .9rem); }

    /* Fluid logo + week label */
    .logo        { font-size: clamp(.95rem, 4vw, 1.1rem); }
    .week-label  { font-size: clamp(.8rem,  4vw, 1rem); }

    /* Sidebar drawer: cap height so it does not fill the screen awkwardly */
    .app-sidebar { max-height: calc(100dvh - var(--app-header-offset)); overflow-y: auto; }

    /* Day cards: tighter headers */
    .day-header  { padding: .45rem .6rem; }
    .day-name    { font-size: clamp(.8rem, 3.5vw, .9rem); }

    /* Week summary wraps tighter */
    .week-summary { gap: .5rem; padding: .6rem .75rem; }

    /* Login card: full bleed with comfortable margin */
    .login-card { margin: .75rem; padding: 1.75rem 1.25rem; }

    /* Quick-card: not sticky — with keyboard open on small phones the sticky bar
       eats too much vertical space. Keep it at natural top-of-page position. */
}

/* ---- Hover tooltip ---- */
.has-tooltip {
    position: relative;
    cursor: default;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}
.tooltip-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #f1f5f9;
    font-size: .78rem;
    font-weight: 400;
    line-height: 1.5;
    padding: .4rem .65rem;
    border-radius: 5px;
    white-space: nowrap;
    z-index: 300;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    text-align: left;
    text-decoration: none;
}
.tooltip-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--primary);
}
.has-tooltip:hover .tooltip-popup { display: block; }

/* ---- Copy button ---- */
.desc-cell { display: flex; align-items: center; gap: .4rem; }
.btn-copy  { flex-shrink: 0; background: none; border: none; cursor: pointer; padding: .1rem; color: #94a3b8; line-height: 0; border-radius: 3px; transition: color .12s; }
.btn-copy:hover  { color: var(--primary); }
.btn-copy.copied { color: #16a34a; }
