/* Page styles on top of the design system (tokens.css + bundle.css): layout only. */
h2 { margin: 0 0 var(--space-4); font-size: 18px; line-height: 24px; font-weight: 600; }
h3 { margin: 0 0 var(--space-2); font-size: 15px; line-height: 20px; font-weight: 600; }
p { margin: 0 0 var(--space-2); }
.small { font-size: 12px; line-height: 16px; }
.wordmark { text-decoration: none; }
a.wordmark:hover { text-decoration: none; }
a.sync { text-decoration: none; }

.content > * + * { margin-top: var(--space-6); }
.section { margin-top: var(--space-8); }
.section .dl { margin-top: var(--space-4); }
.stack { display: grid; gap: var(--space-4); }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-6); }
.note { white-space: pre-wrap; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); max-width: 720px; margin-bottom: var(--space-4); }
.form-grid .wide { grid-column: 1 / -1; }
.btn-row form { display: contents; }
.notice ul { margin: var(--space-2) 0 0; padding-left: var(--space-4); }
#history .stack { max-width: 720px; margin-bottom: var(--space-4); }

.auth { max-width: 380px; margin: 12vh auto; padding: 0 var(--space-4); display: grid; gap: var(--space-6); }
.auth .qr { background: #fff; padding: var(--space-2); }
.auth .secret { overflow-wrap: anywhere; font-size: 13px; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}
.breadcrumb b { font-weight: 400; }
.check { display: flex; flex-direction: row; align-items: center; gap: var(--space-2); }

/* Orders tinted by WooCommerce status. Muted, so text keeps 4.5:1 in both themes; the status is also written in the row. */
:root, [data-theme="light"] { --row-completed: #e6f0e3; --row-processing: #f8e8d4; --row-sent: #e3edf7; --row-failed: #f7eec6; --row-courier: #e0eff0; }
[data-theme="dark"] { --row-completed: #1f3025; --row-processing: #3a2c1c; --row-sent: #1c2b3a; --row-failed: #34311b; --row-courier: #19302f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --row-completed: #1f3025; --row-processing: #3a2c1c; --row-sent: #1c2b3a; --row-failed: #34311b; --row-courier: #19302f; }
}
.data-table--tinted th:first-child, .data-table--tinted td:first-child { padding-left: var(--space-3); }
.data-table--tinted th:last-child, .data-table--tinted td:last-child { padding-right: var(--space-3); }
.data-table tr.row--completed { background: var(--row-completed); }
.data-table tr.row--processing { background: var(--row-processing); }
.data-table tr.row--sent { background: var(--row-sent); }
.data-table tr.row--failed { background: var(--row-failed); }
/* Stage beats Woo status here: packed and waiting for the courier, a step before «sent». */
.data-table tr.row--courier { background: var(--row-courier); }
.data-table--tinted tbody tr:hover { background: var(--soft); }

/* Settings tabs: plain links, the current one underlined in accent (same idea as the sidebar marker). */
.tabs { display: flex; flex-wrap: wrap; gap: var(--space-6); border-bottom: 1px solid var(--line); }
.tabs a { margin-bottom: -1px; padding: var(--space-2) 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* Today: each metric links to the filtered list. */
a.metric--link { color: inherit; }
a.metric--link:hover { text-decoration: none; }
a.metric--link:hover .metric__label { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* API keys: masked text, not type=password, so browsers don't take the form for a login. */
.input--secret { -webkit-text-security: disc; }

/* Orders pager. */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); font-variant-numeric: tabular-nums; }
.pager__current { font-weight: 600; border-bottom: 2px solid var(--accent); }

/* Apaczka: a value that looks unusual but is allowed (warning, not error). */
.field--warning .input { border-color: var(--warning); }
.field__warning { color: var(--warning); font-size: 12px; line-height: 16px; }
.phone-warning { color: var(--warning); font-weight: 600; }

/* Apaczka: service picker */
.svc-list { display: flex; flex-direction: column; border: 1px solid var(--line); }
.svc { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); cursor: pointer; }
.svc + .svc { border-top: 1px solid var(--line); }
.svc:hover, .svc:has(input:checked) { background: var(--soft); }
.svc__name { flex: 1; min-width: 0; }
.svc__price { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.svc-more { margin-top: var(--space-2); }
.svc-more > summary { cursor: pointer; }
.confirm > summary { list-style: none; display: inline-flex; }
.confirm > summary::-webkit-details-marker { display: none; }
.confirm__body { margin-top: var(--space-2); }

/* «Сьогодні»: a parcel too long with the courier. Colour plus the «!» text, never colour alone. */
.data-table tr.row--late td:first-child { border-left: 3px solid var(--warning); }
.data-table .late { color: var(--warning); font-weight: 500; }

/* Needs attention: one red dot, reasons in red text. */
.attn-dot { display: inline-block; width: 8px; height: 8px; margin-right: var(--space-2); border-radius: 50%; background: var(--error); vertical-align: middle; }
.attn-text { color: var(--error); }
.sidebar__count--alert { color: var(--error); font-weight: 600; }

/* Bell in the header: system notices; lit while some are unread. */
.bell { position: relative; display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; }
.bell--lit { color: var(--error); font-weight: 600; }
.bell__count { font-size: 12px; font-variant-numeric: tabular-nums; }
.notice-row--unread td { background: var(--error-soft); font-weight: 600; }
.pre-line { white-space: pre-line; }

/* «Сьогодні» is a dashboard: compact metrics and groups, meant to fit one screen. */
.metrics--compact .metric { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.metrics--compact .metric__value { font-size: 24px; line-height: 28px; }
.today-group h2 { margin-bottom: var(--space-2); }
.today-group .data-table td { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.today-group .data-table tbody tr:first-child td { border-top: 1px solid var(--line); }

/* Pop-up rendered by the server (no JS): Brevo template check. Cancel is a plain link. */
.popup { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: var(--space-6, 32px) var(--space-4, 16px); background: rgb(0 0 0 / 0.45); overflow-y: auto; }
.popup__panel { width: min(720px, 100%); padding: var(--space-5, 24px); background: var(--surface); color: var(--ink); border: 1px solid var(--line); }

/* Stage change confirmation */
.confirm-actions { display: flex; gap: var(--space-3); margin-top: var(--space-3); }

/* Order card: one screen. Head row, stages | next action, then three columns:
   items + history, client + emails, parcel. Narrower: parcel stays on top. */
.oc-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); }
.oc-title { font-size: 24px; line-height: 30px; }
.oc-meta { color: var(--muted); font-size: 13px; }
.oc-meta b { color: var(--ink); font-weight: 500; }
.oc-tools { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.oc-menu { position: relative; }
.oc-menu > summary { list-style: none; }
.oc-menu > summary::-webkit-details-marker { display: none; }
.oc-menu__list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 220px; padding: var(--space-1) 0; background: var(--surface); border: 1px solid var(--line); }
.oc-menu__list p { margin: 0; padding: 6px var(--space-3) 2px; font-size: 11px; line-height: 16px; color: var(--muted); }
.oc-menu__list button { display: block; width: 100%; padding: 6px var(--space-3); border: 0; background: none; text-align: left; font-size: 13px; cursor: pointer; }
.oc-menu__list button:hover { background: var(--soft); }
.oc-menu__list button[disabled] { font-weight: 600; cursor: default; background: none; }
.content > .oc-attn, .content > .notice, .content > p.small { margin-top: var(--space-3); }
.oc-attn { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--error); background: var(--error-soft); font-size: 13px; line-height: 18px; }
.oc-attn b { color: var(--error); }

.content > .oc-stages { margin-top: var(--space-4); }
.oc-stages { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: var(--space-4); }
.oc-stages--solo { grid-template-columns: minmax(0, 560px); }
.oc-track { display: flex; align-items: center; padding: var(--space-4) var(--space-6) var(--space-3) var(--space-4); border: 1px solid var(--line); background: var(--surface); }
.oc-stepper { flex: 1; display: flex; align-items: center; margin: 0; padding: 0 0 30px; list-style: none; }
.oc-stepper li { position: relative; flex: 1; display: flex; align-items: center; }
.oc-stepper li:last-child { flex: none; }
.oc-stepper li::after { content: ""; flex: 1; height: 1px; margin: 0 4px; background: var(--line); }
.oc-stepper li:last-child::after { display: none; }
.oc-stepper li.done::after { height: 2px; background: var(--accent); }
.oc-node, .oc-chip { position: relative; display: inline-grid; place-items: center; flex: none; color: var(--muted); }
.oc-node { width: 32px; height: 32px; border: 1.5px solid var(--line); background: var(--surface); }
.oc-node svg { width: 16px; height: 16px; }
.done .oc-node { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.cur .oc-node { border: 2px solid var(--accent); background: var(--soft); color: var(--accent); }
.oc-cap { position: absolute; top: 38px; left: 0; white-space: nowrap; font-size: 12px; line-height: 16px; }
.oc-cap b { font-weight: 600; }
.oc-cap time { margin-left: 6px; font: 11px/16px var(--font-mono); color: var(--muted); }
.oc-cap--end { left: auto; right: 0; }
.oc-chip { width: 22px; height: 22px; margin-left: 6px; vertical-align: middle; border: 1px solid var(--line); }
.oc-chip svg { width: 13px; height: 13px; }
/* Hover/focus label for icon-only marks. */
.oc-node::after, .oc-chip::after { content: attr(data-tip); position: absolute; left: 50%; z-index: 10; transform: translateX(-50%); padding: 4px 8px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 400; line-height: 16px; white-space: nowrap; pointer-events: none; opacity: 0; }
.oc-node::after { top: calc(100% + 6px); }
.oc-chip::after { bottom: calc(100% + 6px); }
.oc-node:hover::after, .oc-node:focus-visible::after, .oc-chip:hover::after, .oc-chip:focus-visible::after { opacity: 1; }
.oc-next { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--soft); border: 1px solid var(--soft); }
.oc-next p { margin: 0; }
.oc-next--confirm { background: var(--warning-soft); border-color: var(--warning); }
.oc-next--confirm .next-action__label { color: var(--warning); }
.oc-next ul { margin: 2px 0 0; padding-left: var(--space-4); font-size: 13px; line-height: 18px; }
.oc-next__btns { display: flex; flex: none; gap: var(--space-2); }
.oc-next--confirm { flex-direction: column; align-items: stretch; }

.oc-cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, .9fr); gap: var(--space-4); margin-top: var(--space-4); align-items: start; }
.oc-card { padding: var(--space-4); border: 1px solid var(--line); background: var(--surface); }
.oc-card + .oc-card { margin-top: var(--space-4); }
.oc-card h2 { display: flex; align-items: baseline; gap: var(--space-2); margin: 0 0 var(--space-3); font-size: 15px; line-height: 20px; }
.oc-aside { margin-left: auto; font-size: 12px; font-weight: 400; }
.oc-label { margin: 0; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.oc-gap { margin-top: var(--space-3); }
.oc-strong { font-weight: 600; }
.oc-r { text-align: right; white-space: nowrap; }
.oc-sub { display: block; font-size: 12px; line-height: 16px; color: var(--muted); }
.oc-warn { color: var(--warning); }
.oc-wide { width: 100%; }
.oc-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.oc-item:first-of-type { padding-top: 0; }
.oc-item__name { font-weight: 500; }
.oc-dl { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 4px var(--space-3); margin: var(--space-3) 0 0; font-size: 13px; line-height: 18px; }
.oc-dl dt { color: var(--muted); }
.oc-dl dd { margin: 0; overflow-wrap: anywhere; }
.oc-addr { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--line); font-size: 13px; line-height: 18px; }
.oc-addr p { margin: 2px 0 0; }
.oc-others { margin-top: var(--space-1); }
.oc-mail { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 18px; }
.oc-mail:last-child { border-bottom: 0; }
.oc-mail .confirm { margin-top: 6px; }
.oc-tick { font-family: var(--font-mono); color: var(--accent); }
.oc-tick--err { color: var(--error); }
.oc-tick--wait { color: var(--muted); }
.oc-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.oc-status::before { content: ""; width: 8px; height: 8px; background: var(--stage-transit); }
.oc-btns { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: var(--space-4); }
.oc-btns > .btn--primary { grid-column: 1 / -1; }
.oc-btns form { display: contents; }
.oc-btns .confirm .btn { width: 100%; }
.oc-btns > form:last-child > .btn { grid-column: 1 / -1; }
.oc-btns details[open] { grid-column: 1 / -1; }
.oc-note { display: flex; gap: var(--space-2); }
.oc-note .input { flex: 1; height: var(--control-h-sm); font-size: 13px; }
.oc-tl { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.oc-tl li { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: var(--space-3); padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 18px; }
.oc-tl li:last-child { border-bottom: 0; }
.oc-tl time { display: block; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.oc-kind { display: block; font: 10px/14px var(--font-mono); letter-spacing: .04em; color: var(--muted); }
.oc-tl .timeline__text { overflow-wrap: anywhere; }
.oc-tl li[data-kind="note"] .timeline__text { white-space: pre-wrap; }
.oc-tl li[data-kind="refund"] .timeline__text { color: var(--warning); }
.oc-more { margin-top: var(--space-2); font-size: 13px; }
.oc-more > summary { cursor: pointer; color: var(--accent); }
.oc-link { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-2); margin-top: var(--space-2); }

@media (max-width: 1280px) {
  .oc-stages { grid-template-columns: minmax(0, 1fr) 400px; }
  .oc-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .oc-c1 { grid-column: 1; grid-row: 1 / span 2; }
  .oc-c3 { grid-column: 2; grid-row: 1; }
  .oc-c2 { grid-column: 2; grid-row: 2; }
}
@media (max-width: 1000px) { .oc-stages { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .oc-tools { margin-left: 0; }
  .oc-node { width: 28px; height: 28px; }
  .oc-stepper li::after { margin: 0 2px; }
  .oc-stepper { position: relative; }
  .oc-stepper li { position: static; }
  .oc-cap, .oc-cap--end { left: 0; right: auto; }
  .oc-next { flex-wrap: wrap; }
  .oc-cols { display: flex; flex-direction: column; align-items: stretch; }
  .oc-c1, .oc-c2 { display: contents; }
  .oc-card + .oc-card { margin-top: 0; }
  .oc-others td:nth-child(2) { display: none; }
  .oc-o1 { order: 1; } .oc-o2 { order: 2; } .oc-o3 { order: 3; } .oc-o4 { order: 4; } .oc-o5 { order: 5; }
}
