/* Allocate page (allocate.html) only. Loads after base.css. */

:root {
    --bg: #f5f3ee;
    --card: #ffffff;
    --ink: #33302b;
    --muted: #8a8375;
    --accent: #4a7c59;
    --accent-dark: #375c43;
    --accent-soft: #eaf1ea;
    --line: #e6e0d4;
    --warn: #c0603a;
    --warn-soft: #fbeee7;
    --blue: #3d6a8f;
    --blue-soft: #e8eff5;
  }
header {
    background: var(--blue);
    color: #fff;
    padding: 20px;
    text-align: center;
  }
header a { color: #fff; }
/* room under the last card so phone browser bars don't cover it */
  @media (max-width: 640px) { .wrap { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); } }
.step-label {
    display: inline-block;
    background: var(--blue-soft);
    color: var(--blue);
    font-weight: 700;
    font-size: .72rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
  }
.hint a { color: var(--blue); }
/* on-hand inputs */
  .have-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.have-box { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; text-align: center; }
.have-box .head { font-size: 1.3rem; font-weight: 800; color: #fff; padding: 8px; line-height: 1; }
.have-box .head small { font-size: .7rem; font-weight: 700; opacity: .85; }
.have-box .body { padding: 12px 10px 12px; }
.have-box input { width: 100%; text-align: center; font-size: 1.3rem; font-weight: 700; padding: 8px; }
.have-box .label { font-size: .72rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .03em; }
.have-box .val { font-size: .8rem; color: var(--muted); margin-top: 6px; min-height: 1.2em; }
.have-totals { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.have-totals .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; display: block; }
.have-totals .v { font-size: 1.25rem; font-weight: 800; }
.have-totals .v.ok { color: var(--accent-dark); }
.have-totals .v.bad { color: var(--warn); }
input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.col-cat { width: 17%; }
.col-amt { width: 10%; }
.col-per { width: 9%; }
.col-each { width: 27%; }
.col-total { width: 28%; }
.col-per, .per-cell { padding-left: 24px; }
#catTable th { white-space: normal; line-height: 1.3; vertical-align: bottom; }
.cat-name { font-weight: 600; }
/* bills set aside for a particular category (shown under the category name) */
  .pins { margin-top: 5px; font-weight: 400; }
.pins .pins-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; color: var(--muted); display: block; margin-bottom: 2px; }
.pins .pill { font-size: .78rem; padding: 1px 7px; }
.pin-note { color: var(--warn); font-size: .76rem; display: block; margin-top: 3px; }
/* the "set aside" list: Category | Bill | Pieces | remove */
  .pin-table { table-layout: fixed; }
.pin-table th, .pin-table td { vertical-align: middle; }
.pin-table .c-cat { width: 46%; }
.pin-table .c-bill { width: 22%; }
.pin-table .c-pcs { width: 18%; }
.pin-table .c-x { width: 14%; }
.btn-del { background: none; color: var(--warn); font-size: 1.05rem; cursor: pointer; border: none; padding: 4px 8px; }
.pin-empty { color: var(--muted); font-size: .9rem; padding: 6px 0 2px; }
.per-cell .amt { display: block; font-weight: 700; color: var(--blue); }
/* the column that matters when stuffing: everything that goes into this envelope */
  .col-total, .total-cell { background: var(--accent-soft); }
.col-total { color: var(--accent-dark); }
/* bills written in one line: [1 × 100] + [1 × 50] */
  .inl { display: flex; flex-wrap: wrap; gap: 4px 5px; align-items: center; }
.pill { display: inline-block; font-weight: 700; font-size: .88rem; padding: 2px 9px; border-radius: 7px; color: #fff; white-space: nowrap; line-height: 1.5; }
.pill small { font-weight: 600; opacity: .85; margin: 0 2px; }
.plus { color: var(--muted); font-weight: 700; }
.each-cell .pill { font-size: .8rem; padding: 1px 7px; opacity: .9; }
.have-cell .bl .cnt, .have-cell .bl .dv { color: var(--accent-dark); }
/* one line per portion when the portions of a category differ */
  .env { display: grid; grid-template-columns: 4.6em 1fr; gap: 6px; align-items: center; padding: 3px 0; }
.env + .env { border-top: 1px dashed var(--line); }
.env .env-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.env.is-short .env-label { color: var(--warn); }
.flag { color: var(--warn); font-size: .8rem; display: block; margin-top: 2px; font-weight: 600; }
.ok-tag { color: var(--accent-dark); font-size: .8rem; display: block; margin-top: 2px; font-weight: 600; }
.none { color: var(--muted); font-style: italic; }
/* summary table */
  .sum-table th, .sum-table td { text-align: right; vertical-align: middle; }
.sum-table th:first-child, .sum-table td:first-child { text-align: left; }
.sum-table .bill { font-weight: 800; color: #fff; padding: 3px 10px; border-radius: 8px; display: inline-block; min-width: 4.2em; text-align: center; }
.sum-table .short { color: var(--warn); font-weight: 700; }
.sum-table .left { color: var(--accent-dark); font-weight: 700; }
.sum-table .dim { color: var(--muted); }
.sum-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.info-notice { background: var(--blue-soft); border-color: #cddbe8; color: var(--blue); }
.need-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 12px; }
.need-box { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; text-align: center; background: #fff; }
.need-box .head { font-size: 1.2rem; font-weight: 800; color: #fff; padding: 8px; line-height: 1; }
.need-box .head small { font-size: .7rem; font-weight: 700; opacity: .85; }
.need-box .qty { font-size: 1.8rem; font-weight: 800; padding: 10px 8px 2px; line-height: 1; }
.need-box .label { font-size: .75rem; color: var(--muted); padding-bottom: 12px; text-transform: uppercase; letter-spacing: .03em; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #2f5573; }
.btn-ghost { background: var(--blue-soft); color: var(--blue); }
.btn-ghost:hover { background: #d8e4ee; }
/* MOBILE: each envelope row becomes one compact card
       [ Category name                    ]
       [ Budget   ][ Weeks   ][ Per week  ]
       [ Total bills for this envelope    ]
       [ Bills per week (reference)       ]   */
  @media (max-width: 640px) {
    #catTable, #catTable tbody { display: block; width: 100%; }
    #catTable thead { display: none; }
    #catTable tr {
      display: grid; grid-template-columns: 1fr 1fr 1fr; column-gap: 12px; row-gap: 10px; align-items: start;
      grid-template-areas: "cat cat cat" "amt wk per" "tot tot tot" "each each each";
      border: 1px solid var(--line); border-radius: 12px;
      padding: 12px 14px 14px; margin-bottom: 12px; background: #fff;
    }
    #catTable td { display: flex; flex-direction: column; gap: 3px; border: none; padding: 0; text-align: left; }
    #catTable td::before {
      content: attr(data-label);
      font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
      color: var(--muted); font-weight: 700;
    }
    #catTable td:nth-child(1) { grid-area: cat; font-size: 1.05rem; }
    #catTable td:nth-child(1)::before { display: none; }
    #catTable td:nth-child(2) { grid-area: amt; font-weight: 600; }
    #catTable td:nth-child(3) { grid-area: wk; font-weight: 600; }
    #catTable td:nth-child(4) { grid-area: per; }
    #catTable td:nth-child(5) { grid-area: each; }
    #catTable td:nth-child(6) { grid-area: tot; border-radius: 8px; padding: 8px 10px; }
    #catTable td.total-cell::before { color: var(--accent-dark); }
    .col-per, .per-cell { padding-left: 0; }
    .per-cell .amt { font-size: 1rem; }
    .bl { line-height: 1.45; }
    .env { grid-template-columns: 4.6em 1fr; }
    .sum-table { font-size: .85rem; }
    .sum-table th, .sum-table td { padding: 8px 5px; }

    .pin-table, .pin-table tbody { display: block; width: 100%; }
    .pin-table thead { display: none; }
    .pin-table tr {
      display: grid; grid-template-columns: 1fr 1fr 34px; column-gap: 10px; row-gap: 8px; align-items: end;
      grid-template-areas: "cat cat cat" "bill pcs del";
      border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: #fff;
    }
    .pin-table td { display: flex; flex-direction: column; gap: 3px; border: none; padding: 0; }
    .pin-table td::before {
      content: attr(data-label); font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
      color: var(--muted); font-weight: 700;
    }
    .pin-table td:nth-child(1) { grid-area: cat; }
    .pin-table td:nth-child(2) { grid-area: bill; }
    .pin-table td:nth-child(3) { grid-area: pcs; }
    .pin-table td:nth-child(4) { grid-area: del; }
    .pin-table td:nth-child(4)::before { display: none; }
  }
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    header { background: #fff; color: var(--ink); border-bottom: 2px solid var(--line); }
    .card { box-shadow: none; break-inside: avoid; }
    table { table-layout: auto; }
    th, td { padding: 6px 8px; }
    .col-per, .per-cell { padding-left: 8px; }
    input { border: none !important; outline: none !important; -webkit-appearance: none; appearance: none; }
    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
    .sum-table .bill { color: var(--ink) !important; background: none !important; padding: 0; }
  }
