/* Розділ «Заощадження»: лише те, чого немає у style.css і style-pult.css */

.gate { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.back-hub { text-decoration: none; }
.topbar .back-hub:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.load-error { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 0; }

/* ----- Місяці ----- */
.months { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.month {
  flex: 0 0 auto; min-width: 150px; display: grid; gap: 2px; text-align: left; cursor: pointer; font: inherit;
  padding: 12px 16px; border-radius: 18px; border: 0; background: #fff; color: var(--text);
  box-shadow: 0 1px 2px rgba(21, 23, 31, .05); transition: box-shadow .15s, transform .12s;
}
.month:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(21, 23, 31, .09); }
.month span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.month strong { font-family: var(--num); font-weight: 800; font-size: 17px; white-space: nowrap; }
.month[aria-pressed="true"] { background: var(--night); color: #fff; }
.month[aria-pressed="true"] span { color: var(--lime); }
.month:focus-visible, .tile:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ----- Плитки підсумків ----- */
.tiles { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.6fr; gap: 12px; }
.tile { border-radius: var(--r-card); padding: 18px 20px; background: #fff; display: grid; gap: 4px; align-content: start; border: 0; text-align: left; font: inherit; color: var(--text); box-shadow: 0 1px 2px rgba(21, 23, 31, .04); min-width: 0; }
.tile .t-name { font-size: 13px; font-weight: 700; color: var(--muted); }
.tile .t-num { font-family: var(--num); font-weight: 800; font-size: 30px; line-height: 1.15; letter-spacing: -.02em; }
.tile .t-sub { font-size: 12.5px; color: var(--muted); }
.tile.main { background: var(--lime); }
.tile.main .t-name, .tile.main .t-sub { color: rgba(13, 20, 36, .72); }
.tile.main .t-num { font-size: 36px; }
button.tile { cursor: pointer; background: #fff2db; }
button.tile:hover { box-shadow: 0 8px 22px rgba(21, 23, 31, .09); }
.top-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 9px; }
.top-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: 13px; }
.top-list .t-item { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.top-list .t-val { font-family: var(--num); font-weight: 700; white-space: nowrap; }
.top-list .bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: #eef0f6; overflow: hidden; }
.top-list .bar i { display: block; height: 100%; background: var(--teal); border-radius: 3px; }

.f-type { width: 210px; background: #fff; }

/* ----- Таблиця ----- */
.sv-table { min-width: 940px; }
.sv-table tbody tr { cursor: pointer; }
.sv-table td { padding: 11px 14px; }
.sv-table .c-item { max-width: 420px; }
.sv-table .c-item strong { font-weight: 600; }
.sv-table .c-date { white-space: nowrap; }
.sv-table .c-eco strong { font-size: 15.5px; color: var(--ok); }
.sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.was { color: var(--faint); text-decoration: line-through; font-weight: 500; }
.row-open { font: inherit; background: none; border: 0; padding: 0; color: inherit; text-align: left; cursor: pointer; }
.row-open:hover { color: var(--teal-d); }
.row-open:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
.table-wrap tfoot td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 800; }

.chip.t-bargain { background: #e3f3f2; color: #0b6b70; }
.chip.t-analog { background: #ece6ff; color: #5a3fb8; }
.chip.t-supplier { background: #e2f3ff; color: #12679b; }
.chip.t-repair { background: #fff0e2; color: #a04c0c; }
.chip.t-own { background: #eef8c9; color: #55660a; }
.chip.t-other { background: #eef0f6; color: #4c5468; }
.chip.s-confirmed { background: #e3f4ea; color: #17714a; }
.chip.s-pending { background: #fff2db; color: #8a5a00; }
.chip.s-rejected { background: #fdecea; color: #b42318; }
.chip.moved { background: #eef0f6; color: #4c5468; margin-top: 3px; }

.outside h3 { margin: 4px 0 8px; font-size: 13px; color: var(--muted); }
.outside ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.outside button { width: 100%; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; text-align: left; font: inherit; font-size: 13.5px; color: var(--muted); background: transparent; border: 1px dashed var(--glass-line-hi); border-radius: 14px; padding: 10px 14px; cursor: pointer; }
.outside button:hover { background: #fff; }
.outside .o-item { flex: 1 1 240px; color: var(--text); font-weight: 600; }

/* ----- Картки ----- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.cards > .empty { grid-column: 1 / -1; background: #fff; border-radius: var(--r-card); }
.sv-card { background: #fff; border-radius: var(--r-card); padding: 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 1px 2px rgba(21, 23, 31, .05); min-width: 0; }
.sv-card .head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.sv-card h3 { margin: 0; font-size: 15.5px; line-height: 1.35; overflow-wrap: anywhere; }
.sv-card .big { font-family: var(--num); font-weight: 800; font-size: 24px; }
.sv-card .prices { font-variant-numeric: tabular-nums; }
.sv-card .comment { font-size: 13.5px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.sv-card .links { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.sv-card .links a { color: var(--teal-d); }
.sv-card .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }
.sv-card .acts .btn { flex: 1 1 130px; min-width: 0; padding: 0 10px; }
.sv-card .acts .btn.edit { flex-basis: 100%; }
.swap { display: grid; gap: 4px; font-size: 13.5px; }
.swap .from { color: var(--faint); text-decoration: line-through; }
.pending-total { font-family: var(--num); font-size: 20px; }
.rejected summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: 8px 0; }
.rejected .cards { margin-top: 8px; }

/* ----- Форма ----- */
.sv-dlg { width: min(860px, calc(100vw - 24px)); }
.sv-dlg h3 { margin: 20px 0 8px; font-size: 14px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pos { display: grid; gap: 10px; margin-bottom: 10px; padding: 12px; border: 1px solid var(--glass-line); border-radius: 14px; }
.pos label, .pos .price > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.pos-top { display: flex; gap: 8px; align-items: flex-end; }
.pos-top .l-item { flex: 1 1 auto; min-width: 0; }
.pos-top .l-qty { flex: 0 0 90px; }
.pos .icon-btn { height: var(--h-ctl); flex: none; }
.pos-prices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(110px, auto); gap: 8px 14px; align-items: end; }
.pos .price { display: grid; gap: 6px; min-width: 0; }
.pos .price select { flex: 0 0 112px; width: 112px; }
.pos .p-eco { height: var(--h-ctl); display: flex; align-items: center; justify-content: flex-end; font-family: var(--num); font-weight: 800; font-size: 16px; white-space: nowrap; }
.pos .p-eco.bad { color: var(--warn); }
.p-recalc { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 10px; border: 0; border-radius: 12px; background: #fff4df; min-width: 0; }
.p-recalc legend { float: left; width: 100%; grid-column: 1 / -1; padding: 0; font-size: 12.5px; font-weight: 700; color: #7a4f00; }
.pos .p-recalc label { display: flex; gap: 9px; align-items: flex-start; background: #fff; border: 1px solid #f0d28f; border-radius: 11px; padding: 9px 11px; cursor: pointer; color: var(--text); font-weight: 500; }
.pos .p-recalc label:has(input:checked) { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.p-recalc input { margin-top: 1px; }
.p-recalc label > span { display: grid; min-width: 0; }
.p-recalc strong { font-family: var(--num); font-size: 16px; }
.p-recalc small { color: var(--muted); font-variant-numeric: tabular-nums; }
.status-pick { border: 0; padding: 0; margin: 18px 0 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.status-pick legend { font-size: 13px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.status-pick label { flex: 1 1 200px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--glass-line); border-radius: 14px; padding: 11px 13px; cursor: pointer; }
.status-pick label:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.status-pick span { display: grid; }
.status-pick small { color: var(--muted); font-weight: 500; }
#conf-wrap { max-width: 280px; }
.total-line { margin-top: 16px; padding: 12px 16px; border-radius: 14px; background: #f4fbd3; font-weight: 600; }
.total-line strong { font-family: var(--num); font-size: 20px; margin-left: 6px; }
.warnbox { margin-top: 12px; background: #fff4df; border: 1px solid #f0d28f; color: #7a4f00; border-radius: var(--r-ctl); padding: 9px 13px; font-size: 14px; }
.confirm-dlg form > label { display: block; margin-top: 12px; }

.export-opts { display: grid; gap: 8px; margin: 16px 0 10px; }
.export-opts .btn { height: auto; min-height: 52px; justify-content: space-between; white-space: normal; text-align: left; padding: 10px 16px; }
.export-opts small { color: var(--muted); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--night); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-pop); z-index: 50; max-width: calc(100vw - 32px); }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .topnav { grid-template-columns: repeat(3, 1fr); }
  .toast { bottom: 96px; }
}
@media (max-width: 700px) {
  .grid-3 { grid-template-columns: 1fr; }
  .pos-prices { grid-template-columns: 1fr; }
  .p-recalc { grid-template-columns: 1fr; }
  .pos .p-eco { justify-content: flex-start; height: auto; }
  .pos-top { flex-wrap: wrap; }
  .pos-top .l-item { flex-basis: 100%; }
  .pos-top .l-qty { flex: 1 1 0; }
}
@media (max-width: 640px) {
  .tiles .tile.main, .tiles .tile.top { grid-column: 1 / -1; }
  .tile { padding: 14px; }
  .tile:not(.main) .t-num { font-size: 22px; }
  .f-type { width: auto; flex: 1 1 0; }

  .sv-table { min-width: 0; }
  .sv-table thead { display: none; }
  .sv-table, .sv-table tbody { display: block; }
  #table-wrap { background: none; box-shadow: none; overflow: visible; }
  .sv-table tbody { display: grid; gap: 10px; }
  .sv-table tr {
    display: grid; grid-template-columns: 1fr auto; background: #fff; border-radius: 16px; padding: 12px 14px;
    grid-template-areas: "date eco" "item item" "type type" "price qty" "ev ev";
  }
  .sv-table td { display: block; border: 0; padding: 3px 0; }
  .sv-table .c-date { grid-area: date; }
  .sv-table .c-eco { grid-area: eco; }
  .sv-table .c-item { grid-area: item; max-width: none; font-size: 15px; }
  .sv-table .c-type { grid-area: type; }
  .sv-table .c-price { grid-area: price; text-align: left; }
  .sv-table .c-qty { grid-area: qty; align-self: end; }
  .sv-table .c-ev { grid-area: ev; }
  .cards { grid-template-columns: 1fr; }
}
