/* TransactPro — application styles */
:root {
    --navy: #0b2239;
    --navy-2: #12304f;
    --primary: #0f5fa8;
    --primary-dark: #0b4a85;
    --accent: #14a38b;
    --bg: #f3f5f9;
    --surface: #ffffff;
    --border: #e2e7ee;
    --text: #1c2a39;
    --muted: #66758a;
    --success: #16875a;
    --success-bg: #e5f6ee;
    --warning: #b26b00;
    --warning-bg: #fff3dc;
    --danger: #c2362e;
    --danger-bg: #fdeae8;
    --info: #0f5fa8;
    --info-bg: #e5f0fb;
    --neutral-bg: #eceff4;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(11, 34, 57, .06), 0 4px 14px rgba(11, 34, 57, .05);
    --sidebar-w: 252px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
p { margin: 0 0 .75rem; }
.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1.25rem; }

/* ------------------------------------------------ layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--navy), var(--navy-2));
    color: #c9d6e6; display: flex; flex-direction: column; z-index: 40; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--primary)); font-weight: 700; font-size: 1.1rem;
}
.brand strong { display: block; font-size: 1.05rem; letter-spacing: .3px; }
.brand small { display: block; font-size: .72rem; color: #8ea3bc; }
.nav { padding: .25rem .75rem 1.5rem; }
.nav-label { margin: 1.1rem .6rem .35rem; font-size: .68rem; text-transform: uppercase; letter-spacing: 1.2px; color: #6f86a3; }
.nav-link {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 8px;
    color: #c9d6e6; font-size: .93rem;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(20, 163, 139, .2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-badge {
    margin-left: auto; font-style: normal; background: var(--accent); color: #fff;
    border-radius: 999px; font-size: .7rem; padding: .05rem .5rem; font-weight: 600;
}
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem;
    padding: .75rem 1.75rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.3rem; margin: 0; }
.topbar-title p { margin: 0; color: var(--muted); font-size: .85rem; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.topbar-right form { margin: 0; }
.menu-btn { display: none; }
.icon-btn {
    position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border);
    border-radius: 9px; background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); text-decoration: none; }
.bell em {
    position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
    background: var(--danger); color: #fff; font-size: .68rem; font-style: normal; display: grid; place-items: center; font-weight: 600;
}
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .2rem .5rem .2rem .2rem; border-radius: 999px; color: var(--text); }
.user-chip:hover { background: var(--bg); text-decoration: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: .8rem; font-weight: 600; }
.user-chip-text strong { display: block; font-size: .85rem; line-height: 1.15; }
.user-chip-text small { color: var(--muted); font-size: .72rem; }
.content { flex: 1; padding: 1.5rem 1.75rem; max-width: 1400px; width: 100%; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-bottom: 1rem; }
.footer { padding: 1rem 1.75rem; color: var(--muted); font-size: .78rem; border-top: 1px solid var(--border); }
.sidebar-backdrop { display: none; }

/* ------------------------------------------------ cards, grids, stats */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1.02rem; }
.card-body { padding: 1.25rem; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.15rem; border-left: 4px solid var(--primary); }
.stat.accent { border-left-color: var(--accent); }
.stat.warn { border-left-color: #e0a100; }
.stat.danger { border-left-color: var(--danger); }
.stat.ok { border-left-color: var(--success); }
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; }
.stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1.25; margin-top: .15rem; }
.stat-note { color: var(--muted); font-size: .8rem; }
.welcome { background: linear-gradient(120deg, var(--navy), var(--primary)); color: #fff; border: 0; }
.welcome h2 { font-size: 1.3rem; }
.welcome p { color: #d7e5f5; margin: 0; }
.welcome .meta { margin-top: .75rem; font-size: .82rem; color: #a9c3e0; }

/* ------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: #f8fafc; font-size: .74rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); white-space: nowrap; }
.table tbody tr:hover { background: #fafcfe; }
.table tfoot td { font-weight: 700; background: #f8fafc; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .code { font-weight: 600; white-space: nowrap; }
.table-empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ------------------------------------------------ badges */
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: #455468; }
.badge-draft, .badge-inactive, .badge-completed { background: var(--neutral-bg); color: #455468; }
.badge-pending-manager, .badge-pending-finance, .badge-pending-director, .badge-submitted, .badge-revision-requested, .badge-overdue { background: var(--warning-bg); color: var(--warning); }
.badge-active, .badge-paid, .badge-accountability-submitted, .badge-info { background: var(--info-bg); color: var(--info); }
.badge-approved, .badge-verified, .badge-closed, .badge-ok { background: var(--success-bg); color: var(--success); }
.badge-rejected, .badge-suspended, .badge-locked { background: var(--danger-bg); color: var(--danger); }
.badge-role { background: #ece8fb; color: #4b3ca8; }

/* ------------------------------------------------ buttons & forms */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1.05rem; border-radius: 8px;
    border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn:hover { text-decoration: none; background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #11704a; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #a42b24; }
.btn-warning { background: #fff; color: var(--warning); border-color: #e8c27a; }
.btn-warning:hover { background: var(--warning-bg); }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn-row.end { justify-content: flex-end; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.full { grid-column: 1 / -1; }
.field label, .label { font-weight: 600; font-size: .85rem; }
.req { color: var(--danger); }
.input, select.input, textarea.input {
    width: 100%; padding: .55rem .75rem; border: 1px solid #c9d2de; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
.input:focus { outline: 2px solid rgba(15, 95, 168, .25); border-color: var(--primary); }
.input.invalid { border-color: var(--danger); }
.input[readonly], .input[disabled] { background: #f1f4f8; color: var(--muted); }
textarea.input { min-height: 96px; resize: vertical; }
.hint { color: var(--muted); font-size: .8rem; }
.error-text { color: var(--danger); font-size: .8rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: #fbfcfe; }
.filters .field { min-width: 160px; }
.filters .field.grow { flex: 1; min-width: 220px; }
form.inline { display: inline; margin: 0; }

/* ------------------------------------------------ alerts */
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: #0d5c3d; border-color: #bfe6d3; }
.alert-error, .alert-danger { background: var(--danger-bg); color: #8f241e; border-color: #f4c3bf; }
.alert-warning { background: var(--warning-bg); color: #7a4a00; border-color: #f1d9a4; }
.alert-info { background: var(--info-bg); color: #0b4a85; border-color: #c3dcf4; }

/* ------------------------------------------------ detail lists, timeline, progress */
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; margin: 0; }
.kv.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv dt { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; }
.kv dd { margin: .1rem 0 0; font-weight: 600; word-break: break-word; }
.kv .wide { grid-column: 1 / -1; }
.prose { white-space: pre-line; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 .5rem; }
.timeline li { position: relative; padding: 0 0 1.1rem 1.5rem; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--primary); }
.timeline li.rejected::before { background: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.timeline li.revision::before { background: #e0a100; box-shadow: 0 0 0 1px #e0a100; }
.timeline li.approved::before { background: var(--success); box-shadow: 0 0 0 1px var(--success); }
.timeline .when { color: var(--muted); font-size: .78rem; }
.timeline .note { margin-top: .2rem; padding: .45rem .7rem; background: var(--bg); border-radius: 6px; font-size: .88rem; }
.route { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.route .step { padding: .3rem .8rem; border-radius: 999px; background: var(--neutral-bg); color: #455468; font-size: .8rem; font-weight: 600; }
.route .step.done { background: var(--success-bg); color: var(--success); }
.route .step.current { background: var(--primary); color: #fff; }
.route .step.skipped { opacity: .45; text-decoration: line-through; }
.route .sep { color: var(--muted); }
.progress { height: 8px; border-radius: 4px; background: #e6ebf2; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.progress.warn > span { background: #e0a100; }
.progress.danger > span { background: var(--danger); }
.progress.stack { position: relative; }
.progress.stack > span { position: absolute; left: 0; top: 0; height: 100%; }
.progress.stack > .committed { background: #e0a100; }
.progress.stack > .spent { background: var(--danger); }
.bars .bar-row { display: grid; grid-template-columns: 170px 1fr 120px; gap: .75rem; align-items: center; margin-bottom: .8rem; font-size: .88rem; }
.bars .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar-value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty h2 { color: var(--text); }
.panel-note { background: var(--info-bg); color: #0b4a85; padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.budget-box { background: #f8fafc; border: 1px dashed #bfcbdb; border-radius: 8px; padding: .8rem 1rem; font-size: .9rem; }
.budget-box strong { font-variant-numeric: tabular-nums; }
.budget-box.bad { background: var(--danger-bg); border-color: #f0b4af; color: #8f241e; }
.budget-box.good { background: var(--success-bg); border-color: #b5dfc9; }
.item-card { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: .9rem; background: #fcfdff; }
.item-card .item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; font-weight: 600; }

/* ------------------------------------------------ notifications */
.notice { display: flex; justify-content: space-between; gap: 1rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); color: var(--text); }
.notice:hover { background: #fafcfe; text-decoration: none; }
.notice.unread { background: #f1f7fe; border-left: 4px solid var(--primary); }

/* ------------------------------------------------ pager */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); }
.pager a, .pager .disabled { padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 6px; font-size: .85rem; color: var(--text); }
.pager a:hover { background: var(--bg); text-decoration: none; }
.pager a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .disabled { color: #aab5c4; }
.pager-info { margin-left: auto; color: var(--muted); font-size: .82rem; }

/* ------------------------------------------------ guest / login */
body.guest { background: var(--bg); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art {
    background: linear-gradient(150deg, var(--navy) 0%, var(--primary) 100%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.login-art .brand { padding: 0; }
.login-art h2 { font-size: 2rem; max-width: 460px; line-height: 1.2; }
.login-art p { color: #cfe0f3; max-width: 460px; }
.login-art ul { padding-left: 1.1rem; color: #cfe0f3; }
.login-art small { color: #8ea9c7; }
.login-panel { display: grid; place-items: center; padding: 2rem; }
.login-box { width: 100%; max-width: 400px; }
.login-box h1 { font-size: 1.6rem; }
.guest-card { max-width: 480px; margin: 12vh auto; padding: 2rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); text-align: center; box-shadow: var(--shadow); }

/* ------------------------------------------------ responsive */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: none; }
    .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(11, 34, 57, .45); z-index: 35; }
    .main { margin-left: 0; }
    .menu-btn { display: inline-grid; }
    .user-chip-text { display: none; }
    .content { padding: 1rem; }
    .topbar { padding: .6rem 1rem; }
    .login-wrap { grid-template-columns: 1fr; }
    .login-art { display: none; }
}
@media (max-width: 640px) {
    .grid-2, .grid-3, .grid-4, .form-grid, .kv, .kv.cols-3 { grid-template-columns: 1fr; }
    .bars .bar-row { grid-template-columns: 1fr; gap: .25rem; }
}
@media print {
    .sidebar, .topbar, .page-actions, .footer, .filters, .btn { display: none !important; }
    .main { margin: 0; }
    body { background: #fff; }
}

/* ------------------------------------------------ pop-up alerts, sign-in dialog, tabs, project team */
.toast-stack { position: fixed; top: 76px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: .75rem; width: min(380px, calc(100vw - 32px)); }
.toast {
    background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--accent); border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(11, 34, 57, .22); padding: .9rem 1rem; animation: toast-in .25s ease-out;
}
.toast strong { display: block; margin-bottom: .15rem; }
.toast small { display: block; color: var(--muted); margin-top: .25rem; }
.toast-actions { display: flex; gap: .5rem; margin-top: .7rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(11, 34, 57, .55); display: grid; place-items: center; padding: 1rem; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 1.25rem 1.5rem; animation: toast-in .25s ease-out; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.modal-head h2 { margin: 0; font-size: 1.2rem; }
.attention-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.attention-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.attention-list li:last-child { border-bottom: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; padding: .6rem 1.25rem 0; border-bottom: 1px solid var(--border); background: #fbfcfe; }
.tabs a { padding: .55rem 1rem; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; color: var(--muted); font-weight: 600; }
.tabs a:hover { text-decoration: none; background: var(--bg); }
.tabs a.active { background: var(--surface); border-color: var(--border); color: var(--primary); margin-bottom: -1px; }
.tabs .count { display: inline-block; margin-left: .35rem; padding: 0 .5rem; border-radius: 999px; background: var(--neutral-bg); font-size: .75rem; }
.tabs a.active .count { background: var(--info-bg); }
.section-note { padding: .6rem 1.25rem; background: #f8fafc; border-bottom: 1px solid var(--border); color: var(--muted); font-size: .85rem; }
.card.attention { border-left: 5px solid #e0a100; }

/* Accountability: things bought on each receipt */
.lines { margin-top: 1rem; border-top: 1px dashed var(--border); padding-top: .8rem; }
.lines-head, .line-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 130px 120px 34px; gap: .5rem; align-items: center; }
.lines-head { font-size: .75rem; font-weight: 600; color: var(--muted, #64748b); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .03em; }
.line-row { margin-bottom: .4rem; }
.line-row .field { margin: 0; }
.line-total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; padding-right: .3rem; }
.lines-foot { display: flex; justify-content: space-between; align-items: center; margin-top: .6rem; gap: 1rem; flex-wrap: wrap; }
.receipt-total { font-size: .95rem; }
.subtable { width: 100%; border-collapse: collapse; font-size: .85rem; }
.subtable th, .subtable td { padding: .25rem .5rem; border-bottom: 1px solid var(--border); text-align: left; }
.subtable th.num, .subtable td.num { text-align: right; }
.table .receipt-row td { border-bottom: 0; padding-bottom: .2rem; }
@media (max-width: 720px) {
    .lines-head { display: none; }
    .line-row { grid-template-columns: 1fr 1fr; }
    .line-row .field:first-child { grid-column: 1 / -1; }
}

.receipt-row td.num, .table tfoot td.num { white-space: nowrap; }
