body {
    background: var(--kt-body-bg, #f5f7fb);
    color: var(--kt-text, #1f2937);
}

.app-frame {
    min-height: 100vh;
    display: flex;
}

.app-sidebar {
    width: 270px;
    background: var(--kt-surface, #fff);
    border-right: 1px solid var(--kt-border, #dee2e6);
}

.app-sidebar-header {
    min-height: 58px;
    border-bottom: 1px solid var(--kt-subtle-border, #edf0f3);
}

.app-sidebar-brand,
.app-brand {
    color: var(--kt-heading, #172033);
    font-weight: 700;
    text-decoration: none;
}

.app-sidebar-brand:hover,
.app-brand:hover {
    color: var(--kt-primary, #0d6efd);
}

.app-sidebar-body {
    padding: 0;
}

.app-nav {
    width: 100%;
    padding: 0.75rem;
}

.app-nav-section + .app-nav-section {
    margin-top: 0.75rem;
}

.app-nav-dashboard {
    margin-bottom: 0.75rem;
}

.app-nav-group {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--kt-muted, #6b7280);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0;
    padding: 0.35rem 0.45rem;
    text-align: left;
    text-transform: uppercase;
}

.app-nav-group::after {
    border: solid currentColor;
    border-width: 0 1.5px 1.5px 0;
    content: "";
    display: inline-block;
    height: 0.45rem;
    margin-left: 0.5rem;
    transform: rotate(45deg);
    transition: transform 0.15s ease-in-out;
    width: 0.45rem;
}

.app-nav-group[aria-expanded="false"]::after {
    transform: rotate(-45deg);
}

.app-nav-items {
    margin-top: 0.2rem;
}

.app-nav-link {
    border-radius: 6px;
    color: var(--kt-nav-text, #273142);
    display: block;
    font-weight: 500;
    padding: 0.5rem 0.65rem;
    text-decoration: none;
}

.app-nav-link:hover,
.app-nav-link:focus {
    background: var(--kt-nav-hover-bg, #eef3f8);
    color: var(--kt-nav-hover-text, var(--kt-link, #0b5ed7));
}

.app-nav-link.active {
    background: var(--kt-nav-active-bg, #e7f1ff);
    color: var(--kt-nav-active-text, #084298);
}

/* Task #3: top-level menu items get a distinct, heavier look so they stand out
   from the collapsible sub-menu items below them. */
.app-nav-top {
    font-weight: 700;
    font-size: 0.82rem;
    border-radius: 6px;
    color: var(--kt-nav-text, #172033);
    background: var(--kt-nav-top-bg, #f1f4f8);
    display: flex;
    align-items: center;
    padding: 0.55rem 0.7rem;
    text-decoration: none;
    box-shadow: inset 3px 0 0 0 var(--kt-nav-top-rule, #cfd6e0);
}

.app-nav-top:hover,
.app-nav-top:focus {
    background: var(--kt-nav-top-hover, #e5ebf2);
    color: var(--kt-nav-hover-text, var(--kt-link, #0b5ed7));
    box-shadow: inset 3px 0 0 0 var(--kt-nav-top-rule, #cfd6e0);
}

.app-nav-top.active {
    background: var(--kt-nav-active-bg, #e7f1ff);
    color: var(--kt-nav-active-text, #084298);
    box-shadow: inset 3px 0 0 0 var(--kt-nav-top-rule, #084298);
}

/* Sub-menu items: lighter, no rule, so they read as secondary. */
.app-nav-sub {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--kt-nav-text-muted, #56607a);
    border-radius: 6px;
    padding: 0.4rem 0.75rem 0.4rem 2.05rem;
    text-decoration: none;
}

.app-nav-sub:hover,
.app-nav-sub:focus {
    background: var(--kt-nav-hover-bg, #eef3f8);
    color: var(--kt-nav-hover-text, var(--kt-link, #0b5ed7));
}

.app-nav-sub.active {
    background: var(--kt-nav-active-bg, #e7f1ff);
    color: var(--kt-nav-active-text, #084298);
}

.app-main {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    align-items: center;
    background: var(--kt-surface, #fff);
    border-bottom: 1px solid var(--kt-border, #dee2e6);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    min-height: 58px;
    padding: 0.65rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-topbar-start,
.app-topbar-actions {
    align-items: center;
    display: flex;
    gap: 0.6rem;
    min-width: 0;
}

.app-topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}


.app-theme-picker {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    gap: 0.35rem;
}

.app-theme-picker .form-select {
    min-width: 6.75rem;
}

.app-theme-picker .form-select:first-of-type {
    min-width: 7.5rem;
}

.app-user-name {
    color: var(--kt-muted-strong, #4b5563);
    font-size: 0.9rem;
    white-space: nowrap;
}

.app-shell {
    max-width: 1600px;
    padding: 1rem;
}

.page-title {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.page-title h1 {
    font-size: 1.6rem;
    margin: 0;
}

.panel {
    background: var(--kt-surface, #fff);
    border: 1px solid var(--kt-border, #dee2e6);
    border-radius: 6px;
    box-shadow: var(--kt-shadow, 0 1px 2px rgba(15, 23, 42, 0.04));
    padding: 1rem;
}

.form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.table td,
.table th {
    vertical-align: middle;
}

.white-space-pre-line {
    white-space: pre-line;
}

@media (min-width: 992px) {
    .app-sidebar {
        flex: 0 0 270px;
        min-height: 100vh;
        position: sticky;
        top: 0;
    }

    .app-sidebar .offcanvas-body {
        display: block;
        max-height: calc(100vh - 58px);
        overflow-y: auto;
    }
}

@media (max-width: 991.98px) {
    .app-frame {
        display: block;
    }

    .app-sidebar {
        width: 280px;
    }
}

@media (max-width: 576px) {
    .app-shell {
        padding: 0.75rem;
    }

    .app-topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .app-topbar-start,
    .app-topbar-actions,
    .page-title .actions {
        justify-content: flex-start;
    }

    .page-title {
        align-items: stretch;
        flex-direction: column;
    }
}

.metric-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.metric {
    background: var(--kt-surface, #fff);
    border: 1px solid var(--kt-border, #dee2e6);
    border-radius: 6px;
    padding: 0.9rem 1rem;
}

.metric > div:first-child {
    color: var(--kt-muted, #6b7280);
    font-size: 0.86rem;
    font-weight: 600;
}

.metric-value {
    color: var(--kt-heading, #172033);
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0.25rem;
}

.dashboard-message p {
    margin-bottom: 0.35rem;
}

.dashboard-message p:last-child {
    margin-bottom: 0;
}

.dashboard-blurb {
    border-top: 1px solid var(--kt-subtle-border, #edf0f3);
    margin-top: 0.85rem;
    padding-top: 0.85rem;
}

.dashboard-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
}

.section-title-row {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.dashboard-table-wrap {
    overflow-x: auto;
}

.dashboard-summary-table {
    min-width: 720px;
}

.dashboard-summary-table th,
.dashboard-summary-table td {
    white-space: nowrap;
}

.month-summary {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

@media (max-width: 1199.98px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.report-list {
    display: grid;
    gap: 0;
}

.report-list-item {
    align-items: center;
    border-top: 1px solid var(--kt-subtle-border, #edf0f3);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 0.85rem 0;
}

.report-list-item:first-child {
    border-top: 0;
    padding-top: 0;
}

.report-list-item:last-child {
    padding-bottom: 0;
}

.report-list-body {
    min-width: 0;
}

.report-list-title {
    align-items: center;
    color: var(--kt-heading, #172033);
    display: flex;
    flex-wrap: wrap;
    font-weight: 700;
    gap: 0.5rem;
}

.report-description {
    color: var(--kt-muted, #6b7280);
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

.report-tag {
    background: var(--kt-chip-bg, #eef3f8);
    border: 1px solid var(--kt-chip-border, #d9e2ec);
    border-radius: 4px;
    color: var(--kt-chip-text, #364152);
    display: inline-block;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 0.18rem 0.4rem;
}

.report-list-action {
    flex: 0 0 auto;
}

.report-table-wrap {
    overflow-x: auto;
}

.report-bar-track {
    background: var(--kt-subtle-border, #edf0f3);
    border-radius: 4px;
    height: 0.55rem;
    min-width: 140px;
    overflow: hidden;
}

.report-bar {
    background: var(--kt-primary, #0d6efd);
    height: 100%;
}

.signature-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.signature-line {
    border-bottom: 1px solid var(--kt-muted-strong, #4b5563);
    height: 2.25rem;
}

@media (max-width: 576px) {
    .report-list-item {
        align-items: flex-start;
        flex-direction: column;
    }
}


.form-grid-span {
    grid-column: 1 / -1;
}

.report-table-wrap {
    overflow-x: auto;
}

.invoice-document,
.invoice-report-panel {
    background: var(--kt-surface, #fff);
    border: 1px solid var(--kt-border, #dee2e6);
    border-radius: 6px;
    box-shadow: var(--kt-shadow, 0 1px 2px rgba(15, 23, 42, 0.04));
    padding: 1.25rem;
}

.invoice-header {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.invoice-brand {
    color: var(--kt-heading, #172033);
    font-size: 1.4rem;
    font-weight: 700;
}

.invoice-number-block {
    text-align: right;
}

.invoice-number {
    color: var(--kt-heading, #172033);
    font-size: 1.1rem;
    font-weight: 700;
}

.invoice-address-grid,
.invoice-meta-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 1rem;
}

.invoice-address-grid h2 {
    color: var(--kt-muted, #6b7280);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.invoice-meta-grid > div {
    border: 1px solid var(--kt-subtle-border, #edf0f3);
    border-radius: 6px;
    padding: 0.65rem 0.75rem;
}

.invoice-meta-grid span {
    color: var(--kt-muted, #6b7280);
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
}

.invoice-meta-grid strong {
    color: var(--kt-heading, #172033);
    display: block;
    font-weight: 700;
    margin-top: 0.2rem;
}

.invoice-note {
    background: var(--kt-subtle-bg, #f8fafc);
    border: 1px solid var(--kt-subtle-border, #edf0f3);
    border-radius: 6px;
    margin-bottom: 1rem;
    padding: 0.85rem;
}

.invoice-lines tfoot th {
    border-top: 2px solid var(--kt-rule, #cbd5e1);
}

@media print {
    body {
        background: var(--kt-surface, #fff);
        color: #000;
    }

    .app-sidebar,
    .app-topbar,
    .no-print {
        display: none !important;
    }

    .app-frame,
    .app-main,
    .app-shell {
        display: block;
        margin: 0;
        max-width: none;
        padding: 0;
        width: 100%;
    }

    .invoice-document,
    .invoice-report-panel,
    .panel {
        border: 0;
        box-shadow: none;
        padding: 0;
    }

    .report-table-wrap {
        overflow: visible;
    }
}


.app-help-footer {
    border-top: 1px solid var(--kt-border, #dee2e6);
    color: var(--kt-muted, #6b7280);
    font-size: 0.9rem;
    padding: 0.75rem 1rem 1rem;
    text-align: right;
}

.app-help-footer a {
    color: var(--kt-link, #0b5ed7);
    font-weight: 600;
    text-decoration: none;
}

.app-help-footer a:hover,
.app-help-footer a:focus {
    text-decoration: underline;
}

.help-title {
    align-items: flex-start;
}

.help-layout {
    align-items: start;
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
}

.help-nav {
    position: sticky;
    top: 74px;
}

.help-nav a {
    border-radius: 6px;
    color: var(--kt-nav-text, #273142);
    display: block;
    font-weight: 600;
    padding: 0.35rem 0.45rem;
    text-decoration: none;
}

.help-nav a:hover,
.help-nav a:focus {
    background: var(--kt-nav-hover-bg, #eef3f8);
    color: var(--kt-link, #0b5ed7);
}

.help-article {
    line-height: 1.6;
    max-width: 1120px;
}

.help-article section + section {
    border-top: 1px solid var(--kt-subtle-border, #edf0f3);
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

.help-article h2 {
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
}

.help-article h3 {
    font-size: 1.05rem;
    margin-top: 1.1rem;
}

.help-article dt {
    font-weight: 700;
}

.help-article dd {
    margin-bottom: 0.75rem;
}

@media (max-width: 991.98px) {
    .help-layout {
        grid-template-columns: 1fr;
    }

    .help-nav {
        position: static;
    }
}

@media print {
    .app-sidebar,
    .app-topbar,
    .app-help-footer,
    .no-print {
        display: none !important;
    }

    .app-frame,
    .app-main {
        display: block;
        min-height: auto;
    }

    .app-shell {
        max-width: none;
        padding: 0;
    }

    .panel {
        border: 0;
        box-shadow: none;
    }
}


.report-viewer-panel {
    padding: 0;
    overflow: hidden;
}

.report-viewer-frame {
    background: var(--kt-surface, #ffffff);
    border: 0;
    display: block;
    height: min(78vh, 980px);
    min-height: 640px;
    width: 100%;
}

/* ---- Mobile ---------------------------------------------------------- */

/* Wide data tables scroll inside their own panel instead of forcing the whole
   page sideways. The report/dashboard variants above predate this; this is the
   generic one used by the list and timesheet views. */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 575.98px) {
    /* iOS Safari auto-zooms when a focused control is under 16px. The small
       variants are 14px, so tapping the theme picker or a filter zoomed the
       page and left it zoomed. */
    .form-control,
    .form-select,
    .form-control-sm,
    .form-select-sm {
        font-size: 16px;
    }

    /* The account controls collapse behind a toggle on phones; when open they
       stack full width under the brand row rather than crowding it. */
    .app-topbar-actions.collapse:not(.show),
    .app-topbar-actions.collapsing {
        gap: 0;
    }

    .app-topbar-actions {
        align-items: stretch;
        flex-direction: column;
        padding-top: 0.5rem;
        width: 100%;
    }

    .app-topbar-actions .app-theme-picker {
        width: 100%;
    }

    .app-topbar-actions .app-theme-picker .form-select {
        flex: 1 1 0;
        min-width: 0;
    }

    .app-topbar-actions .app-user-name {
        padding-top: 0.15rem;
    }

    .app-topbar-actions form {
        display: block;
    }

    .app-topbar-actions form .btn {
        width: 100%;
    }
}

/* Honeypot wrapper. Moved off-screen rather than display:none, which some
   form-filling scripts detect and skip. Never shown to a person. */
.hp-field {
    position: absolute !important;
    left: -9999px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}
