:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #202c26;
  background: #f4f6f3;
  --line: #dce4de;
  --muted: #4e6256;
  --accent: #25563d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--accent); }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
button, .button, input, select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: inherit;
  background: #fff;
}
button, .button { padding: 8px 14px; cursor: pointer; }
button:hover, .button:hover { background: #eef4ef; }
.button { display: inline-flex; align-items: center; text-decoration: none; }
.button[aria-disabled="true"] { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select { width: 100%; min-width: 0; padding: 8px 10px; }
label { display: grid; gap: 5px; min-width: 0; font-size: .875rem; color: var(--muted); }
label > * { color: #202c26; }

.masthead {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px max(24px, calc((100% - 1392px) / 2));
  background: #21382d;
  color: #fff;
}
.brand { font-size: 1.1rem; font-weight: 750; }
#demo { font-size: .8rem; color: #e4efe6; }
main { padding: 28px 24px; max-width: 1440px; margin: auto; }
.heading, .detail-heading, .results { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.heading { flex-wrap: wrap; }
.order-heading { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.order-heading label { min-width: 116px; }
h1 { font-size: 2rem; line-height: 1.12; }
#organization { margin-top: 7px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.filters { display: grid; grid-template-columns: minmax(185px, 1.6fr) repeat(5, minmax(0, 1fr)); gap: 10px; padding: 14px; margin-top: 20px; }
.date-ranges { grid-column: 1 / -1; }
.date-ranges fieldset { margin: 0; }
.date-range-row { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-bottom: 8px; }
.date-range-row label { min-width: 116px; }
#date-range-error { margin-top: 8px; }
.results { margin: 18px 0 8px; color: var(--muted); font-size: .875rem; }
.workspace { display: flex; gap: 14px; align-items: flex-start; }
.sheet { flex: 1; min-width: 0; overflow: auto; }
table { width: 100%; min-width: 660px; border-collapse: collapse; text-align: left; font-size: .875rem; }
thead { background: #eef3ee; color: #3e5949; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:last-child, td:last-child { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover, tbody tr:focus-within { background: #f6faf6; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.detail { flex: 0 0 310px; padding: 15px; overflow-wrap: anywhere; }
.detail h2 { font-size: 1.2rem; }
#close { padding: 0 10px; min-height: 36px; font-size: 1.4rem; }
#bouquet { margin-top: 5px; font-weight: 650; }
dl { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(0, 1.2fr); gap: 8px 10px; font-size: .875rem; }
dt { color: var(--muted); }
dd { margin: 0; white-space: pre-wrap; }
#message, #empty { padding: 12px 0; color: var(--muted); }
#empty { text-align: center; }
.login { display: grid; gap: 14px; width: min(100%, 390px); padding: 20px; }
.login h1 { font-size: 1.4rem; }

@media (max-width: 1050px) {
  .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .search { grid-column: span 2; }
}
@media (max-width: 900px) {
  .workspace { display: grid; }
  .detail { grid-row: 1; }
}
@media (max-width: 560px) {
  .masthead, main { padding-left: 12px; padding-right: 12px; }
  .heading { align-items: flex-start; flex-direction: column; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results { flex-wrap: wrap; }
}

.sheet table { width: max-content; min-width: 100%; }
.sheet th, .sheet td { border-right: 1px solid var(--line); text-align: left; }
.sheet th { min-width: 52px; white-space: nowrap; }
.sheet td { max-width: 300px; white-space: normal; overflow-wrap: anywhere; }
.sheet th:first-child, .sheet td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f5f8f4;
}
.sheet td.row-controls { white-space: nowrap; }
.column-bouquet, .column-address { width: 230px; }
.column-paymentText, .column-customerText, .column-recipientText { width: 175px; }
.drag-handle { display: inline-block; padding: 6px; margin-left: 2px; color: var(--muted); cursor: grab; }
tr[data-drop="before"] td { box-shadow: inset 0 3px var(--accent); }
tr[data-drop="after"] td { box-shadow: inset 0 -3px var(--accent); }
@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}
.drag-handle { touch-action: none; user-select: none; }
tr.dragging .drag-handle { cursor: grabbing; }

.sheet th:first-child, .sheet td:first-child { min-width: 34px; width: 34px; padding: 0; text-align: center; }
.sheet td { min-width: 95px; padding: 6px 10px; }
.sheet td.row-controls { min-width: 34px; }
.drag-handle { margin: 0; width: 100%; font-size: 1.45rem; line-height: 1; padding: 10px 3px; }
.sheet .queue { min-width: 40px; width: 40px; padding: 0 6px; text-align: center; }
.queue input[type="checkbox"], #visibility input[type="checkbox"] { width: 16px; min-height: auto; height: 16px; accent-color: var(--accent); padding: 0; vertical-align: middle; }
.sheet select, .sheet input:not([type="checkbox"]), .sheet textarea {
  min-width: 105px;
  width: 100%;
  min-height: 34px;
  padding: 4px 6px;
  background: transparent;
}
.sheet select { padding-right: 22px; }
.sheet input:not([type="checkbox"]):focus, .sheet select:focus, .sheet textarea:focus { background: #fff; }
.sheet textarea { resize: vertical; }
.column-time { width: 160px; }
.column-comment { width: 210px; }
.sheet .column-source, .sheet .column-payment_method { min-width: 170px; }
.sheet .column-amount { min-width: 110px; }
.sheet .column-last_event { min-width: 175px; }
.cell-button { padding: 3px 1px; min-height: 32px; border: 0; color: var(--accent); background: transparent; text-decoration: underline; text-underline-offset: 2px; text-align: left; }
.column-bouquet[data-bouquet-status] {
  background: linear-gradient(90deg, var(--bouquet-accent) 4px, var(--bouquet-bg) 4px);
}
.column-bouquet[data-bouquet-status="assembling"] { --bouquet-bg: #ffd271; --bouquet-accent: #bb7400; --bouquet-ink: #523300; }
.column-bouquet[data-bouquet-status="ready"] { --bouquet-bg: #9ee3a5; --bouquet-accent: #248a37; --bouquet-ink: #194525; }
.column-bouquet[data-bouquet-status="picked_up"] { --bouquet-bg: #a9cbff; --bouquet-accent: #326dce; --bouquet-ink: #193969; }
.column-bouquet[data-bouquet-status="delivered"] { --bouquet-bg: #84ded3; --bouquet-accent: #098778; --bouquet-ink: #11463e; }
.column-bouquet[data-bouquet-status="issue"] { --bouquet-bg: #ff9a9f; --bouquet-accent: #cf293b; --bouquet-ink: #66111e; }
.cell-button.bouquet-status {
  display: block;
  padding: 0;
  min-height: 24px;
  color: var(--bouquet-ink);
  font-size: .75rem;
  font-weight: 750;
  text-decoration: none;
}
.cell-button.bouquet-status:hover { background: transparent; text-decoration: underline; }
dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100% - 32px); padding: 22px; border: 1px solid var(--line); border-radius: 12px; color: inherit; }
dialog::backdrop { background: #1c322a80; }
dialog h2 { font-size: 1.2rem; }
#settings-scope, #settings-error, #log-message { margin: 10px 0; color: var(--muted); }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 8px; margin: 12px 0; padding: 12px; }
legend { font-weight: 650; }
#visibility { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
#visibility label { display: flex; align-items: center; gap: 6px; }
details { margin-top: 6px; }
summary { cursor: pointer; padding: 5px 0; }
textarea { display: block; width: 100%; resize: vertical; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.custom-column { display: grid; gap: 8px; margin: 0 0 10px; padding: 10px; background: #f5f8f4; border-radius: 6px; }
#log-events { padding-left: 22px; }
#log-events li { padding: 7px 0; }
#log-events time, #log-events small { display: block; color: var(--muted); font-size: .8rem; }
#staff-activity-source { max-width: 230px; }
#staff-activity label, #staff-activity-status { margin-top: 10px; }
#staff-activity-events { list-style: none; padding: 0; }
#staff-activity-events li { display: grid; gap: 3px; padding: 10px 0; border-bottom: 1px solid var(--line); }
#staff-activity-events time, #staff-activity-events small { color: var(--muted); font-size: .85rem; }
#cash-shift { width: min(420px, calc(100% - 24px)); }
#cash-shift-form { width: 100%; padding: 0; }
#cash-shift-error { color: var(--accent); }
.cash-report-filters, #cash-report-status { margin: 12px 0; }
.cash-report-table { overflow-x: auto; }
.cash-report-table th, .cash-report-table td { padding: 8px; text-align: start; }
.cash-report-table time { display: block; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.schedule-filters, #schedule-message { margin: 14px 0; }
.schedule-month-controls { align-items: end; }
#schedule-cities { display: grid; gap: 16px; }
.schedule-city { padding: 16px; min-width: 0; }
.schedule-updated { margin-top: 5px; color: var(--muted); font-size: .8rem; }
.schedule-weeks { overflow-x: auto; }
.schedule-weeks table { width: 100%; min-width: 850px; margin-top: 16px; table-layout: fixed; }
.schedule-weeks :is(td, th) { vertical-align: top; text-align: start; padding: 7px; border: 1px solid var(--line); white-space: normal; }
.schedule-weeks th:first-child { position: sticky; left: 0; width: 122px; background: #f8f6f7; }
.schedule-weeks .schedule-outside-month { color: var(--muted); background: #f7f5f6; }
.schedule-weeks .schedule-today { background: var(--accent); color: #fff; }
.schedule-weeks thead small { display: block; font-weight: 400; }
.schedule-city ul { list-style: none; margin: 0; padding-left: 0; }
.schedule-city li + li { margin-top: 4px; }
.schedule-shift { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; border-radius: 6px; background: #edf4ee; overflow-wrap: anywhere; }
.schedule-shift[data-role="manager"] { background: #f6e8ed; }
.schedule-shift > span { width: 100%; font-weight: 650; }
.schedule-shift[data-mine] { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
button.schedule-shift { min-height: 0; width: 100%; border-color: transparent; text-align: left; }
button.schedule-shift:hover { border-color: var(--accent); }
.schedule-add-cell { width: 100%; min-height: 34px; padding: 2px 6px; border-style: dashed; color: var(--accent); }
.schedule-add-cell:hover, .schedule-add-cell:focus-visible { background: #f6e8ed; border-color: var(--accent); }
.schedule-city .detail-heading button { min-height: 32px; padding: 4px 8px; font-size: .8rem; }
.schedule-shift small { color: var(--muted); }
#schedule-edit-fields, #schedule-swap-fields { display: grid; gap: 9px; }
#schedule-edit-context, #schedule-edit-error { margin-top: 10px; }
#schedule-edit-error { color: var(--accent); }

:root {
  --line: #eee3e5;
  --ink: #35282c;
  --muted: #6e555e;
  --accent: #8b3e54;
  --soft: #f5e7eb;
  --wash: #fffaf8;
  --header: #f5e7eb;
  --stripe: #9c4c62;
  background: var(--wash);
  color: var(--ink);
}
body[data-brand="taganrog"] {
  --line: #d3e4e9;
  --ink: #2f3a55;
  --muted: #4d5d75;
  --accent: #864658;
  --soft: #e7f1f4;
  --wash: #f7fbfc;
  --header: #c2dde3;
  --stripe: #d66d87;
  background: var(--wash);
  color: var(--ink);
}
body { min-height: 100vh; }
.masthead {
  min-height: 88px;
  background: var(--header);
  border-top: 4px solid var(--stripe);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.brand { display: flex; align-items: center; gap: 18px; }
#brand-logo { display: block; object-fit: contain; width: 165px; height: 52px; }
[data-brand="taganrog"] #brand-logo { width: 75px; height: 68px; }
#brand-context { display: grid; gap: 4px; border-left: 1px solid var(--line); padding-left: 16px; }
#workspace-name { font-size: 1rem; line-height: 1.2; }
#brand-city { font-size: .85rem; color: var(--muted); font-weight: 550; }
[data-brand="taganrog"] #brand-context { border-color: #a6c4ce; }
.popup-menu { position: relative; flex: none; margin: 0; }
.popup-menu > summary { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; list-style: none; }
.popup-menu > summary::-webkit-details-marker { display: none; }
.account-menu-icon { display: grid; gap: 4px; width: 18px; }
.account-menu-icon > span { height: 2px; border-radius: 1px; background: currentColor; }
.table-menu-icon { font-size: 22px; line-height: 1; }
.popup-menu-items {
  position: absolute;
  z-index: 5;
  inset: calc(100% + 6px) 0 auto auto;
  display: grid;
  min-width: max-content;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 6px 18px #0002;
}
.popup-menu-items :is(button, a) { border-color: transparent; text-align: start; }
@media (max-width: 560px) {
  .masthead { flex-wrap: wrap; gap: 10px; }
  .brand { flex: 1; min-width: 0; gap: 10px; }
  #brand-logo { width: 116px; flex-shrink: 0; }
  #brand-context { padding-left: 10px; }
  .heading > .actions { width: 100%; }
  #table-actions { margin-inline-start: auto; }
}
#demo { color: var(--muted); }
h1 { font-family: Georgia, serif; font-size: clamp(2rem, 3.2vw, 2.75rem); font-weight: 500; }
[data-brand="taganrog"] h1 { font-family: inherit; font-weight: 700; }
.heading #refresh { background: var(--accent); border-color: var(--accent); color: #fff; }
.heading #refresh:hover { filter: brightness(.92); }
button:hover, .button:hover, tbody tr:hover, tbody tr:focus-within { background: var(--wash); }
label > * { color: var(--ink); }
thead, .sheet th:first-child, .sheet td:first-child { background: var(--soft); color: var(--ink); }
.panel { box-shadow: 0 3px 12px #37283208; }
.closed-orders { display: grid; gap: 9px; margin-top: 16px; }
.order-group { margin: 0; min-width: 0; }
.order-group summary {
  display: grid;
  grid-template-columns: 1fr auto 16px;
  align-items: center;
  gap: 10px;
  min-height: 49px;
  padding: 10px 15px;
  list-style: none;
  font-weight: 650;
}
.order-group summary::-webkit-details-marker { display: none; }
.order-group summary::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  justify-self: center;
}
.order-group[open] summary::after { transform: rotate(225deg); }
.order-group summary span {
  padding: 2px 9px;
  border-radius: 16px;
  color: var(--muted);
  background: var(--soft);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}
.order-group[open] .sheet { border-top: 1px solid var(--line); }
.group-empty { color: var(--muted); padding: 13px 15px; font-size: .875rem; }
.column-shipment_status { white-space: nowrap; }
[data-shipment-state] { font-weight: 750; }
[data-shipment-state="not-posted"] { background: #ff9a9f; color: #66111e; }
[data-shipment-state="posted"] { background: #9ee3a5; color: #194525; }
.payment-cash-receipt { display: block; width: fit-content; margin-top: 5px; padding: 3px 6px; border-radius: 5px; font-size: .75rem; font-weight: 700; }
.payment-cash-receipt[data-cash-receipt-state="pending"] { background: #ffd271; color: #523300; }
.payment-cash-receipt[data-cash-receipt-state="confirmed"] { min-height: 28px; background: #9ee3a5; color: #194525; }
#order-cash-receipt-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
#order-cash-receipt-fields dd { margin: 0; overflow-wrap: anywhere; }
.custom-column { background: var(--wash); }

.deal-link { display: block; width: fit-content; margin: 0 0 3px; font-size: .78rem; white-space: nowrap; }
#reference, #telegram-photo { display: grid; gap: 9px; border-top: 1px solid var(--line); padding-top: 13px; margin-top: 15px; }
#reference h3, #telegram-photo h3 { margin: 0; font-size: 1rem; }
#reference-empty, #reference-expiry, #reference-message, #telegram-photo-link, #telegram-photo-message { font-size: .82rem; color: var(--muted); }
#telegram-photo-form { display: grid; gap: 7px; }
#telegram-photo-form button, #reference-remove { justify-self: start; min-height: 36px; }
#reference-preview { max-height: 220px; max-width: 100%; object-fit: contain; justify-self: start; border-radius: 7px; }
#create-order { background: var(--accent); color: #fff; border-color: var(--accent); }
#create-order:hover { filter: brightness(.92); }
#create-order-city { margin: 5px 0 14px; color: var(--muted); }
.quick-order-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-order-form .form-wide { grid-column: 1 / -1; }
#save-new-order { justify-self: start; }
#create-order-error { color: #8d2228; }
#create-order-error:empty { display: none; }
@media (max-width: 560px) {
  .quick-order-form { grid-template-columns: 1fr; }
}

.sheet th:first-child, .sheet td.row-controls { min-width: 122px; }
.sheet td.row-controls .drag-handle { width: 22px; padding-inline: 2px; vertical-align: middle; }
.delivery-row-button { min-width: 84px; min-height: 32px; padding: 4px 7px; font-size: .75rem; color: var(--accent); }

.dashboard-filters { flex-wrap: wrap; align-items: end; margin-block: 14px; }
.dashboard-metrics, .dashboard-goals { display: grid; gap: 12px; }
.dashboard-metrics { grid-template-columns: repeat(auto-fit, minmax(156px, 1fr)); margin-block: 0 14px; }
.dashboard-metrics > div { padding: 16px; }
.dashboard-metrics dt { color: var(--muted); }
.dashboard-metrics dd { margin: 6px 0 0; font-size: clamp(1.35rem, 3vw, 2rem); font-weight: 700; color: var(--accent); }
.dashboard-section { padding: 16px; margin-bottom: 14px; }
.dashboard-section h2 { margin: 0 0 12px; }
.dashboard-section progress { width: 100%; height: 14px; accent-color: var(--accent); }
.dashboard-table { overflow-x: auto; }
.dashboard-table table { width: 100%; border-collapse: collapse; }
.dashboard-table :is(th, td) { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dashboard-table th { text-align: left; }
.dashboard-goals { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.dashboard-goals p { margin-block: 0 6px; }
#delivery-copy-dialog textarea { margin: 10px 0 8px; }
#copy-delivery-status, #delivery-photo-status { color: var(--muted); font-size: .82rem; margin: 7px 0; }
#copy-delivery-status:empty, #delivery-photo-status:empty { display: none; }
#delivery-photo-preview { display: block; max-width: 100%; max-height: 330px; border-radius: 8px; margin: 8px 0; }
