/* ─────────────────────────────────────────────────────────────────────────────
   WorkTracker — Stylesheet
───────────────────────────────────────────────────────────────────────────── */

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

:root {
    --brand:       #1e40af;
    --brand-dark:  #1e3a8a;
    --brand-light: #dbeafe;
    --accent:      #2563eb;
    --success:     #16a34a;
    --danger:      #dc2626;
    --warning:     #d97706;
    --gray-50:     #f9fafb;
    --gray-100:    #f3f4f6;
    --gray-200:    #e5e7eb;
    --gray-400:    #9ca3af;
    --gray-600:    #4b5563;
    --gray-800:    #1f2937;
    --text:        #111827;
    --radius:      6px;
    --shadow:      0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html { overflow-y: scroll; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: #e8eaed;
    line-height: 1.5;
}

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

/* ── Top Nav ─────────────────────────────────────────────────────────────── */
.navbar {
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 56px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.3px;
    text-decoration: none;
    margin-right: 2rem;
}
.navbar-brand:hover { text-decoration: none; }
.navbar-nav {
    display: flex;
    gap: .25rem;
    list-style: none;
    flex: 1;
}
.navbar-nav a {
    color: rgba(255,255,255,.85);
    padding: .4rem .8rem;
    border-radius: var(--radius);
    font-size: .88rem;
    font-weight: 500;
    transition: background .15s;
    text-decoration: none;
}
.navbar-nav a:hover,
.navbar-nav a.active { background: rgba(255,255,255,.18); color: #fff; }
/* "More" dropdown (Expenses, Recurring): button styled like the links, white menu like the account menu */
.nav-more { position: relative; }
.nav-more-btn { display: inline-flex; align-items: center; gap: .35rem; background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.85); padding: .3rem .8rem; margin: -.3rem 0; border-radius: var(--radius); font-family: inherit; font-size: .88rem; font-weight: 500; line-height: inherit; transition: background .15s; }
.nav-more-btn:hover, .nav-more-btn.active, .nav-more.open .nav-more-btn { background: rgba(255,255,255,.18); color: #fff; }
.nav-more-btn svg { transition: transform .15s; }
.nav-more.open .nav-more-btn svg { transform: rotate(180deg); }
.nav-more-menu { display: none; position: absolute; top: calc(100% + 8px); left: 0; min-width: 170px; list-style: none; margin: 0;
    padding: .3rem 0; background: #fff; border: 1px solid var(--gray-200); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 200; }
.nav-more.open .nav-more-menu { display: block; }
.navbar-nav .nav-more-menu a { display: block; color: var(--text); border-radius: 0; padding: .55rem .9rem; }
.navbar-nav .nav-more-menu a:hover { background: var(--gray-100); color: var(--accent); }
.navbar-nav .nav-more-menu a.active { background: var(--gray-100); color: var(--accent); font-weight: 600; }
.navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: .88rem;
    color: rgba(255,255,255,.75);
}
.navbar-right a { color: rgba(255,255,255,.85); }
.navbar-right a:hover { color: #fff; text-decoration: none; }

/* ── Collapsible top nav (tablet and phone) ──────────────────────────────── */
.nav-toggle { display: none; background: none; border: none; color: #fff; cursor: pointer; padding: .35rem;
              margin-right: .5rem; border-radius: var(--radius); line-height: 0; }
.nav-toggle:hover { background: rgba(255,255,255,.15); }
@media (max-width: 1080px) {
    .navbar { padding: 0 .75rem; }
    .nav-toggle { display: inline-flex; }
    .navbar-brand { margin-right: .75rem; white-space: nowrap; }
    .navbar-nav { display: none; position: absolute; top: 56px; left: 0; right: 0; flex-direction: column; gap: 0;
                  background: var(--brand); padding: .4rem .75rem .75rem; box-shadow: var(--shadow-md); }
    .navbar.nav-open .navbar-nav { display: flex; }
    .navbar-nav a { display: block; padding: .7rem .8rem; font-size: .95rem; }
    /* In the ☰ menu the "More" links are listed with the others: no button, no dropdown */
    .nav-more-btn { display: none; }
    .nav-more-menu, .nav-more.open .nav-more-menu { display: block; position: static; min-width: 0; padding: 0;
        background: none; border: 0; box-shadow: none; }
    .navbar-nav .nav-more-menu a { color: rgba(255,255,255,.85); border-radius: var(--radius); padding: .7rem .8rem; }
    .navbar-nav .nav-more-menu a:hover,
    .navbar-nav .nav-more-menu a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 500; }
    .navbar-right { gap: .6rem; }
}
@media (max-width: 680px) {
    .nav-username { display: none; }           /* account menu: gear icon only */
    .navbar-brand { font-size: 1.05rem; }
}

/* Two-column page layouts (invoice, customer, dashboard) stack on tablets and phones */
@media (max-width: 900px) {
    .layout-split { grid-template-columns: 1fr !important; }
    .layout-split > * { min-width: 0; }
}

/* Cell wrapper added for the phone card layout; invisible to layout on larger screens */
.stack-val { display: contents; }

/* ── Page wrapper ────────────────────────────────────────────────────────── */
.page { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.page-title { font-size: 1.35rem; font-weight: 700; color: var(--gray-800); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    gap: .35rem;
    padding: .45rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--gray-800); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-100); text-decoration: none; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #b45309; text-decoration: none; color: #fff; }
.btn-sm        { padding: .3rem .7rem; font-size: .8rem; }
.btn:disabled  { opacity: .55; cursor: not-allowed; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: .9rem;
    border: 1px solid transparent;
}
.alert-success { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.alert-error   { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.alert-info    { background: var(--brand-light); color: var(--brand-dark); border-color: #bfdbfe; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.notif-dropdown {
    background: #fff;
    color: var(--text);
}
.notif-dropdown a { color: var(--text) !important; }
.notif-dropdown a:hover { color: var(--accent) !important; }
.card-header {
    padding: .75rem 1.1rem;
    background: #fff;
    border-bottom: 2px solid var(--gray-200);
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}
.card-header h3 { font-size: .95rem; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 1.1rem; }
.date-label { font-size: 1rem; font-weight: 600; color: var(--brand); }
.date-totals { font-size: .82rem; color: var(--gray-600); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
.table-fixed { table-layout: fixed; }

/* Capped scrolling list (~5 rows) with a header that stays put while scrolling.
   Used by the Unpaid Invoices and Unbilled Entries cards. */
.scroll-list { max-height: 250px; overflow-y: auto; border-bottom: 1px solid var(--gray-100); margin-bottom: .9rem; }
.scroll-list thead th { position: sticky; top: 0; z-index: 1; }

/* Summary total row shown beneath a scroll-list, kept visually consistent
   across cards. Anchors to the bottom of a flex-column card. */
.card-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .4rem;
    font-weight: 700;
    background: var(--brand-light);
    color: var(--brand-dark);
    padding: .7rem .85rem;
    margin-top: auto;
}

th, td {
    padding: .6rem .85rem;
    text-align: left;
    font-size: .875rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
}
th { font-weight: 600; color: var(--gray-600); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: #fff; border-bottom: 2px solid var(--gray-200); }
tr:last-child td { border-bottom: none; }
td { transition: background 220ms ease, box-shadow 220ms ease; }
tr:hover td { background: #f1f3f5; box-shadow: inset 0 1px 0 #e2e5e9, inset 0 -1px 0 #e2e5e9; }
tr:hover td:first-child { box-shadow: inset 0 1px 0 #e2e5e9, inset 0 -1px 0 #e2e5e9, inset 2px 0 0 #e2e5e9; }
tr:hover td:last-child  { box-shadow: inset 0 1px 0 #e2e5e9, inset 0 -1px 0 #e2e5e9, inset -2px 0 0 #e2e5e9; }

/* ── Scrollbars (light theme) ────────────────────────────────────────────── */
:root {
    scrollbar-color: #b0b4ba #e8eaed;
    scrollbar-width: thin;
}
::-webkit-scrollbar       { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #e8eaed; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #b0b4ba; border-radius: 4px; border: 2px solid #e8eaed; }
.td-right { text-align: right; }
.td-center { text-align: center; }
.td-actions { white-space: nowrap; }
.td-desc { max-width: 320px; }
.text-muted { color: var(--gray-400); }
.text-success { color: var(--success); font-weight: 600; }
.no-hover tr:hover td { background: inherit !important; box-shadow: none !important; }
.total-row td { font-weight: 600; background: var(--brand-light) !important; color: var(--brand-dark); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.75rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .span2 { grid-column: span 2; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
label { font-size: .82rem; font-weight: 600; color: var(--gray-600); }
input[type=text], input[type=email], input[type=password], input[type=time],
input[type=date], input[type=number], select, textarea {
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    padding: .5rem .75rem;
    font-size: .9rem;
    color: var(--text);
    background: #fff;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 80px; }

/* ── File input ───────────────────────────────────────────────────────────── */
input[type=file] {
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    padding: .35rem .5rem;
    font-size: .85rem;
    color: var(--text);
    background: #fff;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
}
input[type=file]::file-selector-button {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: calc(var(--radius) - 1px);
    color: var(--gray-800);
    padding: .25rem .65rem;
    font-size: .82rem;
    font-family: inherit;
    cursor: pointer;
    margin-right: .5rem;
    transition: background .15s;
}
input[type=file]::file-selector-button:hover { background: var(--gray-200); }
/* Firefox legacy */
input[type=file]::-moz-file-upload-button {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: calc(var(--radius) - 1px);
    color: var(--gray-800);
    padding: .25rem .65rem;
    font-size: .82rem;
    font-family: inherit;
    cursor: pointer;
    margin-right: .5rem;
}

/* ── Number input spinner ─────────────────────────────────────────────────── */
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* ── Password strength meter ─────────────────────────────────────────────── */
.pw-meter {
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    /* Full gradient painted on the track; cover hides the unfilled part */
    background:
        linear-gradient(90deg, #dc2626 0%, #f59e0b 20%, #facc15 40%, #4ade80 65%, #16a34a 100%) #fff;
    width: 100%;
    height: 38px;          /* matches input height */
    overflow: hidden;
    position: relative;
}
.pw-meter-cover {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 100%;           /* JS shrinks this as strength grows */
    background: #fff;
    transition: width 250ms ease;
}
[data-theme="dark"] .pw-meter { border-color: #4b5563; }
[data-theme="dark"] .pw-meter-cover { background: #374151; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.25rem; align-items: center; }
.form-hint { font-size: .78rem; color: var(--gray-400); margin-top: .2rem; }
.checkbox-row { display: flex; align-items: center; gap: .5rem; }
.checkbox-row input { width: auto; }
.checkbox-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1px solid var(--gray-300, #cbd5e1);
    border-radius: 4px;
    background: var(--input-bg, #fff);
    cursor: pointer;
    position: relative;
    flex: 0 0 auto;
    transition: border-color 150ms ease, background 150ms ease;
}
.checkbox-row input[type="checkbox"]:hover { border-color: var(--accent); }
.checkbox-row input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.checkbox-row input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}
/* Checkmark drawn with a rotated border, so it renders identically across browsers */
.checkbox-row input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    padding: 1.5rem;
}
.auth-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    padding: 2.25rem 2rem;
    width: 100%;
    max-width: 400px;
}
.auth-logo { font-size: 1.4rem; font-weight: 800; color: var(--brand); text-align: center; margin-bottom: 1.5rem; letter-spacing: -.4px; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .85rem; color: var(--gray-600); }
.auth-agree { margin: .75rem 0 0; font-size: .75rem; line-height: 1.45; color: var(--gray-600); text-align: center; }

/* ── Account menu items (buttons styled like the menu links) ──────────────── */
.acct-menu-item { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .6rem .75rem; background: none;
    border: none; border-bottom: 1px solid var(--gray-100); cursor: pointer; text-align: left; color: inherit;
    font-size: .85rem; line-height: 1; font-family: inherit; }
.acct-menu-item:hover { color: var(--accent); }
.acct-menu-icon { display: inline-flex; flex-shrink: 0; }
a.acct-menu-item { text-decoration: none; }
.acct-menu-form { margin: 0; }

/* ── Legal footer (copyright + Terms / Privacy) ──────────────────────────── */
.site-legal { text-align: center; font-size: .72rem; line-height: 1.6; color: var(--gray-400); padding: 1.25rem 1rem 1.5rem; }
.site-legal a { color: inherit; text-decoration: none; }
.site-legal a:hover { text-decoration: underline; }
.site-legal-sep { margin: 0 .45rem; }
.site-legal-copy, .site-legal-links { white-space: nowrap; }
.site-legal-onbrand { color: rgba(255,255,255,.8); padding-bottom: 0; }

/* ── Terms / Privacy pages ───────────────────────────────────────────────── */
.legal-body { background: var(--gray-50); }
.legal-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; max-width: 820px; margin: 0 auto; padding: 1.1rem 1rem; }
.legal-brand { font-weight: 800; font-size: 1.1rem; color: var(--brand); text-decoration: none; letter-spacing: -.3px; }
.legal-back { font-size: .85rem; color: var(--brand); text-decoration: none; }
.legal-back:hover { text-decoration: underline; }
.legal-doc { max-width: 820px; margin: 0 auto; background: #fff; border: 1px solid var(--gray-200); border-radius: 10px; padding: 2rem 2.25rem; color: var(--gray-800); font-size: .92rem; line-height: 1.65; }
.legal-doc h1 { font-size: 1.6rem; margin: 0 0 .2rem; letter-spacing: -.4px; }
.legal-doc h2 { font-size: 1.05rem; margin: 1.75rem 0 .5rem; }
.legal-doc h3 { font-size: .92rem; margin: 1.1rem 0 .35rem; }
.legal-doc p { margin: 0 0 .8rem; }
.legal-doc ul { margin: 0 0 .9rem; padding-left: 1.25rem; }
.legal-doc li { margin-bottom: .4rem; }
.legal-doc a { color: var(--brand); }
.legal-meta { color: var(--gray-600); font-size: .85rem; margin-bottom: 1.4rem !important; }
@media (max-width: 680px) {
    .legal-doc { border-radius: 0; border-left: 0; border-right: 0; padding: 1.4rem 1rem; }
}
@media (max-width: 680px) {
    .site-legal-copy { display: block; }
    .site-legal-links > .site-legal-sep:first-child { display: none; }
}

/* ── Summary bar ─────────────────────────────────────────────────────────── */
.summary-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.summary-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .9rem 1.25rem;
    flex: 1;
    min-width: 150px;
}
.summary-card .sc-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-400); font-weight: 600; }
.summary-card .sc-value { font-size: 1.45rem; font-weight: 700; color: var(--brand); margin-top: .2rem; }
.summary-card .sc-sub   { font-size: .78rem; color: var(--gray-400); margin-top: .1rem; }

/* ── Filters ─────────────────────────────────────────────────────────────── */
.filter-bar {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    display: flex;
    align-items: flex-end;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.filter-bar .form-group { flex: 1; min-width: 140px; max-width: 220px; }
.filter-bar label { font-size: .78rem; }

/* ── Badge ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
}
.badge-blue    { background: var(--brand-light); color: var(--brand); }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }
.badge-green   { background: #dcfce7; color: #15803d; }
.badge-yellow  { background: #fef3c7; color: #92400e; }
/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span2 { grid-column: span 1; }
    .summary-bar { gap: .6rem; }
    .page { padding: 1rem .75rem 2rem; }

    /* Entry form: drop the invisible column stand-ins and let rows wrap */
    .standin { display: none !important; }
    #billing-row > div, #expense-category-wrap > div, #rounding-row > div { flex-wrap: wrap; }
    #billing-row > div > .form-group:first-child { flex: 1 1 100% !important; }
    /* Time slot: start + Now on one line, end + Now + × on the next */
    .slot-row { display: grid !important; grid-template-columns: 1fr auto auto; gap: .4rem; }
    .slot-row > span { display: none; }
    .slot-row .slot-start, .slot-row .slot-end { min-width: 0; width: 100%; }
    .slot-row .slot-end { grid-column: 1; }

    /* Invoice page: tighter document, header stacks, line items scroll if still too wide */
    .invoice-doc { padding: 1rem !important; }
    .invoice-doc .inv-head td { display: block; width: 100% !important; text-align: left !important; padding: 0 0 .75rem !important; }
    .invoice-doc .inv-items th, .invoice-doc .inv-items td { padding: .45rem .4rem !important; font-size: .8rem !important; }

    /* List tables (.stack-table): each row becomes a labelled card */
    .stack-table, .stack-table tbody, .stack-table tfoot, .stack-table tr, .stack-table td { display: block; width: 100% !important; }
    .stack-table thead { display: none; }
    .stack-table tr { padding: .6rem .9rem; border-bottom: 1px solid var(--gray-100); }
    /* A band of page colour between rows so each record reads as its own card. Group headers
       (full-width rows, e.g. dates) get the band above them; the first record under a header
       stays attached to it. */
    .stack-table tbody > tr + tr { border-top: 10px solid #e8eaed; }
    [data-theme="dark"] .stack-table tbody > tr + tr { border-top-color: #111827; }
    .stack-table tbody > tr:has(> td.stack-full) + tr { border-top: 0; }
    .stack-table td { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: .6rem; align-items: start;
                      border: none !important; padding: .2rem 0 !important; text-align: left !important; max-width: none !important; }
    .stack-table td::before { content: attr(data-label); font-size: .7rem; font-weight: 600; text-transform: uppercase;
                              letter-spacing: .04em; color: var(--gray-400); padding-top: .2rem; }
    .stack-table td:not([data-label]) { grid-template-columns: minmax(0, 1fr); }
    .stack-table td:not([data-label])::before { content: none; }
    .stack-table td.stack-empty { display: none; }
    .stack-table tr:has(> td.stack-full) { padding: 0; }
    .stack-table td.stack-full { display: block; }
    .stack-table .stack-val { display: block; min-width: 0; }
    .stack-table td.td-actions { white-space: normal; }
    .stack-table td.td-actions::before { display: none; }          /* buttons need no label */
    .stack-table td.td-actions, .stack-table td.td-actions[data-label] { grid-template-columns: minmax(0, 1fr); padding-top: .45rem !important; }
    .stack-table td.td-actions .stack-val, .stack-table td.td-actions .stack-val > div {
        display: flex !important; flex-wrap: wrap; gap: .4rem; justify-content: flex-start !important; }
    .stack-table tr:hover td { background: none; box-shadow: none !important; }
}

/* ── Dark mode overrides ─────────────────────────────────────────────────── */
[data-theme="dark"] {
    --brand:       #3b82f6;
    --brand-dark:  #2563eb;
    --brand-light: #1e3a5f;
    --accent:      #60a5fa;
    --success:     #4ade80;
    --danger:      #f87171;
    --warning:     #fbbf24;
    --gray-50:     #1f2937;
    --gray-100:    #374151;
    --gray-200:    #4b5563;
    --gray-400:    #9ca3af;
    --gray-600:    #d1d5db;
    --gray-800:    #f3f4f6;
    --text:        #f9fafb;
    --radius:      6px;
    --shadow:      0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
    --shadow-md:   0 4px 6px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
}

[data-theme="dark"] body {
    background: #111827;
    color: var(--text);
    scrollbar-color: #4b5563 #1f2937;
    scrollbar-width: thin;
}
[data-theme="dark"] ::-webkit-scrollbar-track { background: #1f2937; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #4b5563; border-color: #1f2937; }

[data-theme="dark"] .btn-primary              { background: #1e40af; border-color: #1e40af; }
[data-theme="dark"] .btn-primary:hover        { background: #3b82f6; border-color: #3b82f6; }
[data-theme="dark"] .btn-danger               { background: #b91c1c; border-color: #b91c1c; }
[data-theme="dark"] .btn-danger:hover         { background: #f87171; border-color: #f87171; }
[data-theme="dark"] .btn-warning              { background: #b45309; border-color: #b45309; }
[data-theme="dark"] .btn-warning:hover        { background: #fbbf24; border-color: #fbbf24; }


[data-theme="dark"] .navbar {
    background: #1a2035;
}
@media (max-width: 1080px) { [data-theme="dark"] .navbar-nav { background: #1a2035; } }
[data-theme="dark"] .navbar-brand,
[data-theme="dark"] .navbar-nav a,
[data-theme="dark"] .navbar-right a,
[data-theme="dark"] .navbar-right span {
    color: rgba(255,255,255,.85);
}
[data-theme="dark"] .nav-more-btn { color: rgba(255,255,255,.85); }
[data-theme="dark"] .nav-more-menu { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .navbar-nav .nav-more-menu a { color: #e5e7eb; }
[data-theme="dark"] .navbar-nav .nav-more-menu a:hover,
[data-theme="dark"] .navbar-nav .nav-more-menu a.active { background: #374151; color: #fff; }
@media (max-width: 1080px) {
    [data-theme="dark"] .navbar-nav .nav-more-menu { background: none; }
    [data-theme="dark"] .navbar-nav .nav-more-menu a { color: rgba(255,255,255,.85); }
}
[data-theme="dark"] .navbar-nav a:hover,
[data-theme="dark"] .navbar-nav .active > a {
    background: rgba(255,255,255,.15);
    color: #fff;
}

[data-theme="dark"] .card {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .notif-dropdown {
    background: #1f2937;
    border-color: #374151;
    color: var(--text);
}

[data-theme="dark"] .form-card {
    background: #1f2937;
    border-color: #374151;
    color: var(--text);
}
[data-theme="dark"] .logo-remove-x { border-color: #1f2937; }

[data-theme="dark"] .card-header {
    background: #1f2937;
    border-color: #4b5563;
    border-bottom-width: 2px;
}

[data-theme="dark"] .btn-secondary {
    background: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #4b5563;
}

[data-theme="dark"] .date-group-row {
    background: #1a2035 !important;
    border-color: #374151 !important;
    color: #9ca3af !important;
}

[data-theme="dark"] table th {
    background: #1f2937;
    color: #9ca3af;
    border-color: #374151;
}

[data-theme="dark"] table td {
    border-color: #374151;
    color: #e5e7eb;
}

[data-theme="dark"] table tbody tr:hover td,
[data-theme="dark"] table tfoot tr:hover td {
    background: #263044 !important;
    box-shadow: inset 0 1px 0 #4b5563, inset 0 -1px 0 #4b5563 !important;
}
[data-theme="dark"] table tbody tr:hover td:first-child,
[data-theme="dark"] table tfoot tr:hover td:first-child {
    box-shadow: inset 0 1px 0 #4b5563, inset 0 -1px 0 #4b5563, inset 2px 0 0 #4b5563 !important;
}
[data-theme="dark"] table tbody tr:hover td:last-child,
[data-theme="dark"] table tfoot tr:hover td:last-child {
    box-shadow: inset 0 1px 0 #4b5563, inset 0 -1px 0 #4b5563, inset -2px 0 0 #4b5563 !important;
}

[data-theme="dark"] .alert-success { background: #052e16; color: #4ade80; border-color: #166534; }
[data-theme="dark"] .alert-error   { background: #450a0a; color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] .alert-info    { background: #1e3a5f; color: #93c5fd; border-color: #1d4ed8; }

[data-theme="dark"] .checkbox-row input[type="checkbox"] {
    background: #374151;
    border-color: #4b5563;
}
[data-theme="dark"] .checkbox-row input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

[data-theme="dark"] input[type=file] {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}
[data-theme="dark"] input[type=file]::file-selector-button {
    background: #4b5563;
    border-color: #6b7280;
    color: #f3f4f6;
}
[data-theme="dark"] input[type=file]::file-selector-button:hover { background: #6b7280; }
[data-theme="dark"] input[type=file]::-moz-file-upload-button {
    background: #4b5563;
    border-color: #6b7280;
    color: #f3f4f6;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #6b7280;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: var(--accent);
    background: #374151;
}

[data-theme="dark"] .badge-gray   { background: #374151; color: #d1d5db; }
[data-theme="dark"] .badge-green  { background: #052e16; color: #4ade80; }
[data-theme="dark"] .badge-blue   { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-yellow { background: #451a03; color: #fbbf24; }

[data-theme="dark"] .form-hint { color: #9ca3af; }

[data-theme="dark"] .summary-bar .summary-card {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .filter-bar {
    background: #1f2937;
    border-color: #374151;
}

/* Theme toggle button in navbar */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,.82);
    display: flex;
    align-items: center;
    padding: .25rem;
    border-radius: var(--radius);
    transition: color .15s, background .15s;
    line-height: 1;
}
.theme-toggle:hover { color: #fff; background: rgba(255,255,255,.15); }

/* ── Custom tooltip (replaces native title= tooltips for dark-mode compat) ── */
.has-tooltip {
    position: relative;
    cursor: default;
}
.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: var(--gray-800);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-md);
    font-size: .72rem;
    font-weight: 500;
    white-space: nowrap;
    padding: .25rem .55rem;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 150ms ease;
    z-index: 200;
}
.has-tooltip:hover::after { opacity: 1; }
[data-theme="dark"] .has-tooltip::after {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #334155;
}

/* Right-edge variant: anchors the tooltip to the right so it grows leftward
   into the table instead of overflowing past the right border (which would
   otherwise widen the scroll container and create a phantom horizontal scrollbar). */
.has-tooltip-end::after {
    left: auto;
    right: 0;
    transform: none;
}

/* Column-header explainer tooltip (e.g. the Type column legend) */
.col-tip {
    opacity: 0;
    transition: opacity .15s;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    background: #fff;
    color: var(--gray-800);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-md);
    font-size: .72rem;
    font-weight: 400;
    border-radius: 4px;
    padding: .4rem .65rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 99;
    line-height: 1.7;
    text-transform: none;
    letter-spacing: 0;
}
.col-tip b { font-weight: 700; }
[data-theme="dark"] .col-tip {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #334155;
}

/* ── Customer typeahead search (ported from BookKeeper) ─────────────────────── */
.cust-search-wrap { position: relative; display: flex; align-items: stretch; gap: 0; }
.cust-search-input { flex: 1; border-radius: var(--radius) 0 0 var(--radius) !important; }
.cust-browse-btn {
    flex-shrink: 0;
    padding: 0 .65rem;
    background: var(--gray-50);
    border: 1px solid #d1d5db;
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    color: var(--gray-600);
    font-size: 1rem;
    line-height: 1;
    transition: background .15s, color .15s;
}
.cust-browse-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.cust-browse-btn:focus { outline: none; border-color: var(--accent); }

.cust-suggest-dropdown, .cust-browse-panel {
    display: none;
    position: absolute; top: calc(100% + 2px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    z-index: 500; max-height: 260px; overflow-y: auto;
}
.cust-suggest-dropdown.open, .cust-browse-panel.open { display: block; }
.cust-suggest-item, .cust-browse-item {
    display: flex; flex-direction: column; gap: .1rem;
    padding: .5rem .75rem; font-size: .875rem;
    color: var(--text); cursor: pointer; border-bottom: 1px solid var(--gray-100);
}
.cust-suggest-item:last-child, .cust-browse-item:last-child { border-bottom: none; }
.cust-suggest-item:hover, .cust-suggest-item.active,
.cust-browse-item:hover { background: var(--brand-light); }
.cust-suggest-item-email, .cust-browse-item-email {
    font-size: .78rem; color: var(--gray-400);
}
.cust-suggest-empty {
    padding: .75rem 1rem; font-size: .85rem; color: var(--gray-400);
}

[data-theme="dark"] .cust-browse-btn {
    background: var(--gray-100); border-color: var(--gray-200); color: var(--gray-400);
}
[data-theme="dark"] .cust-browse-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
[data-theme="dark"] .cust-suggest-dropdown, [data-theme="dark"] .cust-browse-panel {
    background: #1f2937; border-color: #374151; box-shadow: 0 4px 12px rgba(0,0,0,.5);
}
[data-theme="dark"] .cust-suggest-item, [data-theme="dark"] .cust-browse-item {
    color: #e5e7eb; border-color: #374151;
}
[data-theme="dark"] .cust-suggest-item:hover, [data-theme="dark"] .cust-suggest-item.active,
[data-theme="dark"] .cust-browse-item:hover { background: #263044; }

/* Search-match highlight (Customers and Queue search results) */
mark.search-hit { background: #fde68a; color: #1f2937; padding: 0 .1em; border-radius: 2px; }
[data-theme="dark"] mark.search-hit { background: #a16207; color: #fff; }

/* Billing — plan cards (Billing page and plan-ended page) */
.plan-grid { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.plan-card { flex: 1 1 220px; border: 1px solid var(--gray-200); border-radius: 8px; padding: .9rem; display: flex; flex-direction: column; }
.plan-card-current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-card-name { font-weight: 700; }
.plan-card-price { font-size: 1.3rem; font-weight: 700; margin: .2rem 0 0; }
.plan-card-price span { font-size: .8rem; font-weight: 400; color: var(--gray-600); }
.plan-card-alt { font-size: .82rem; color: var(--gray-600); margin-bottom: .35rem; }
.plan-card-list { margin: .3rem 0 .8rem; padding-left: 1.1rem; font-size: .82rem; color: var(--gray-600); line-height: 1.6; flex: 1; }
.plan-card-form { margin: 0 0 .45rem; }
.plan-card-form:last-child { margin-bottom: 0; }
.plan-card-form .btn { width: 100%; justify-content: center; }
.plan-note { font-size: .78rem; color: var(--gray-600); line-height: 1.5; margin: .5rem 0 0; }
/* Stripe's "Powered by Stripe" badge (billing_ui.php stripeBadge): blurple on light, white in dark mode */
.stripe-badge { display: inline-block; margin-top: .75rem; line-height: 0; }
.stripe-badge img { display: block; width: 120px; height: auto; }
.stripe-badge .sb-dark { display: none; }
[data-theme="dark"] .stripe-badge .sb-light { display: none; }
[data-theme="dark"] .stripe-badge .sb-dark { display: block !important; }   /* inline display:none keeps it hidden if an old cached style.css is in use */
.billing-status p { margin: 0 0 .55rem; font-size: .92rem; line-height: 1.55; }
.billing-status p.plan-note { font-size: .78rem; margin-top: .5rem; }
.billing-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 .2rem; }
.billing-actions form { margin: 0; }
.billing-help { margin: -.6rem 0 1.5rem; }   /* Support / Manage Account / Cancel Subscription row under the plan card */
/* Outlined button with red text: an action to take care with (Cancel Subscription) */
.btn-danger-outline { background: #fff; color: var(--danger); border-color: var(--gray-200); }
.btn-danger-outline:hover { background: var(--danger); color: #fff; border-color: var(--danger); text-decoration: none; }
[data-theme="dark"] .btn-danger-outline { background: transparent; color: #f87171; border-color: #4b5563; }
[data-theme="dark"] .btn-danger-outline:hover { background: #b91c1c; color: #fff; border-color: #b91c1c; }
@media (max-width: 680px) {
    .billing-actions form, .billing-actions .btn { width: 100%; justify-content: center; }
}

/* Sign-up page: Google's reCAPTCHA checkbox is a fixed 304px wide, so on phones the card
   uses less padding (and the widget is scaled down on the narrowest screens) to fit it. */
@media (max-width: 420px) {
    .auth-wrap-signup { padding: 1rem .75rem; }
    .auth-wrap-signup .auth-card { padding: 1.75rem 1rem; }
}
@media (max-width: 359px) {
    .auth-wrap-signup .g-recaptcha { transform: scale(.85); transform-origin: 0 0; height: 66px; }
}

/* ── Getting-started guide (includes/tutorial.php) ─────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
/* Guide switch in the top bar */
.guide-toggle-form { margin: 0; display: inline-flex; }
.guide-toggle { display: inline-flex; align-items: center; gap: .45rem; background: none; border: 0; cursor: pointer;
    color: rgba(255,255,255,.85); font: inherit; font-size: .82rem; font-weight: 500; padding: .3rem .4rem; border-radius: var(--radius); }
.guide-toggle:hover { color: #fff; background: rgba(255,255,255,.12); }
.guide-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.guide-switch { position: relative; width: 30px; height: 17px; border-radius: 999px; background: rgba(255,255,255,.3); transition: background .15s; flex-shrink: 0; }
.guide-knob { position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.guide-toggle.on .guide-switch { background: #22c55e; }
.guide-toggle.on .guide-knob { transform: translateX(13px); }
@media (max-width: 380px) { .guide-label { display: none; } }   /* smallest phones: switch only (it has aria-label and a tooltip) */

/* Checklist panel, fixed in the bottom-right corner */
.guide-panel { position: fixed; right: 16px; bottom: 16px; z-index: 150; width: 290px; max-width: calc(100vw - 32px);
    background: #fff; border: 1px solid var(--gray-200); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: .86rem; }
.gs-head { display: flex; align-items: center; gap: .5rem; width: 100%; background: none; border: 0; cursor: pointer; font: inherit;
    padding: .7rem .9rem; color: var(--text); text-align: left; }
.gs-title { font-weight: 700; flex: 1; }
.gs-count { font-size: .76rem; color: var(--gray-600); }
.gs-chev { transition: transform .15s; color: var(--gray-600); }
.guide-panel:not(.collapsed) .gs-chev { transform: rotate(180deg); }   /* ^ opens upward, v closes */
.guide-panel.collapsed .gs-body { display: none; }
.gs-body { padding: 0 .9rem .8rem; }
.gs-bar { height: 4px; border-radius: 999px; background: var(--gray-100); overflow: hidden; margin-bottom: .6rem; }
.gs-bar span { display: block; height: 100%; background: #22c55e; }
.gs-steps { list-style: none; margin: 0; padding: 0; }
.gs-steps li { display: flex; align-items: center; gap: .55rem; padding: .3rem 0; }
.gs-mark { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 700; flex-shrink: 0; border: 1.5px solid var(--gray-200); color: var(--gray-600); }
.gs-steps a { color: var(--text); text-decoration: none; }
.gs-steps a:hover { color: var(--accent); text-decoration: underline; }
.gs-done .gs-mark { background: #22c55e; border-color: #22c55e; color: #fff; }
.gs-done a { color: var(--gray-600); text-decoration: line-through; }
.gs-current .gs-mark { border-color: var(--accent); background: var(--accent); color: #fff; }
.gs-current a { font-weight: 700; color: var(--accent); }
.gs-finish { margin: .6rem 0 .5rem; }
.guide-off-form { margin: .4rem 0 0; }
.gs-hide { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: .78rem; color: var(--gray-600); text-decoration: underline; }
.gs-hide:hover { color: var(--text); }
body.has-guide .page { padding-bottom: 5rem; }   /* room so the panel never covers the last buttons */

/* Tip at the top of the page for the current step */
.guide-tip { border: 1px solid #bfdbfe; border-left: 4px solid var(--accent); background: var(--brand-light);
    border-radius: 8px; padding: .75rem 1rem; margin: 0 0 1rem; color: var(--text); font-size: .9rem; line-height: 1.5; }
.guide-tip p { margin: 0; }
.gt-step { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); margin-bottom: .2rem; }
.guide-tip.gt-next { border-left-color: #22c55e; }
.gt-check { color: #16a34a; font-weight: 700; }

[data-theme="dark"] .guide-panel { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .gs-head, [data-theme="dark"] .gs-steps a { color: #e5e7eb; }
[data-theme="dark"] .gs-count, [data-theme="dark"] .gs-chev, [data-theme="dark"] .gs-done a, [data-theme="dark"] .gs-hide { color: #9ca3af; }
[data-theme="dark"] .gs-bar { background: #374151; }
[data-theme="dark"] .gs-todo .gs-mark { border-color: #4b5563; color: #9ca3af; }
[data-theme="dark"] .gs-current .gs-mark { background: #2563eb; border-color: #2563eb; color: #fff; }
@media print { .guide-panel, .guide-tip, .guide-toggle-form { display: none !important; } }
[data-theme="dark"] .gs-current a { color: #93c5fd; }
[data-theme="dark"] .guide-tip { background: #172554; border-color: #1e3a8a; border-left-color: #60a5fa; color: #e5e7eb; }
[data-theme="dark"] .guide-tip.gt-next { border-left-color: #22c55e; }
[data-theme="dark"] .gt-step { color: #93c5fd; }
@media (max-width: 700px) {
    .guide-panel { left: 12px; right: 12px; bottom: 12px; width: auto; max-width: none; }
}
