/* Exchange office. One stylesheet; the Content-Security-Policy forbids inline styles.
   Widths: desktop above 1000 px, tablet 641–1000 px, phone up to 640 px. Design audit 2026-11-08. */
:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1c2430; --muted: #596377; --line: #dfe3ea; --field: #858e9e;
  --accent: #17695c; --accent-ink: #fff; --danger: #b3261e; --warn-bg: #fff5de; --warn-ink: #7a5300;
  --ok-bg: #e2f4ee; --ok-ink: #125245; --err-bg: #fdeceb; --info-bg: #e8ebf0; --info-ink: #3e4757;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 "Noto Sans Armenian", "Segoe UI", Arial, sans-serif; }
a { color: var(--accent); }
.skip { position: absolute; left: 8px; top: -60px; z-index: 10; background: var(--panel); padding: 8px 12px; border-radius: 6px; }
.skip:focus { top: 8px; }

/* ── Header: brand and logout on one line, the menu on its own line with the current page marked ── */
header.top { background: var(--panel); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; padding: 8px 20px 0; }
header.top .brand { margin-right: auto; }
header.top form { margin: 0; }
header.top .account { display: flex; align-items: center; gap: 4px; color: var(--muted); }
header.top .account a { color: var(--muted); padding: 10px 4px; text-decoration: none; }
header.top .account a[aria-current="page"] { color: var(--accent); font-weight: 600; }
header.top .account a::after { content: " ·"; color: var(--muted); }
ul.codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 28px; padding: 0; list-style: none; font-size: 18px; }
ol.steps { padding-left: 20px; }
ol.steps li { margin-bottom: 10px; }
ol.steps .qr { margin: 10px 0; }
.spaced-top { margin-top: 12px; }
header.top nav { order: 3; flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 0; margin: 2px 0 0 -6px; }
header.top nav a { text-decoration: none; color: var(--text); padding: 9px 6px; font-size: 15px; border-bottom: 3px solid transparent; }
header.top nav a:hover { color: var(--accent); }
header.top nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1120px; margin: 0 auto; padding: 22px 20px 60px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h1 .badge { font-size: 14px; padding: 2px 10px; vertical-align: middle; }
h2 { font-size: 18px; margin: 0 0 12px; }
h2.flush { margin: 0; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 14px; min-height: 44px; }
.head h1 { margin: 0; }
.head form { margin: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 18px; }
.panel.narrow { max-width: 560px; }
.panel.flush-table { padding: 0; overflow: hidden; }
.panel.flush-table .table-wrap { border-radius: 8px; }
.pad { padding: 16px 18px 0; }
p.pad { padding: 16px 18px; margin: 0; }

/* ── Stat tiles ── */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 14px; }
.stat .value { font-size: 22px; font-weight: 650; margin-top: 2px; }
.stat .sub { color: var(--muted); font-size: 14px; }
.stat.key { border-color: var(--accent); background: var(--ok-bg); }
.stat.key .value { font-size: 28px; }
.key-amounts .value { font-size: 26px; }

/* ── Tables: scroll shadows show that more columns are to the side ── */
.table-wrap { overflow-x: auto; position: relative;  /* keeps visually hidden labels inside the scroll area */
  background: linear-gradient(to right, var(--panel) 30%, transparent) left / 40px 100% no-repeat local,
              linear-gradient(to left, var(--panel) 30%, transparent) right / 40px 100% no-repeat local,
              radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .16), transparent) left / 12px 100% no-repeat scroll,
              radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .16), transparent) right / 12px 100% no-repeat scroll,
              var(--panel); }
table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 12em; }
td.wrap.narrow { min-width: 7em; }
th { color: var(--muted); font-size: 14px; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.group, td.group { border-left: 1px solid var(--line); }
td.strong { font-weight: 600; }
.sticky-first th:first-child, .sticky-first td:first-child { position: sticky; left: 0; background: var(--panel); }
td form { margin: 0; }
td form.inline { flex-wrap: nowrap; gap: 6px; align-items: center; }
td input[type=text] { width: 11em; padding: 5px 8px; min-height: 0; }
.phone-only { display: none; }
details.row-action summary { list-style: none; }
details.row-action summary::-webkit-details-marker { display: none; }
details.row-action[open] summary { margin-bottom: 6px; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.voided td.reason { text-decoration: none; }

/* ── Forms ── */
label { display: block; font-weight: 600; margin-bottom: 4px; }
label.normal { font-weight: 500; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 14px; font-weight: 400; margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], input[type=date], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; max-width: 520px; min-height: 43px; padding: 9px 10px; font: inherit; color: inherit; background: #fff; border: 1px solid var(--field); border-radius: 6px;
}
textarea { min-height: 76px; }
textarea[rows="2"] { min-height: 0; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); vertical-align: -4px; margin: 0 6px 0 0; }
fieldset:disabled input, fieldset:disabled select { background: var(--bg); border-color: var(--line); color: var(--text); cursor: default; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.form-grid input, .form-grid select, .form-grid textarea { max-width: none; }
.amount-row { display: grid; grid-template-columns: minmax(0, 380px) 130px; gap: 10px; }
.amount-row .field { margin: 0; }
.confirm-row label { border: 1px solid var(--warn-ink); background: var(--warn-bg); color: var(--warn-ink); border-radius: 6px; padding: 10px 12px; max-width: 520px; }
fieldset.plain { border: 0; padding: 0; margin: 0; }
.legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label { font-weight: 500; border: 1px solid var(--field); border-radius: 6px; padding: 8px 14px; margin: 0; cursor: pointer; background: #fff; display: flex; align-items: center; min-height: 44px; }
.choices label:has(input:checked) { border-color: var(--accent); background: var(--ok-bg); }
.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inline .field { margin: 0; }
form.search .field.grow { flex: 0 1 560px; }
form.search .hint { position: absolute; }
form.search .field { position: relative; padding-bottom: 20px; }
form.search button { margin-bottom: 20px; }
.spaced { margin-bottom: 16px; }
.grow { flex: 1; }
.tiers .field { display: grid; grid-template-columns: 150px 140px; align-items: center; gap: 10px; margin-bottom: 8px; }
.tiers label { margin: 0; font-weight: 500; }

/* ── Buttons ── */
button, .btn { display: inline-block; padding: 9px 16px; font: inherit; font-weight: 600; text-decoration: none; color: var(--accent-ink); background: var(--accent); border: 1px solid var(--accent); border-radius: 6px; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary, button.secondary { background: #fff; color: var(--accent); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.small, .btn.small { padding: 5px 10px; font-size: 14px; }
button.link { background: none; border: 0; color: var(--muted); padding: 10px 4px; font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions.spread { justify-content: space-between; max-width: 520px; }

/* ── Tabs (status filters) ── */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 9px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Notices and badges: red only for problems, grey for a normal end state ── */
.notice { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.notice.error { background: var(--err-bg); color: var(--danger); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.ok { background: var(--ok-bg); color: var(--ok-ink); }
.notice.info { background: var(--info-bg); color: var(--info-ink); }
.badge { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 10px; background: var(--info-bg); color: var(--info-ink); overflow-wrap: normal; word-break: normal; }
h2 .badge { font-weight: 600; }
.badge.done { background: var(--ok-bg); color: var(--ok-ink); }
.badge.in_progress, .badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.cancelled { background: var(--info-bg); color: var(--info-ink); }
.badge.bad { background: var(--err-bg); color: var(--danger); }
.badge.blocked { background: var(--danger); color: #fff; }

/* ── Label/value lists ── */
dl.facts { display: grid; grid-template-columns: minmax(110px, min(36%, 240px)) minmax(0, 1fr); gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: break-word; }
.break { word-break: break-all; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
input.mono, textarea.mono { font-size: 16px; }  /* below 16 px phones zoom in on focus */

/* ── Deal page and new-deal form ── */
.columns { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); align-items: start; }
.columns.single { grid-template-columns: minmax(0, 640px); }
.columns.client { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
@media (min-width: 1000px) { .columns.client { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.quote { background: var(--ok-bg); border-radius: 6px; padding: 12px 14px; margin-bottom: 14px; max-width: 520px; }
.quote.has-warnings { background: var(--warn-bg); }
#q-amd, #q-usdt { font-size: 20px; font-weight: 650; }
.quote ul { margin: 8px 0 0; padding-left: 18px; color: var(--warn-ink); }
.quote ul:empty { display: none; }
@media (min-width: 1000px) {
  #deal-form { display: grid; grid-template-columns: minmax(0, 1fr) 340px; column-gap: 28px; align-items: start; }
  #deal-form > * { grid-column: 1; }
  #deal-form > .quote { grid-column: 2; grid-row: 1 / span 9; position: sticky; top: 16px; max-width: none; }
}
.qr { display: block; width: 220px; height: 220px; max-width: 100%; }
.candidate + .candidate { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.candidate p { margin: 0 0 8px; }

.login { max-width: 380px; margin: 9vh auto; }
.muted { color: var(--muted); }
.negative { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── Tablet ── */
@media (max-width: 1000px) {
  th, td { padding: 8px 6px; }
}
@media (min-width: 641px) and (max-width: 1000px) {
  .hide-tablet { display: none; }  /* the address column already says from whom or to whom */
}

/* ── Phone ── */
@media (max-width: 640px) {
  main { padding: 16px 16px 48px; }
  header.top { padding: 4px 16px 0; }
  header.top nav { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px; flex-basis: calc(100% + 32px); scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
  header.top nav::-webkit-scrollbar { display: none; }
  header.top nav a { flex: none; padding: 11px 10px; }
  h1 { font-size: 21px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 18px; }
  .grid > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }  /* no lone half-width tile at the end */
  .stat.key .value, .key-amounts .value { font-size: 20px; }
  dl.facts { grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; }
  dl.facts .wide { grid-column: 1 / -1; }
  dl.facts dd.wide { margin-bottom: 4px; }
  .login { margin: 16px auto; }
  .tiers .field { grid-template-columns: 1fr 130px; }
  .amount-row { grid-template-columns: minmax(0, 1fr) 110px; }
  form.search .hint { position: static; }
  form.search .field { padding-bottom: 0; }
  form.search button { margin-bottom: 0; }
  /* deal page: what needs doing first, the facts after */
  .columns.deal .deal-side { display: contents; }
  .columns.deal { display: flex; flex-direction: column; gap: 0; align-items: stretch; }
  .columns.deal > *, .columns.deal .deal-side > * { order: 0; }
  .columns.deal .deal-facts { order: 1; }
  .columns.deal .deal-complete { order: 2; }
  .columns.deal .deal-tail { order: 3; }
  /* tables become cards */
  .cards thead, .deals-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .cards, .cards tbody, .cards tr, .cards td { display: block; }
  .cards tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .cards td { border: 0; padding: 2px 0; white-space: normal; text-align: left; }
  .cards td.num { text-align: left; }
  .cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 14px; }
  .cards td:empty { display: none; }
  .cards td.card-title { font-weight: 600; padding-bottom: 4px; }
  .cards .hide-phone { display: none; }
  .cards .phone-only, .phone-only { display: inline; }
  .hide-phone { display: none; }
  .cards td.mono { overflow-wrap: anywhere; }
  .cards td form.inline { flex-wrap: wrap; }
  .table-wrap:has(.cards), .table-wrap:has(.deals-table) { background: var(--panel); }
  .deals-table, .deals-table tbody { display: block; }
  .deals-table tr { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line);
    grid-template-areas: "no type status" "usdt usdt amd" "client client date"; }
  .deals-table td { border: 0; padding: 0; white-space: normal; min-width: 0; }
  .deals-table .c-no { grid-area: no; font-weight: 600; }
  .deals-table .c-type { grid-area: type; }
  .deals-table .c-status { grid-area: status; }
  .deals-table .c-usdt { grid-area: usdt; text-align: left; font-weight: 600; }
  .deals-table .c-amd { grid-area: amd; }
  .deals-table .c-client { grid-area: client; }
  .deals-table .c-date { grid-area: date; color: var(--muted); font-size: 14px; text-align: right; }
  .deals-table .c-rate { display: none; }
  .deals-table .c-usdt::after { content: " USDT"; }
  .deals-table .c-amd::after { content: " ֏"; }
  .deals-table .c-no a::after { content: ""; position: absolute; inset: 0; }
  .deals-table .c-client a { position: relative; z-index: 1; }
  .panel .table-wrap .deals-table tr:last-child, .cards tr:last-child { border-bottom: 0; }
}

/* ── Touch screens: fingers need 44 px ── */
@media (pointer: coarse) {
  button, .btn { min-height: 44px; }
  button.small, .btn.small { min-height: 40px; }
  header.top button.link { min-height: 44px; }
  input[type=file]::file-selector-button { min-height: 40px; padding: 8px 14px; }
}
