/* Compact invoice page + date/time pickers. Loaded after site.css. */

/* ======================= compact invoice page ======================= */
.container.wide { max-width: 80rem; }
.page-head.tight { margin-bottom: .6rem; }
.page-head.tight h1 { font-size: 1.2rem; }

.card-title { font-weight: 700; color: var(--brand-dark); margin-bottom: .6rem; font-size: .98rem; }
.card-title.spaced { margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.subtitle { font-weight: 600; margin: .8rem 0 .4rem; font-size: .92rem; }

/* row 1: the ticket as one strip */
.strip { padding: .7rem 1rem .4rem; margin-bottom: .8rem; }
.strip-title { font-weight: 700; color: var(--brand-dark); font-size: .9rem; margin-bottom: .35rem; }
.ticket-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0 .7rem; }
.ticket-grid .field, .mini-grid .field { margin-bottom: .5rem; }
.ticket-grid .field label, .mini-grid .field label { font-size: .8rem; font-weight: 600; margin-bottom: .15rem; color: var(--muted); }
.ticket-grid input[type=text], .mini-grid input[type=text], .mini-grid select, .picker input[type=text] {
  width: 100%; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: #fff;
}
.ticket-grid input:focus, .mini-grid input:focus, .mini-grid select:focus, .picker input:focus,
table.lines input:focus, table.lines select:focus, table.installments input:focus {
  outline: 2px solid var(--brand); border-color: var(--brand);
}
.ticket-grid .static { padding: .4rem .1rem; }

/* row 2: products on the right, customer + payment on the left */
.invoice-cols { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: .8rem; align-items: start; }
.col-main, .col-side { padding: .9rem 1rem; }
table.lines { margin-bottom: .6rem; }
table.lines th, table.lines td, table.installments th, table.installments td { padding: .35rem .4rem; }
table.lines th { font-size: .82rem; }
table.lines .qty-cell { min-width: 7.5rem; white-space: nowrap; }
table.lines .qty-cell .line-qty { width: 5.2rem; display: inline-block; }
table.lines .line-unit { margin-inline-start: .3rem; }
table.lines td:nth-child(1) { min-width: 9.5rem; }
table.lines .line-info { min-width: 7rem; }
table.installments td:nth-child(2) { min-width: 8.2rem; }
table.installments td:nth-child(3) { min-width: 7rem; }
table.installments th:first-child, table.installments td:first-child { width: 1.8rem; text-align: center; }

.icon-btn { width: 1.7rem; height: 1.7rem; border: 1px solid var(--line); background: #fff; border-radius: 50%; color: var(--danger); cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 0; }
.icon-btn:hover { background: #fdecea; border-color: var(--danger); }

.col-main .totals { margin-top: .7rem; justify-content: space-between; }

/* side panel */
.picker { position: relative; }
.picker .results { position: absolute; z-index: 20; inset-inline: 0; margin: .15rem 0 0; box-shadow: 0 8px 20px rgba(0,0,0,.15); }
.mini-actions { display: flex; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }
.chip { display: flex; justify-content: space-between; border-radius: var(--radius); padding: .4rem .6rem; margin-bottom: .3rem; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .6rem; margin-top: .6rem; }
.mini-grid .wide-field { grid-column: 1 / -1; }
.seg { margin-bottom: .6rem; }
.seg-item { flex: 1; text-align: center; padding: .4rem .6rem; font-size: .92rem; }
.status-line { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .5rem; padding: .45rem .7rem; background: #f7f1e8; border-radius: var(--radius); font-size: .88rem; }
.status-line strong.ok { color: var(--ok); }
.status-line strong.bad { color: var(--danger); }
.split { margin-inline-start: auto; }
.col-side .actions { margin-top: .5rem; }
.note-box { margin-top: .8rem; }
.note-box summary { cursor: pointer; color: var(--brand-dark); font-size: .9rem; }
.note-box textarea { width: 100%; margin-top: .4rem; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; resize: vertical; }
.submit-row { display: flex; gap: .6rem; align-items: center; margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.submit-row .btn.big { flex: 1; padding: .65rem 1rem; }
.alert.small { padding: .4rem .7rem; font-size: .88rem; margin: .5rem 0 0; }

@media (max-width: 1000px) {
  .ticket-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .invoice-cols { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .ticket-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ======================= date / time pickers ======================= */
.has-picker { background-repeat: no-repeat; background-position: left .55rem center; background-size: 1rem; padding-left: 2rem !important; cursor: pointer; }
.has-picker.is-date { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a5a2b' stroke-width='2' stroke-linecap='round'><rect x='3' y='5' width='18' height='16' rx='2'/><path d='M3 10h18M8 3v4M16 3v4'/></svg>"); }
.has-picker.is-time { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a5a2b' stroke-width='2' stroke-linecap='round'><circle cx='12' cy='12' r='9'/><path d='M12 7v5l3 2'/></svg>"); }

.picker-pop {
  position: absolute; z-index: 1000; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.22); padding: .6rem; direction: rtl; font-size: .9rem; color: var(--text);
}
.picker-pop button { font: inherit; }
.calendar { width: 17rem; }
.cal-head { display: flex; gap: .3rem; align-items: center; margin-bottom: .45rem; }
.cal-head select { flex: 1; min-width: 0; padding: .25rem .3rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; font: inherit; }
.cal-nav { width: 1.9rem; height: 1.9rem; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0; }
.cal-nav:hover { background: #f1e6d8; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd { text-align: center; color: var(--muted); font-size: .78rem; padding: .15rem 0; }
.cal-wd.off, .cal-day.off { color: var(--danger); }
.cal-day { height: 2rem; border: 0; background: none; border-radius: 6px; cursor: pointer; padding: 0; }
.cal-day:hover:not(:disabled) { background: #f1e6d8; }
.cal-day.today { box-shadow: inset 0 0 0 1px var(--brand); }
.cal-day.selected, .cal-day.selected:hover { background: var(--brand); color: #fff; }
.cal-day:disabled { color: #c4bfb6; cursor: not-allowed; text-decoration: line-through; }
.cal-foot { display: flex; justify-content: space-between; margin-top: .45rem; padding-top: .4rem; border-top: 1px solid var(--line); }
.cal-link { background: none; border: 0; color: var(--brand-dark); cursor: pointer; padding: .1rem .2rem; }
.cal-link:disabled { color: #c4bfb6; cursor: not-allowed; }
.timepop { width: 10.5rem; }
.time-labels, .time-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.time-labels { text-align: center; color: var(--muted); font-size: .78rem; margin-bottom: .2rem; }
.time-col { max-height: 11.5rem; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.time-item { display: block; width: 100%; border: 0; background: none; padding: .22rem 0; cursor: pointer; font-variant-numeric: tabular-nums; }
.time-item:hover { background: #f1e6d8; }
.time-item.selected { background: var(--brand); color: #fff; }

@media print { .picker-pop { display: none !important; } }

/* tweaks after the first review */
.ticket-grid { grid-template-columns: 1.05fr 1.25fr .85fr 1fr 1.1fr 1fr 1fr .8fr; }
.has-picker { padding-left: 1.75rem !important; background-position: left .45rem center; background-size: .9rem; }
.col-main #credit-section .card-title.spaced { margin-top: .9rem; }

.bad-text { color: var(--danger); font-size: .8rem; }

/* ======================= collecting money ======================= */
.stats { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: .9rem; }
.stat { flex: 1 1 8rem; background: #f7f1e8; border-radius: var(--radius); padding: .55rem .85rem; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .82rem; }
.stat strong { font-size: 1.25rem; line-height: 1.4; }
.stat small { color: var(--muted); }
.stat.danger { background: #fbe9e7; }
.stat.danger strong { color: var(--danger); }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
tr.cancelled td .badge { text-decoration: none; }
.big-input { font-size: 1.2rem; font-weight: 600; }
.cancel-box summary { cursor: pointer; color: var(--danger); font-size: .85rem; }
.cancel-box form { display: flex; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; }
.cancel-box input[type=text] { flex: 1; min-width: 9rem; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; }

/* ======================= reports and dashboard ======================= */
h3 { margin-top: 1.2rem; }
.stats a.stat.link, .report-links a.card.link { text-decoration: none; color: inherit; }
.stats a.stat.link:hover { box-shadow: 0 0 0 2px var(--brand); }
.report-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.report-links a.card.link { display: flex; flex-direction: column; gap: .2rem; padding: .8rem 1rem; }
.report-links a.card.link:hover { border-color: var(--brand); }
.report-links a.card.link span { color: var(--muted); font-size: .85rem; }

.range-bar { margin-bottom: 1rem; padding: .7rem 1rem; }
.range-bar .quick { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.chip-link { padding: .2rem .8rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; background: #fff; font-size: .88rem; }
.chip-link:hover, .chip-link.on { border-color: var(--brand); background: #f4e9dc; }
.range-fields { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: flex-end; }
.range-fields .field { margin-bottom: 0; }
.range-fields input[type=text] { padding: .4rem .55rem; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: #fff; width: 9.5rem; }

table.grid tfoot td { background: #efe9df; font-weight: 700; border-top: 2px solid var(--line); }
.chart-col { width: 22%; min-width: 7rem; }
.hbar { display: flex; height: .7rem; min-width: 6rem; background: #f1ebe2; border-radius: 4px; overflow: hidden; }
.hbar span { display: block; height: 100%; }
.hbar .cash, .legend.cash, .stack .cash { background: var(--brand); }
.hbar .credit, .legend.credit, .stack .credit { background: #d9b48a; }
.legend { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; vertical-align: middle; margin-inline: .2rem; }

.bars { display: flex; align-items: flex-end; gap: .45rem; height: 11rem; padding-top: .3rem; }
.barcol { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.barcol small { color: var(--muted); margin-top: .25rem; }
.stack { width: 100%; max-width: 2.4rem; display: flex; flex-direction: column; border-radius: 4px 4px 0 0; overflow: hidden; min-height: 2px; }
.stack span { display: block; min-height: 0; }

@media print { .range-bar, .report-links { display: none; } }

/* ======================= dashboard (calm version) ======================= */
.dash-hero { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 1rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem 1.4rem; }
.kpi .label { color: var(--muted); font-size: .92rem; margin-bottom: .25rem; }
.kpi .value { font-size: 2.1rem; font-weight: 700; line-height: 1.35; }
.kpi .unit { font-size: .9rem; font-weight: 400; color: var(--muted); margin-inline-start: .4rem; }
.kpi .sub { color: var(--muted); font-size: .9rem; margin-top: .15rem; }

.attention ul { list-style: none; margin: .3rem 0 0; padding: 0; }
.attention li { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; padding: .6rem 0; border-top: 1px solid #efeae0; }
.attention li:first-child { border-top: 0; }
.attention li a { color: var(--text); text-decoration: none; }
.attention li a:hover { color: var(--brand-dark); text-decoration: underline; }
.attention .value-sm { font-weight: 700; font-size: 1.05rem; }
.attention small { color: var(--muted); }
.attention li.alert-row a, .attention li.alert-row .value-sm { color: var(--danger); }
.attention .ok-note { color: var(--ok); margin-top: .4rem; }

.dash-main { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1rem; margin-bottom: 1rem; align-items: start; }
.dash-main .bars { height: 12rem; }

.summary { margin: 0; }
.summary > div { display: flex; justify-content: space-between; align-items: baseline; padding: .55rem 0; border-top: 1px solid #efeae0; }
.summary > div:first-child { border-top: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 500; }
.summary .main dt { color: var(--text); font-weight: 700; }
.summary .main dd { font-size: 1.25rem; font-weight: 700; }
.summary small { color: var(--muted); font-weight: 400; font-size: .8rem; }

.quicklinks { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1.1rem; padding: .8rem 0 .4rem; }
.quicklinks a { color: var(--brand-dark); text-decoration: none; }
.quicklinks a:hover { text-decoration: underline; }

@media (max-width: 1000px) { .dash-hero, .dash-main { grid-template-columns: 1fr; } }

/* ---- change log and invoice history ---- */
.history ul { list-style: none; margin: 0 0 .6rem; padding: 0; }
.history li { display: flex; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history .when { flex: 0 0 9.5rem; color: var(--muted); font-size: .88rem; }
.details { margin-top: .25rem; color: var(--muted); font-size: .88rem; white-space: pre-line; }
table.audit td { vertical-align: top; }
.nowrap { white-space: nowrap; }
@media (max-width: 640px) { .history li { flex-direction: column; gap: .15rem; } .history .when { flex-basis: auto; } }

/* ---- phone number already registered (invoice form) ---- */
#phone-exists { grid-column: 1 / -1; }
#phone-exists ul { list-style: none; margin: .4rem 0 0; padding: 0; }
#phone-exists li { display: flex; align-items: center; gap: .6rem; padding: .15rem 0; }
