/* Digisnare Billing — application styling.
   Kept in a stylesheet rather than inline <style> blocks so the Content
   Security Policy can forbid inline styles and scripts outright. */

:root {
    --app-sidebar-width: 260px;
    --app-navy: #0f2744;
    --app-navy-2: #1a3c5e;
    --app-accent: #0d6efd;
    --app-surface: #f1f5f9;
    --app-border: #e2e8f0;
}

* { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }

body {
    background: var(--app-surface);
    min-height: 100vh;
}

.skip-link {
    position: absolute;
    top: .5rem;
    left: .5rem;
    z-index: 2000;
    background: #fff;
    padding: .5rem .75rem;
    border-radius: .5rem;
}

/* ---- Sidebar ---------------------------------------------------------- */

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--app-sidebar-width);
    background: linear-gradient(180deg, var(--app-navy) 0%, var(--app-navy-2) 100%);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
    overflow-y: auto;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.1rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.app-brand-logo { max-width: 40px; max-height: 40px; border-radius: .35rem; background: #fff; padding: 2px; }

.app-brand-mark {
    width: 38px; height: 38px;
    flex: 0 0 38px;
    border-radius: .55rem;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
}

.app-brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.app-brand-text strong { color: #fff; font-size: .82rem; font-weight: 600; }
.app-brand-text small { color: rgba(255, 255, 255, .5); font-size: .68rem; }

.app-nav { flex: 1 1 auto; padding: .5rem 0 1rem; }

.app-nav-label {
    margin: 1rem 0 .3rem;
    padding: 0 1.15rem;
    color: rgba(255, 255, 255, .38);
    font-size: .64rem;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem 1.15rem;
    color: rgba(255, 255, 255, .78);
    text-decoration: none;
    font-size: .875rem;
    border-left: 3px solid transparent;
}

.app-nav-link:hover,
.app-nav-link:focus-visible { background: rgba(255, 255, 255, .08); color: #fff; }

.app-nav-link.is-active {
    background: rgba(13, 110, 253, .22);
    border-left-color: #4d94ff;
    color: #fff;
    font-weight: 600;
}

.app-nav-link i { font-size: 1rem; width: 1.1rem; text-align: center; }

.app-sidebar-foot { padding: .9rem 1.15rem 1.2rem; border-top: 1px solid rgba(255, 255, 255, .1); }

.app-user { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }

.app-user-avatar {
    width: 34px; height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    background: var(--app-accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
}

.app-user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.app-user-meta strong { color: #fff; font-size: .8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-meta small { color: rgba(255, 255, 255, .5); font-size: .68rem; }

/* ---- Main column ------------------------------------------------------ */

.app-main {
    margin-left: var(--app-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .85rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-topbar-title { flex: 1 1 auto; min-width: 0; }
.app-topbar-title h1 { font-size: 1.1rem; font-weight: 600; margin: 0; color: #15293f; }
.app-topbar-title p { margin: .1rem 0 0; font-size: .8rem; color: #64748b; }

.app-content { flex: 1 1 auto; padding: 1.4rem 1.5rem 2rem; }

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: .85rem 1.5rem;
    border-top: 1px solid var(--app-border);
    font-size: .76rem;
    color: #64748b;
    background: #fff;
}

.app-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 39, 68, .45);
    z-index: 1035;
}

/* ---- Components ------------------------------------------------------- */

.card { border: 1px solid var(--app-border); border-radius: .7rem; box-shadow: 0 1px 2px rgba(15, 39, 68, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--app-border); padding: .85rem 1.1rem; }
.card-header h2, .card-header h5 { font-size: .95rem; font-weight: 600; margin: 0; color: #15293f; }

.stat-card { display: block; text-decoration: none; color: inherit; height: 100%; }
.stat-card:hover { border-color: #bcd2f5; }
.stat-card .stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; font-weight: 600; }
.stat-card .stat-value { font-size: 1.45rem; font-weight: 700; color: #15293f; line-height: 1.2; }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: .6rem; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; }

.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    font-weight: 600;
    background: #f8fafc;
    white-space: nowrap;
}
.table td { font-size: .86rem; vertical-align: middle; }

.avatar-circle {
    width: 34px; height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--app-navy-2), var(--app-accent));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .82rem;
}

.btn-icon { padding: .25rem .5rem; font-size: .78rem; line-height: 1.4; }

.empty-state { padding: 3rem 1rem; text-align: center; color: #64748b; }
.empty-state i { font-size: 2.25rem; display: block; margin-bottom: .6rem; opacity: .45; }

.form-label { font-size: .8rem; font-weight: 600; color: #334155; margin-bottom: .3rem; }
.form-control, .form-select { font-size: .875rem; }
.form-text { font-size: .76rem; }
.required-mark { color: #dc3545; }

.item-table { --bs-table-bg: transparent; }
.item-table td { padding: .4rem .35rem; vertical-align: top; }
.item-table input, .item-table select, .item-table textarea { font-size: .83rem; }
.item-table textarea { min-height: 38px; resize: vertical; }
.item-table .col-sr { width: 42px; }
.item-table .col-qty { width: 96px; }
.item-table .col-unit { width: 96px; }
.item-table .col-rate { width: 124px; }
.item-table .col-amount { width: 130px; }
.item-table .col-action { width: 44px; }

.totals-panel { background: #f8fafc; border: 1px solid var(--app-border); border-radius: .7rem; padding: 1rem 1.1rem; }
.totals-row { display: flex; justify-content: space-between; gap: 1rem; font-size: .86rem; padding: .22rem 0; }
.totals-row .label { color: #64748b; }
.totals-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.totals-row.is-grand { border-top: 2px solid var(--app-border); margin-top: .45rem; padding-top: .6rem; font-size: 1.05rem; }
.totals-row.is-grand .label { color: #15293f; font-weight: 700; }
.totals-row.is-grand .value { color: var(--app-navy-2); font-weight: 700; }

.doc-sheet { background: #fff; border: 1px solid var(--app-border); border-radius: .7rem; padding: 1.75rem; }
.doc-meta dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; font-weight: 600; }
.doc-meta dd { font-size: .88rem; margin-bottom: .6rem; }

.password-hint { font-size: .76rem; color: #64748b; }

/* ---- Login ------------------------------------------------------------ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0f2744 0%, #1a3c5e 55%, #0d6efd 140%);
}

.login-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2.4rem 2.1rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 60px rgba(8, 20, 38, .32);
}

.login-logo { display: block; margin: 0 auto 1rem; max-width: 160px; max-height: 64px; }

.login-card h1 { font-size: 1.15rem; font-weight: 700; color: #15293f; text-align: center; margin-bottom: .2rem; }
.login-card .login-subtitle { text-align: center; color: #64748b; font-size: .83rem; margin-bottom: 1.5rem; }

/* ---- Responsive ------------------------------------------------------- */

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-content { padding: 1.1rem 1rem 2rem; }
    .app-topbar { padding: .75rem 1rem; }
    .app-footer { padding: .75rem 1rem; }
}

@media print {
    .app-sidebar, .app-topbar, .app-footer, .app-backdrop, .no-print { display: none !important; }
    .app-main { margin-left: 0; }
    .app-content { padding: 0; }
    .doc-sheet { border: 0; padding: 0; }
    body { background: #fff; }
}
