/* Tokens from docs/UI-PALETTE.md. Warm surface, navy chrome. */
:root {
  --surface:          #FFFFFF;
  --surface-sunken:   #EEECE1;
  --surface-input:    #FFDCB9;
  --surface-header:   #FAC090;
  --chrome:           #1F497D;
  --chrome-accent:    #4F81BD;
  --on-chrome:        #FFFFFF;
  --status-ok:        #C6EFCE;
  --status-pending:   #FFF2BD;
  --status-alert:     #EA2D00;
  --status-muted:     #D8D8D8;
  --text:             #000000;
  --text-muted:       #5A5A5A;
  /* The application bar's height, so a sticky column header knows where to stop. A one-line
     bar is about this; `_nav.html` overwrites it with the real measurement on load and on
     resize, because the links wrap on a narrow screen and the number is then wrong by half. */
  --bar-h:            38px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--surface);
}

header.top {
  background: var(--chrome);
  color: var(--on-chrome);
  padding: 9px 20px;
  display: flex;
  align-items: baseline;
  gap: 18px;
  /* Stays put while the page scrolls. The screens that need it most are the long ones - a
     booking with 28 article rows, an order with 17 lines - where the navigation would otherwise
     be a scroll to the top away. `sticky` rather than `fixed`: it keeps its place in the flow,
     so nothing below needs a compensating margin. It breaks if any ancestor ever gets
     `overflow` other than visible; `body` is its only ancestor here. */
  position: sticky;
  top: 0;
  z-index: 20;
}
header.top b { font-size: 16px; }
header.top span { color: #CFE0EF; font-size: 13px; margin-left: auto; }
header.top nav { display: flex; gap: 2px; }
header.top nav a { color: #CFE0EF; text-decoration: none; padding: 4px 12px; font-size: 13px; }
header.top nav a:hover { background: var(--chrome-accent); color: var(--on-chrome); }
header.top nav a.here { background: var(--chrome-accent); color: var(--on-chrome);
                        font-weight: 600; }
header.top a.who { color: var(--on-chrome); }
header.top form.logout { display: inline; margin-left: 8px; }
header.top form.logout button { padding: 1px 10px; font-size: 12px; background: var(--chrome-accent); }

/* Вход */
main.login { max-width: 360px; margin: 60px auto; }
main.login form { display: flex; flex-direction: column; gap: 10px; }
main.login label { display: flex; flex-direction: column; gap: 3px; font-size: 12px;
                   color: var(--text-muted); }
main.login input { font: inherit; padding: 5px 8px; background: var(--surface-input);
                   border: 1px solid var(--status-muted); }

main { padding: 20px; max-width: 720px; }
h1 { font-size: 18px; margin: 0 0 14px; }

table.facts { border-collapse: collapse; }
table.facts th,
table.facts td { border: 1px solid var(--status-muted); padding: 5px 12px; text-align: left; }
table.facts th { background: var(--surface-header); font-weight: 600; white-space: nowrap; }
table.facts td { background: var(--surface-sunken); }

p.note { margin-top: 16px; color: var(--text-muted); max-width: 60ch; }
code { background: var(--surface-input); padding: 0 4px; }

p.alert { color: var(--status-alert); font-weight: 600; }
pre.alert-detail { background: var(--surface-sunken); padding: 10px; overflow-x: auto; }

/* Календар. The week grid itself is FullCalendar's; this is the chrome around it. */
main.wide { max-width: none; }

form.week-bar { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; margin-bottom: 10px; }
form.week-bar label { display: flex; flex-direction: column; gap: 3px; font-size: 12px;
                      color: var(--text-muted); }
form.week-bar select { font: inherit; padding: 3px 6px; background: var(--surface-input);
                       border: 1px solid var(--status-muted); }

.flag { color: var(--status-alert); font-size: 12px; font-weight: 600; }

/* Заявка */
p.back { margin: 0 0 10px; }
p.back a { color: var(--chrome); text-decoration: none; }
h2 { font-size: 15px; margin: 22px 0 8px; }
p.none { color: var(--text-muted); }

table.lines { border-collapse: collapse; width: 100%; max-width: 720px; }
table.lines th,
table.lines td { border: 1px solid var(--status-muted); padding: 4px 8px; text-align: left; }
table.lines thead th,
table.lines tfoot th { background: var(--surface-header); }
/* The column names follow the rows down. Below the application bar, never under it — hence
   `--bar-h`, which the bar measures on itself. `z-index` 5 sits under the bar's 20 and above
   the `.ps-*` calendar chrome's 4, so the three layers have one order and not three opinions.
   The background must stay opaque or the rows show through as they pass beneath. */
table.lines thead th { position: sticky; top: var(--bar-h); z-index: 5; }
table.lines td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.lines tfoot td { background: var(--surface-header); text-align: right; font-weight: 600; }
ul.performers { margin: 0; padding-left: 20px; }

/* The booking form. Editable cells look editable; read-only ones do not. */
table.facts input,
table.facts textarea { font: inherit; padding: 2px 5px; background: var(--surface-input);
                       border: 1px solid var(--status-muted); }
table.facts input[type=number] { width: 6ch; }
table.facts td.ro { background: var(--surface-sunken); color: var(--text-muted); }
button { font: inherit; padding: 5px 18px; background: var(--chrome); color: var(--on-chrome);
         border: 0; cursor: pointer; }
button:hover { background: var(--chrome-accent); }
p.saved { background: var(--status-ok); padding: 6px 10px; margin: 0 0 12px; font-weight: 600; }

/* FullCalendar 7 wears this application's palette, applied through its *Class options.
   Only skeleton.css is vendored; the stock themes key off hashed class names with no
   importable mapping, so dressing it here keeps one palette instead of two. */
.ps-event { background: var(--chrome-accent); border: 1px solid var(--chrome);
            color: var(--on-chrome); border-radius: 2px; padding: 1px 3px;
            font-size: 12px; line-height: 1.25; text-decoration: none; overflow: hidden; }
.ps-event:hover { background: var(--chrome); }
.ps-event.cancelled { background: var(--status-muted); border-color: #9a9a9a;
                      color: var(--text-muted); text-decoration: line-through; }
.ps-day-header { background: var(--surface-header); font-weight: 600; padding: 4px 0; }
.ps-toolbar { margin-bottom: 10px; gap: 8px; }
.ps-button { font: inherit; padding: 4px 12px; background: var(--chrome);
             color: var(--on-chrome); border: 1px solid var(--chrome); cursor: pointer; }
.ps-button:hover { background: var(--chrome-accent); }
a.new-booking { align-self: end; padding: 4px 12px; background: var(--status-ok);
                border: 1px solid #7ec98f; color: var(--text); text-decoration: none; }
a.new-booking:hover { background: #b2e6bf; }
form.cancel-bar { display: flex; gap: 10px; align-items: end; margin: 18px 0 0; }
form.cancel-bar label { display: flex; flex-direction: column; gap: 3px; font-size: 12px;
                        color: var(--text-muted); }
form.cancel-bar input { font: inherit; padding: 3px 6px; background: var(--surface-input);
                        border: 1px solid var(--status-muted); }
button.danger { background: var(--status-alert); }
button.danger:hover { background: #b52300; }
table.lines input { font: inherit; padding: 1px 4px; background: var(--surface-input);
                    border: 1px solid var(--status-muted); }
table.lines input[type=number] { width: 8ch; text-align: right; }
td.row-actions { white-space: nowrap; display: flex; gap: 4px; }
td.row-actions button { padding: 2px 8px; font-size: 12px; }
td.none { color: var(--text-muted); }
tr.mismatch td, tr.mismatch th { background: var(--status-pending); }
form.add-line { display: flex; gap: 10px; align-items: end; margin-top: 12px; flex-wrap: wrap; }
form.add-line label { display: flex; flex-direction: column; gap: 3px; font-size: 12px;
                      color: var(--text-muted); }
form.add-line input { font: inherit; padding: 3px 6px; background: var(--surface-input);
                      border: 1px solid var(--status-muted); }
span.hint, span.posted { font-size: 12px; color: var(--text-muted); }
p.acted-by { display: flex; gap: 10px; align-items: end; margin: 0 0 12px; }
p.acted-by label { display: flex; flex-direction: column; gap: 3px; font-size: 12px;
                   color: var(--text-muted); font-weight: 600; }
p.acted-by input { font: inherit; padding: 3px 6px; background: var(--surface-input);
                   border: 2px solid var(--chrome-accent); }
span.posted { color: var(--chrome); font-weight: 600; }
table.facts select { font: inherit; padding: 2px 5px; background: var(--surface-input);
                     border: 1px solid var(--status-muted); }
table.facts input[readonly], table.facts select:disabled { background: var(--status-muted);
                                                           color: var(--text-muted); }

/* The Заявка sheet: the workbook's own reading order, in a label/value grid. */
table.sheet { border-collapse: collapse; margin-bottom: 12px; }
table.sheet th, table.sheet td { border: 1px solid var(--status-muted); padding: 3px 8px;
                                 text-align: left; vertical-align: middle; }
table.sheet th { background: var(--surface-header); font-weight: 600; white-space: nowrap;
                 font-size: 12px; }
table.sheet td { background: var(--surface-sunken); }
table.sheet td.ro { background: var(--surface-sunken); color: var(--text-muted);
                    font-variant-numeric: tabular-nums; }
table.sheet input, table.sheet textarea, table.sheet select {
    font: inherit; padding: 2px 5px; background: var(--surface-input);
    border: 1px solid var(--status-muted); }
table.sheet input[type=number] { width: 8ch; text-align: right; }
table.sheet input[readonly], table.sheet select:disabled {
    background: var(--status-muted); color: var(--text-muted); }
/* Остатък: the booking is settled at 0.00, and anything else is money still moving. */
b.owing { color: var(--status-alert); }

/* КАСА: Запис, изравнителен запис and Приключване sit on one line, so each is its own form. */
form.inline { display: inline; }
form.inline button { margin-left: 8px; }
button:disabled { background: var(--status-muted); color: var(--text-muted); cursor: not-allowed; }
h1 .hall, h1 .number, h1 .state { font-weight: 400; font-size: 13px; color: var(--text-muted);
                                  margin-left: 10px; }
h1 .number { font-weight: 600; color: var(--chrome); }
h1 .state { background: var(--status-pending); padding: 1px 6px; }

/* No spinner on number inputs. The arrows step money by one cent, which is never the edit
   anyone wants, and they eat width in a dense grid. Numeric validation and the mobile numeric
   keyboard both survive - only the widget goes. */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

table.sheet textarea.wide { width: 100%; min-width: 60ch; }
details.history { margin-top: 18px; border: 1px solid var(--status-muted);
                  background: var(--surface-sunken); padding: 8px 12px; max-width: 100ch; }
details.history summary { cursor: pointer; font-weight: 600; color: var(--chrome); }
details.history pre { white-space: pre-wrap; word-break: break-word; max-height: 22em;
                      overflow-y: auto; background: var(--surface); padding: 8px;
                      border: 1px solid var(--status-muted); margin: 10px 0; font-size: 12px; }

/* Настройки. The catalogue-maintenance screen: an index of tables, then one table at a time. */
table.settings-index td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.settings-index a { color: var(--chrome); text-decoration: none; font-weight: 600; }
table.settings-index a:hover { text-decoration: underline; }
a.clear-search { align-self: center; color: var(--text-muted); font-size: 12px; }
p.pager { display: flex; gap: 14px; align-items: baseline; margin: 10px 0 0; }
p.pager a { color: var(--chrome); text-decoration: none; }
p.pager span { color: var(--text-muted); font-size: 12px; }
table.lines a { color: var(--chrome); text-decoration: none; }
form.add-line select { font: inherit; padding: 3px 6px; background: var(--surface-input);
                       border: 1px solid var(--status-muted); }

/* Вз.Обороти. The subtotal rows a GROUPING SETS query produces: `Общо за месец` sits inside
   the table body, so it needs the header fill that `tfoot` gets for free. */
table.lines tr.subtotal th,
table.lines tr.subtotal td { background: var(--surface-header); font-weight: 600; }
table.lines tr.subtotal th { text-align: right; }

/* Сп.Поръчки. A cancelled order stays on the report and is greyed rather than hidden -
   BUSINESS-RULES §12 makes cancellation a status, and a status you cannot see is not one. */
table.lines tr.cancelled-row td { color: var(--text-muted); text-decoration: line-through; }
table.lines tr.cancelled-row td a { color: var(--text-muted); }

/* Сп.КАСА и Сп.КАСА 2. A count that the denomination ladder cannot value is not a zero and
   must not look like one - schema/011 leaves January 2026 uncovered on purpose, and 30 real
   sessions land there. `td.num` right-aligns it as a number; this un-numbers it. */
table.lines td.num.unvalued { color: var(--text-muted); font-style: italic;
                              text-align: center; }
table.lines td.num.owing { color: var(--status-alert); font-weight: 600; }

/* Печат. REPORTS.md, "Printing is a workflow, not a button": every legacy sheet sets
   `BlackAndWhite = True` and then previews, and the printers are mono. So the chrome goes, the
   fills go, and the table keeps its rules - which is what the sheet's own print setup does. */
@media print {
  header.top, form.week-bar, p.pager { display: none; }
  main, main.wide { padding: 0; max-width: none; }
  body { background: #FFF; color: #000; font-size: 10px; }
  table.lines { max-width: none; }
  table.lines thead th { position: static; background: #FFF; border-bottom: 2px solid #000; }
  table.lines tfoot th, table.lines tfoot td, table.lines tr.subtotal th,
  table.lines tr.subtotal td { background: #FFF; border-top: 2px solid #000; }
  table.lines th, table.lines td { border-color: #999; }
  table.lines a { color: #000; text-decoration: none; }
  table.lines thead { display: table-header-group; }
  p.note { color: #000; max-width: none; }
}
/* Кухня. One narrow table per party rather than one wide table with its identity columns
   blanked, which is what `case when "Данни" = 1 then "Заявка" else '' end` is doing in the
   legacy query. A block is meant to be read standing up, so it stays narrow, and the sticky
   column header that `table.lines` gives every other report would stack one per block. */
table.lines.kitchen-block { max-width: 560px; margin-bottom: 14px; page-break-inside: avoid; }
table.lines.kitchen-block thead th { position: static; text-align: left; }
table.lines.kitchen-block thead th a { color: var(--chrome); }

/* Стат's twelve month buttons. REPORTS.md gives them to this screen and Вз.Обороти only. */
p.pager.months { display: flex; flex-wrap: wrap; gap: 4px; }
p.pager.months a { font-size: 12px; }
