/* Monthly Spending Report (Story 2241).
   One month of the general ledger told as a story: what came in, what was taken
   out of the paycheck, what was spent after payday, and what is left. */

body { background: #F2F2F4; margin: 0; }

/* Shell is pinned: only .ms-body scrolls, so the icon band and the month picker
   never slide off on a phone. 100dvh (not 100vh) or the URL bar steals the top. */
.page-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom);
}

.ct-header {
    background: #3C3C3C; color: #fff; padding: 10px 16px;
    display: flex; align-items: center; gap: 12px; flex: 0 0 auto;
}
.ct-header h1 { margin: 0; font-size: 14pt; font-weight: 600; flex: 1; }
.ct-header button {
    color: #fff; background: transparent; border: 1px solid #6A6A6A;
    border-radius: 3px; padding: 4px 12px; font: inherit; cursor: pointer;
}

#lwIconBand, .ct-header, .ms-controls, .ms-statusbar { flex: 0 0 auto; }

/* ---- controls ---- */
.ms-controls {
    background: #fff; border-bottom: 1px solid #DDD; padding: 8px 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.ms-row { display: flex; align-items: center; gap: 8px; }
.ms-row label {
    font-size: 10px; color: #555; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.3px;
}
/* A field alone on its row runs the full width and lines up with the content
   on both sides. */
.ms-row select { flex: 1; min-width: 0; }
.ms-row .ms-step {
    background: #E9E9EF; color: #333; border: 1px solid #C9C9CC;
    border-radius: 4px; padding: 7px 12px; font: inherit; font-size: 13px;
    cursor: pointer; flex: 0 0 auto;
}
.ms-row .ms-step:disabled { opacity: .4; cursor: default; }

/* Collapse all / Expand all share the row and split it evenly. The choice is
   remembered, so Expand all always stays visible next to Collapse all -- a
   remembered all-collapsed page must never look like a page with no data. */
.ms-row .ms-all {
    background: #E9E9EF; color: #333; border: 1px solid #C9C9CC;
    border-radius: 4px; padding: 7px 12px; font: inherit; font-size: 13px;
    cursor: pointer; flex: 1; min-width: 0;
}
.ms-row .ms-all:hover { background: #DEDEE6; }

/* ---- body ---- */
.ms-body { flex: 1; min-height: 0; overflow: auto; padding: 12px; }
.ms-loading, .ms-empty { text-align: center; color: #888; padding: 40px; font-size: 13px; }

/* ---- headline tiles ---- */
.ms-tiles {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px; margin-bottom: 12px;
}
.ms-tile {
    background: #fff; border: 1px solid #E4E4E8; border-radius: 6px;
    padding: 10px 12px;
}
.ms-tile .k {
    font-size: 10px; color: #666; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.3px;
}
.ms-tile .v { font-size: 19px; font-weight: 700; margin-top: 3px; }
.ms-tile .n { font-size: 11px; color: #888; margin-top: 2px; }
.ms-tile.in    .v { color: #1A7A3C; }
.ms-tile.out   .v { color: #B53C3C; }
.ms-tile.left  .v { color: #0A66C2; }
.ms-tile.left.negative .v { color: #B53C3C; }
.ms-tile.cash  .v { color: #6A3CB5; }

.ms-lede {
    background: #fff; border: 1px solid #E4E4E8; border-radius: 6px;
    padding: 12px 14px; margin-bottom: 12px;
    font-size: 13px; line-height: 1.55; color: #333;
}
.ms-lede b { color: #111; }

/* ---- sections ---- */
.ms-section {
    background: #fff; border: 1px solid #E4E4E8; border-radius: 6px;
    margin-bottom: 12px; overflow: hidden;
}
.ms-section > h2 {
    margin: 0; padding: 10px 14px; font-size: 14px; color: #333;
    background: #F6F6F9; border-bottom: 1px solid #ECECEE;
    display: flex; align-items: baseline; gap: 8px;
}
.ms-section > h2 .amt { margin-left: auto; font-weight: 700; }
.ms-section > h2 .sub { font-size: 11px; color: #777; font-weight: 400; }
.ms-note { padding: 8px 14px; font-size: 11px; color: #777; border-bottom: 1px solid #F2F2F4; }
.ms-section .ms-empty { padding: 18px 14px; }
.ms-ghead .sub, .ms-row-item .sub, .ms-check .sub { font-size: 11px; color: #999; font-weight: 400; }

/* ---- group / row list ---- */
.ms-group { border-bottom: 1px solid #ECECEE; }
.ms-group:last-child { border-bottom: none; }
.ms-ghead {
    width: 100%; text-align: left; background: transparent; border: none;
    padding: 9px 14px; font: inherit; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
}
.ms-ghead:hover { background: #ECF4FD; }
.ms-ghead .tw { color: #888; font-size: 11px; width: 12px; flex: 0 0 auto; }
.ms-ghead .nm { font-weight: 600; font-size: 13px; color: #111; flex: 1; min-width: 0; }
.ms-ghead .amt { font-weight: 700; font-size: 13px; white-space: nowrap; }
.ms-ghead .pctlbl { font-size: 11px; color: #888; width: 44px; text-align: right; flex: 0 0 auto; }

.ms-bar { height: 4px; background: #EFEFF3; margin: 0 14px 8px; border-radius: 2px; overflow: hidden; }
.ms-bar > i { display: block; height: 100%; background: #B53C3C; }
.ms-section.income .ms-bar > i { background: #1A7A3C; }

.ms-rows { display: none; }
.ms-group.open .ms-rows { display: block; }

.ms-row-item {
    display: flex; align-items: baseline; gap: 8px;
    padding: 7px 14px 7px 32px; font-size: 12.5px;
    border-top: 1px solid #F4F4F6;
}
.ms-row-item .nm { flex: 1; min-width: 0; color: #333; }
.ms-row-item .amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ms-row-item .cnt { font-size: 11px; color: #999; width: 44px; text-align: right; flex: 0 0 auto; }
.ms-row-item.drillable { cursor: pointer; }
.ms-row-item.drillable:hover { background: #ECF4FD; }

.ms-drill { padding: 4px 14px 10px 32px; background: #FAFAFC; border-top: 1px solid #F0F0F2; }
.ms-drill table { width: 100%; border-collapse: collapse; }
.ms-drill th, .ms-drill td {
    text-align: left; padding: 5px 6px; font-size: 11.5px;
    border-bottom: 1px solid #EEE;
}
.ms-drill th { color: #666; font-weight: 600; }
.ms-drill td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ms-drill .none { color: #999; font-size: 11.5px; padding: 6px 0; }

/* ---- reconciliation ---- */
.ms-recon { padding: 10px 14px; font-size: 12.5px; }
.ms-recon .line { display: flex; padding: 4px 0; border-bottom: 1px solid #F4F4F6; }
.ms-recon .line:last-child { border-bottom: none; }
.ms-recon .line .nm { flex: 1; color: #444; }
.ms-recon .line .amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.ms-recon .line.total { border-top: 2px solid #E4E4E8; margin-top: 4px; padding-top: 7px; }
.ms-recon .warn { color: #B53C3C; font-size: 11.5px; margin-top: 8px; }

/* ---- paychecks ---- */
.ms-check { border-bottom: 1px solid #ECECEE; padding: 10px 14px; }
.ms-check:last-child { border-bottom: none; }
.ms-check h3 { margin: 0 0 6px; font-size: 13px; color: #333; }
.ms-check .kv { display: flex; padding: 3px 0; font-size: 12.5px; }
.ms-check .kv .nm { flex: 1; color: #444; }
.ms-check .kv .amt { font-variant-numeric: tabular-nums; }
.ms-check .kv.head { font-weight: 700; color: #111; }
.ms-check .kv.net { font-weight: 700; color: #1A7A3C; border-top: 1px solid #EEE; margin-top: 4px; padding-top: 6px; }
.ms-check .kv.ded .nm { padding-left: 14px; color: #666; }

.pos { color: #1A7A3C; }
.neg { color: #B53C3C; }

.ms-statusbar { background: #2A2A2A; color: #BBB; padding: 4px 12px; font-size: 11px; }

/* Print: the report only, opened through the Leonardo Print menu. */
@media print {
    .page-shell { height: auto; overflow: visible; }
    .ms-body { overflow: visible; }
    .ms-rows { display: block; }
}
