
  /* Layout: rates first; card preview pinned on the right (desktop) or right after the rates (mobile). */
  :root {
    --navy: #0f1f3d; --navy-2: #22365f; --gold: #c9a227; --gold-2: #e9d48f; --gold-soft: #faf4e1;
    --bg: #f2f3f6; --card: #ffffff; --line: #e3e6ec; --text: #17202f; --muted: #667085;
    --up: #127a3a; --up-bg: #e5f5ea; --down: #b3261e; --down-bg: #fdebea; --wa: #1f8f4e; --wa-bubble: #e3f7e6;
    --radius: 16px; --f-head: 'Montserrat', system-ui, sans-serif; --f-body: 'Inter', system-ui, sans-serif;
  }
  * { box-sizing: border-box; }
  body { margin: 0; font: 15px/1.5 var(--f-body); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
  header {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--navy); color: #fff;
    padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  }
  .brand { display: grid; line-height: 1.2; }
  .brand b { font: 800 16px var(--f-head); letter-spacing: .2px; }
  .brand span { font-size: 11px; color: var(--gold-2); letter-spacing: .4px; }
  .pill { font: 700 11px var(--f-head); text-transform: uppercase; letter-spacing: .8px; padding: 4px 10px; border-radius: 999px; }
  .pill.session { background: var(--gold); color: var(--navy); }
  .pill.preview { background: rgba(255,255,255,.14); color: #fff; }
  .clock { margin-left: auto; text-align: right; font-size: 12px; line-height: 1.25; color: var(--gold-2); }
  .clock b { display: block; font: 700 16px var(--f-head); color: #fff; font-variant-numeric: tabular-nums; }

  .layout {
    max-width: 1180px; margin: 0 auto; padding: 16px; display: grid; gap: 16px;
    grid-template-columns: minmax(0, 1fr); grid-template-areas: "rates" "card" "calc" "msg" "hist";
  }
  @media (min-width: 960px) {
    .layout { grid-template-columns: minmax(0, 1fr) 420px; grid-template-areas: "rates card" "calc card" "msg card" "hist hist"; align-items: start; }
    .area-card { position: sticky; top: 76px; }
  }
  .area-rates { grid-area: rates; } .area-card { grid-area: card; } .area-calc { grid-area: calc; } .area-msg { grid-area: msg; } .area-hist { grid-area: hist; }

  /* Card date & time */
  .when { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
  .when input { text-align: left; font-size: 16px; }
  .auto { display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; color: var(--navy); min-height: 46px; white-space: nowrap; }
  @media (max-width: 520px) { .when { grid-template-columns: 1fr 1fr; } .auto { grid-column: 1 / -1; min-height: 0; } }

  /* Rate history */
  .seg { display: inline-flex; background: #f2f4f7; border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
  .seg button { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 8px; background: transparent; color: var(--muted); }
  .seg button[aria-pressed="true"] { background: #fff; color: var(--navy); box-shadow: 0 1px 2px rgba(15,31,61,.12); }
  .filters { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; margin-bottom: 14px; }
  .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
  .stat { background: #f7f8fa; border-radius: 12px; padding: 10px 12px; }
  .stat span { display: block; font-size: 12px; color: var(--muted); }
  .stat b { font: 800 18px var(--f-head); color: var(--navy); font-variant-numeric: tabular-nums; }
  .chartwrap { position: relative; }
  .chartwrap svg { width: 100%; height: auto; display: block; overflow: visible; }
  .chartwrap .axis text { font: 500 11px var(--f-body); fill: var(--muted); font-variant-numeric: tabular-nums; }
  .chartwrap .grid line { stroke: #e9ecf1; stroke-width: 1; }
  .tip { position: absolute; pointer-events: none; background: var(--navy); color: #fff; border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.45; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); display: none; font-variant-numeric: tabular-nums; z-index: 2; }
  .tip b { font: 700 13px var(--f-head); }
  .legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
  .legend i { display: inline-block; width: 18px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
  .histtable { overflow-x: auto; max-height: 360px; overflow-y: auto; }
  .histtable table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 520px; }
  .histtable th { position: sticky; top: 0; background: #fff; text-align: right; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
  .histtable td { text-align: right; padding: 8px 10px; border-bottom: 1px solid #f0f2f5; }
  .histtable th:first-child, .histtable td:first-child, .histtable th:nth-child(2), .histtable td:nth-child(2) { text-align: left; }
  .empty { padding: 30px 10px; text-align: center; color: var(--muted); font-size: 14px; }
  .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
  .panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
  h2 { font: 800 15px var(--f-head); margin: 0; color: var(--navy); }
  .sub { font-size: 12px; color: var(--muted); }

  /* Approved rates */
  .rates { display: grid; gap: 10px; }
  .rate { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: linear-gradient(90deg, var(--gold-soft), #fff 70%); border: 1px solid #efe4c2; }
  .rate.silver { background: linear-gradient(90deg, #eef0f4, #fff 70%); border-color: var(--line); }
  .rate .name { font: 800 16px var(--f-head); color: var(--navy); }
  .rate .meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
  .delta { font: 700 11px var(--f-head); padding: 2px 8px; border-radius: 999px; }
  .delta.up { color: var(--up); background: var(--up-bg); } .delta.down { color: var(--down); background: var(--down-bg); }
  .delta.flat { color: var(--muted); background: #eef0f4; }

  /* Inputs with unit prefix */
  .money { position: relative; display: block; }
  .money .unit { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font: 700 16px var(--f-head); color: var(--muted); pointer-events: none; }
  .money input { padding-left: 32px; }
  .money.nounit input { padding-left: 12px; }
  input, textarea {
    font: 700 17px var(--f-head); padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
    background: #fff; color: var(--text); width: 100%; min-height: 46px; text-align: right; font-variant-numeric: tabular-nums;
  }
  textarea { font: 500 14px/1.55 var(--f-body); min-height: 200px; resize: vertical; text-align: left; }
  input:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,.22); }
  input[readonly] { background: #f5f6f8; color: var(--muted); }
  input[type=range] { padding: 0; min-height: 28px; border: 0; accent-color: var(--navy); }
  input[type=checkbox] { width: 20px; min-height: 20px; accent-color: var(--navy); }

  /* Calculation blocks */
  details.block { border-top: 1px solid var(--line); }
  details.block:first-of-type { border-top: 0; }
  details.block > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 12px 0; font: 700 14px var(--f-head); color: var(--navy); }
  details.block > summary::-webkit-details-marker { display: none; }
  details.block > summary::after { content: '+'; font-size: 20px; color: var(--muted); }
  details.block[open] > summary::after { content: '–'; }
  .fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); padding-bottom: 14px; }
  .field { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
  .results { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 18px; padding-bottom: 14px; }
  .results div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
  .results dt { color: var(--muted); margin: 0; }
  .results dd { margin: 0; font: 700 14px var(--f-head); font-variant-numeric: tabular-nums; white-space: nowrap; }

  /* Card */
  canvas { width: 100%; height: auto; border-radius: 12px; display: block; box-shadow: 0 10px 30px rgba(15,31,61,.18); background: #e9ebf0; aspect-ratio: 2 / 3; }
  .btns { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
  button, .filebtn {
    font: 700 15px var(--f-head); border: 0; border-radius: 12px; padding: 12px 16px; min-height: 48px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; text-decoration: none;
  }
  .btn-wa { background: var(--wa); color: #fff; font-size: 16px; min-height: 54px; }
  .btn-wa:hover { filter: brightness(1.06); }
  .btn-line, .filebtn { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
  .btn-line:hover, .filebtn:hover { border-color: var(--navy); }
  .btn-navy { background: var(--navy); color: #fff; }
  .small { font-size: 13px; min-height: 40px; padding: 8px 12px; }
  .filebtn input { display: none; }
  button:disabled { opacity: .55; cursor: progress; }
  button:focus-visible, .filebtn:focus-within, summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
  .reach { font-size: 12px; color: var(--muted); text-align: center; margin-top: 8px; }
  details.settings { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 4px; }
  details.settings > summary { cursor: pointer; padding: 10px 0; font: 700 13px var(--f-head); color: var(--navy); }
  .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
  .sliders { display: grid; grid-template-columns: 52px 1fr 40px; gap: 6px 10px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 10px; font-variant-numeric: tabular-nums; }
  .hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

  /* WhatsApp */
  .wa-chat { background: #efe7dd; border-radius: 12px; padding: 14px; }
  .bubble { max-width: 420px; background: #fff; border-radius: 0 12px 12px 12px; padding: 6px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
  .bubble img { width: 100%; border-radius: 8px; display: block; }
  .bubble p { white-space: pre-wrap; margin: 6px 6px 2px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
  .bubble small { display: block; text-align: right; color: var(--muted); font-size: 11px; margin: 0 6px 2px; }
  .tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
  .tag { font: 600 12px var(--f-body); background: #f2f4f7; border: 1px solid var(--line); color: var(--navy); border-radius: 999px; padding: 5px 10px; min-height: 0; }

  /* Mobile bottom bar */
  .mobilebar { display: none; }
  @media (max-width: 959px) {
    .area-card .btns { display: none; }
    .mobilebar { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; position: sticky; bottom: 0; z-index: 9; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: rgba(242,243,246,.96); border-top: 1px solid var(--line); backdrop-filter: blur(6px); }
    .rate { grid-template-columns: minmax(0, 1fr) 150px; }
  }

  /* Dialogs */
  dialog { border: 0; border-radius: 18px; padding: 0; width: min(460px, calc(100% - 32px)); background: #fff; color: var(--text); }
  dialog::backdrop { background: rgba(15,31,61,.55); }
  .dlg { padding: 22px; display: grid; gap: 14px; }
  .dlg h3 { margin: 0; font: 800 18px var(--f-head); color: var(--navy); }
  .dlg table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
  .dlg td { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .dlg td:last-child { text-align: right; font-weight: 700; }
  .dlg .btns2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .warn { color: var(--down); background: var(--down-bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600; margin: 0; }
  .steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
  .steps li { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
  .steps li::before { content: ''; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); flex: 0 0 auto; }
  .steps li.active { color: var(--text); font-weight: 600; }
  .steps li.active::before { border-color: var(--gold); border-top-color: transparent; animation: spin .8s linear infinite; }
  .steps li.done { color: var(--up); font-weight: 600; }
  .steps li.done::before { content: '✓'; border-color: var(--up); background: var(--up); color: #fff; font-size: 12px; display: grid; place-items: center; }
  .steps li.fail { color: var(--down); font-weight: 600; }
  .steps li.fail::before { content: '!'; border-color: var(--down); background: var(--down); color: #fff; font-size: 12px; display: grid; place-items: center; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .steps li.active::before { animation: none; } }
  .done-card img { width: 100%; border-radius: 10px; display: block; box-shadow: 0 6px 18px rgba(15,31,61,.15); }
  .toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 13px; display: none; z-index: 30; max-width: calc(100% - 32px); }
  .loading { padding: 18px 0; color: var(--muted); }

/* ---- server version additions ---- */
.layout { grid-template-areas: "rates" "card" "calc" "msg" "hist" "cust"; }
@media (min-width: 960px) { .layout { grid-template-areas: "rates card" "calc card" "msg card" "hist hist" "cust cust"; } }
.area-cust { grid-area: cust; }
header .logout { margin: 0; }
header .logout button { min-height: 36px; padding: 6px 12px; font-size: 12px; background: rgba(255,255,255,.12); color: #fff; border-radius: 10px; }
header .logout button:hover { background: rgba(255,255,255,.22); }
@media (max-width: 520px) { header .brand span { display: none; } header .clock span { display: none; } }

.chartwrap .band { fill: rgba(15,31,61,.14); }
.chartwrap .line { fill: none; stroke: #0f1f3d; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chartwrap .dot { fill: #0f1f3d; stroke: #fff; stroke-width: 2; }
.chartwrap .cross { stroke: #98a2b3; stroke-width: 1; stroke-dasharray: 3 3; }
.chartwrap .endlabel { font: 700 12px Montserrat, sans-serif; fill: #17202f; }
.legend .lg-band { background: rgba(15,31,61,.14); }
.legend .lg-line { background: #0f1f3d; height: 3px; }
.txt-up { color: var(--up); } .txt-down { color: var(--down); }

.custlist { max-height: 420px; overflow: auto; }
.custlist table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.custlist td { padding: 8px 6px; border-bottom: 1px solid #f0f2f5; }
.custlist td.act { text-align: right; white-space: nowrap; }
.custlist td.act button { margin-left: 6px; }
.custlist tr.off td:not(.act) { color: var(--muted); text-decoration: line-through; }

body.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--navy); }
.login-box { width: min(380px, 100%); background: #fff; border-radius: 18px; padding: 28px; display: grid; gap: 14px; text-align: center; }
.login-box img { margin: 0 auto; border-radius: 12px; }
.login-box h1 { margin: 0; font: 800 20px var(--f-head); color: var(--navy); }
.login-box form { display: grid; gap: 12px; text-align: left; }
.login-box input { text-align: left; }
.login-box button { width: 100%; }

/* ---- layout editor, bigger change badges, chart fit, masters link ---- */
.delta { font: 800 13px var(--f-head); padding: 4px 10px; border-radius: 999px; letter-spacing: .2px; }
.delta.flat { color: #fff; background: #6b7280; }
.delta.up { color: #fff; background: #12803d; } .delta.down { color: #fff; background: #c0291f; }
canvas.editing { touch-action: none; cursor: move; outline: 3px dashed var(--gold); outline-offset: 4px; }
.layout-tools { margin-top: 12px; padding: 12px; background: #fbf7ea; border-radius: 12px; display: grid; gap: 10px; }
.layout-tools .sub { margin: 0; }
.nudge { display: grid; grid-template-columns: repeat(4, 48px); gap: 6px; }
.nudge button { padding: 0; min-height: 40px; }
.subhead { margin: 18px 0 6px; font: 700 13px var(--f-head); color: var(--navy); }
.hdr-link { color: #fff; text-decoration: none; font: 700 12px var(--f-head); padding: 9px 12px; border-radius: 10px; background: rgba(255,255,255,.12); }
.hdr-link:hover { background: rgba(255,255,255,.22); }
.chartwrap { position: relative; width: 100%; max-width: 100%; }
.chartwrap svg { width: 100%; max-width: 100%; height: auto; display: block; overflow: hidden; }
.area-hist, .area-cust { min-width: 0; overflow: hidden; }
.filters { min-width: 0; }
.seg { max-width: 100%; }
@media (max-width: 520px) { .filters { flex-direction: column; } .stats { grid-template-columns: 1fr 1fr; } .hdr-link { padding: 8px; } }
/* ---- masters screen ---- */
.mlayout { max-width: 1180px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .mlayout { grid-template-columns: 420px minmax(0, 1fr); align-items: start; } .mcol { position: sticky; top: 76px; } }
.mcol { display: grid; gap: 16px; min-width: 0; }
.mform { display: grid; gap: 12px; }
.mgrid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
select { font: 600 14px var(--f-body); padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); min-height: 46px; width: 100%; }
select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,.22); }
input:disabled, select:disabled, textarea:disabled { background: #f5f6f8; color: var(--muted); }
.mform input[type=number] { text-align: left; }
.test { margin: 0; font: 600 13px var(--f-body); }
.test.ok { color: var(--up); } .test.bad { color: var(--down); }
.mlist { min-width: 0; }
.ftable { overflow-x: auto; }
.ftable table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.ftable td { padding: 10px 8px; border-bottom: 1px solid #f0f2f5; vertical-align: top; }
.ftable td.fx { max-width: 320px; overflow-wrap: anywhere; }
.ftable td.res { white-space: nowrap; font: 700 13px var(--f-head); font-variant-numeric: tabular-nums; text-align: right; }
.ftable td.act { white-space: nowrap; text-align: right; }
.ftable td.act button { margin-left: 4px; min-height: 34px; padding: 4px 10px; }
code { font: 12px ui-monospace, Consolas, monospace; background: #f2f4f7; padding: 1px 5px; border-radius: 5px; color: var(--navy); }
.pill.lock { background: var(--gold-soft); color: #7a5d00; font-size: 10px; }
.danger { color: var(--down) !important; }
[hidden] { display: none !important; }
.mgrid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

/* ---- plain-language formulas & users ---- */
.formula { font: 600 13px var(--f-body); color: var(--navy); background: #f4f6fb; border-radius: 6px; padding: 2px 6px; line-height: 1.9; }
.tag.op { background: var(--navy); color: #fff; border-color: var(--navy); min-width: 38px; font-size: 15px; font-weight: 700; }
details.howto { background: #f7f8fa; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
details.howto summary { cursor: pointer; font-weight: 700; color: var(--navy); }
details.howto ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; line-height: 1.6; }
.ftable thead th { text-align: left; font: 600 12px var(--f-body); color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
.livebar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: -4px 0 14px; padding: 10px 12px; background: #f4f6fb; border-radius: 12px; }
.livebar .auto { min-height: 0; }
.livebar .sub { flex: 1 1 260px; }

/* ---- clearer forms: labels on one baseline so boxes line up ---- */
.fields { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 16px; align-items: end; }
.field .lbl { display: block; min-height: 2.5em; line-height: 1.25; font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select { margin-top: 2px; }
details.block > summary .count { margin-left: auto; margin-right: 12px; font: 500 12px var(--f-body); color: var(--muted); }
.calc-head { margin: 4px 0 2px; font: 700 11px var(--f-head); text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.results dd.neg { color: var(--down); }

/* ---- live market rates strip ---- */
.livebox { border: 2px solid var(--gold); border-radius: 14px; background: linear-gradient(180deg, #fff8e1, #fffdf6); padding: 14px; margin-bottom: 16px; }
.livebox-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.livebox-title b { display: flex; align-items: center; gap: 8px; font: 800 15px var(--f-head); color: var(--navy); }
.livebox-title .sub { display: block; margin-top: 2px; }
.livebox-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.livebox .auto { min-height: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #12803d; box-shadow: 0 0 0 4px rgba(18,128,61,.18); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(18,128,61,.05); } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
.livefields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.livefield { display: grid; gap: 6px; background: #fff; border: 1px solid #ecd9a0; border-radius: 12px; padding: 10px 12px; }
.livefield .lbl { font: 800 13px var(--f-head); color: var(--navy); text-transform: uppercase; letter-spacing: .4px; }
.livefield input { font-size: 24px; min-height: 54px; border-color: #e9cf7a; background: #fffdf5; }
.livefield .money .unit { font-size: 20px; }
.livefield.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: #fff1b8; } 100% { background: #fff; } }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { filter: brightness(1.05); }

/* ---- connections ---- */
.cwrap { max-width: 1180px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.ctabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ctabs button { display: flex; gap: 12px; align-items: center; text-align: left; justify-content: flex-start; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 16px; min-height: 64px; color: var(--text); }
.ctabs button b { display: block; font: 800 15px var(--f-head); color: var(--navy); }
.ctabs button small { display: block; font: 500 12px var(--f-body); color: var(--muted); }
.ctabs .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #eef0f4; color: var(--navy); font: 800 14px var(--f-head); flex: 0 0 auto; }
.ctabs button[aria-selected="true"] { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15,31,61,.08); }
.ctabs button[aria-selected="true"] .num { background: var(--navy); color: #fff; }
.cpane { display: grid; gap: 16px; }
.note { background: #eef4ff; border: 1px solid #d5e3fb; border-radius: 14px; padding: 14px 16px; font-size: 14px; line-height: 1.55; }
.note b { color: var(--navy); }
.note ol { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.cgrid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .cgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; } }
.frow { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.mform .field input { text-align: left; }
.ccard { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; }
.ccard + .ccard { margin-top: 10px; }
.ccard.off { opacity: .7; background: #fafafa; }
.ccard-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.ccard-head b { font: 800 15px var(--f-head); color: var(--navy); }
.ccard .url { overflow-wrap: anywhere; margin-top: 2px; }
.pill.on { background: #e5f5ea; color: var(--up); font-size: 10px; }
.maplist { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 3px; }
.last { margin: 0; font-size: 12px; color: var(--muted); }
.last.ok { color: var(--up); } .last.bad { color: var(--down); }
.maphead { display: grid; grid-template-columns: 1.2fr 1.4fr 90px 40px; gap: 8px; font: 600 11px var(--f-body); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.maphead.json { grid-template-columns: 1.2fr 1.4fr 40px; }
.maphead.two { grid-template-columns: 1fr 1.4fr 40px; }
.maprow { display: grid; grid-template-columns: 1.2fr 1.4fr 90px 40px; gap: 8px; align-items: center; padding: 4px; border-radius: 10px; }
.maprow.two { grid-template-columns: 1fr 1.4fr 40px; }
.maphead.json + #maps .maprow, #maps .maprow:has(.mRow[hidden]) { grid-template-columns: 1.2fr 1.4fr 40px; }
.maprow.sel { background: #fff8e1; outline: 1.5px solid #ecd9a0; }
.maprow input, .maprow select { min-height: 42px; font-size: 14px; text-align: left; padding: 8px 10px; }
.maprow button { min-height: 42px; padding: 0; }
@media (max-width: 640px) {
  .maphead { display: none; }
  .maprow, .maprow.two { grid-template-columns: 1fr 40px; }
  .maprow > :first-child { grid-column: 1 / -1; }
}
.preview { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fafbfc; }
.pvtable { overflow: auto; max-height: 320px; }
.pvtable table { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.pvtable th { position: sticky; top: 0; background: var(--navy); color: #fff; padding: 6px 8px; font-weight: 600; white-space: nowrap; }
.pvtable td { padding: 6px 8px; border-bottom: 1px solid #edf0f3; white-space: nowrap; }
.pvtable td.pick { cursor: pointer; color: var(--navy); font-weight: 700; }
.pvtable td.pick:hover { background: #fff1b8; }
.pvtable td.picked { background: var(--gold); color: var(--navy); }
pre.sample { margin: 0; background: #0f1f3d; color: #e8ecf4; border-radius: 10px; padding: 12px; font: 12px/1.5 ui-monospace, Consolas, monospace; overflow: auto; max-height: 300px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) { .ctabs { grid-template-columns: 1fr; } }
@media (max-width: 700px) { header { flex-wrap: wrap; row-gap: 8px; } header .clock { margin-left: auto; } header .hdr-link, header .logout button { font-size: 11px; padding: 7px 9px; } }

/* ---- unit notes ---- */
.unitnote { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #eef2fb; color: #33507f; font: 600 11px var(--f-body); letter-spacing: .1px; vertical-align: middle; white-space: nowrap; }
.field .lbl .unitnote { display: table; margin: 3px 0 0; }
.field .lbl { min-height: 3.2em; }
.rate .name .unitnote { font-size: 10px; }
.livefield .unitnote { margin: -2px 0 0; justify-self: start; background: #fff1c2; color: #6b4e00; font-size: 12px; }
.results dt .unitnote { display: table; margin: 2px 0 0; font-size: 10px; }
.results dd small { font: 600 11px var(--f-body); color: var(--muted); }
.money.has-suffix input { padding-right: 52px; }
.money .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 700 12px var(--f-body); color: var(--muted); pointer-events: none; }
.livefield .money .suffix { font-size: 15px; color: #6b4e00; }
.livefield .money.has-suffix input { padding-right: 62px; }
/* ---- security box ---- */
.secbox { border: 1.5px solid #cfdcf3; border-radius: 12px; padding: 12px 14px; display: grid; gap: 12px; background: #f7faff; margin: 0; }
.secbox legend { padding: 0 6px; font: 800 13px var(--f-head); color: var(--navy); }
.secret-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; margin-top: 2px; }
.secret-row input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; text-align: left; min-height: 42px; }
.secret-row button { min-height: 42px; padding: 6px 10px; }
@media (max-width: 560px) { .secret-row { grid-template-columns: 1fr 1fr 1fr; } .secret-row input { grid-column: 1 / -1; } }
.pill.sec-ok { background: #e5f5ea; color: var(--up); font-size: 10px; }
.pill.sec-mid { background: #fff4d6; color: #7a5d00; font-size: 10px; }
.pill.sec-bad { background: var(--down-bg); color: var(--down); font-size: 10px; }
/* ---- association comparison ---- */
.layout { grid-template-areas: "rates" "cmp" "card" "calc" "msg" "hist" "cust"; }
@media (min-width: 960px) { .layout { grid-template-areas: "rates card" "cmp card" "calc card" "msg card" "hist hist" "cust cust"; } }
.area-cmp { grid-area: cmp; }
.cmpwrap { overflow-x: auto; }
table.cmp { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; min-width: 360px; }
table.cmp th, table.cmp td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: top; }
table.cmp thead th { font: 700 12px var(--f-head); color: var(--muted); text-transform: uppercase; letter-spacing: .6px; background: #f7f8fa; }
table.cmp thead th:first-child, table.cmp tbody th { text-align: left; }
table.cmp tbody th { font: 800 14px var(--f-head); color: var(--navy); }
table.cmp td { font: 700 16px var(--f-head); color: var(--text); }
table.cmp td div { margin-top: 4px; }
table.cmp td .delta { font-size: 12px; }
table.cmp tr.ours th, table.cmp tr.ours td { background: var(--gold-soft); }
table.cmp tr.ours th::after { content: 'Our rate'; display: block; font: 600 10px var(--f-body); color: #7a5d00; text-transform: uppercase; letter-spacing: .6px; margin-top: 2px; }
table.cmp .na { color: var(--muted); font-weight: 500; }
.cmp-note { margin: 10px 0 0; }
ul.pvlines { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; font-size: 13px; }
ul.pvlines li { padding: 7px 8px; border-bottom: 1px solid #edf0f3; }
ul.pvlines .pick { cursor: pointer; font-weight: 800; color: var(--navy); background: #fff1b8; border-radius: 6px; padding: 1px 6px; }
ul.pvlines .pick:hover { background: #ffe27a; }
ul.pvlines .pick.picked { background: var(--gold); }
ul.mlist-markets { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
ul.mlist-markets li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
ul.mlist-markets li .sub { display: block; font-size: 11px; }
/* ---- source test / confirm ---- */
.testbox { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; background: #fbfcfe; display: grid; gap: 10px; font-size: 13px; }
.testbox table { width: 100%; border-collapse: collapse; }
.testbox th { text-align: left; font: 600 11px var(--f-body); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 6px; border-bottom: 1px solid var(--line); }
.testbox td { padding: 8px 6px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.testbox tr.ok td.num { color: var(--up); font-weight: 800; white-space: nowrap; }
.testbox tr.bad td.num { color: var(--down); font-weight: 700; }
.testbox td.from { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.maprow.just { background: #e5f5ea; outline: 1.5px solid #9ad3ad; transition: background .3s; }
.pvtable td.picked, .pvtable td.pick.picked { background: var(--gold); }
/* ---- With GST column ---- */
.rate { grid-template-columns: minmax(0, 1fr) 160px 150px; }
.rates-head { display: grid; grid-template-columns: minmax(0, 1fr) 160px 150px; gap: 12px; padding: 0 14px 6px; font: 600 11px var(--f-body); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.rates-head span:not(:first-child) { text-align: right; }
.rate .gst { display: grid; justify-items: end; gap: 2px; padding: 8px 10px; border-radius: 10px; background: #eef7f0; border: 1px solid #cfe9d6; min-height: 46px; align-content: center; }
.rate .gst span { font: 600 10px var(--f-body); color: #2c6b41; text-transform: uppercase; letter-spacing: .4px; }
.rate .gst b { font: 800 16px var(--f-head); color: #12803d; font-variant-numeric: tabular-nums; }
table.cmp small.incl { display: block; font: 600 11px var(--f-body); color: #2c6b41; margin-top: 2px; }
@media (max-width: 959px) {
  .rate, .rates-head { grid-template-columns: minmax(0, 1fr) 150px; }
  .rates-head span:last-child { display: none; }
  .rate .gst { grid-column: 1 / -1; grid-template-columns: 1fr auto; justify-items: start; align-items: center; min-height: 0; }
  .rate .gst b { justify-self: end; }
}
@media (min-width: 960px) and (max-width: 1180px) { .rate, .rates-head { grid-template-columns: minmax(0, 1fr) 140px 130px; } }@media (min-width: 960px) { .rate .gst span { display: none; } }

/* ---- roles & permissions ---- */
.mcol2 { display: grid; gap: 16px; min-width: 0; align-content: start; }
.roles { display: grid; gap: 12px; }
.rolecard { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 12px; background: #fff; }
.rolecard.new { border-style: dashed; background: #fbfcfe; }
.rolehead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.rolehead b { font: 800 15px var(--f-head); color: var(--navy); }
.rolehead .rName { flex: 1 1 200px; text-align: left; font: 700 15px var(--f-head); min-height: 40px; }
.permsum { margin: 0; }
.permgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.perm { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.perm.on { border-color: #cfe9d6; background: #eef7f0; }
.perm input { width: 18px; height: 18px; min-height: 0; margin-top: 2px; flex: none; accent-color: #12803d; }
.perm span { display: grid; gap: 2px; }
.perm b { font: 700 13px var(--f-body); color: var(--text); }
.perm small { font-size: 11px; color: var(--muted); line-height: 1.35; }
.perm input:disabled + span { opacity: .75; }
.btn-line.danger:disabled { opacity: .45; cursor: not-allowed; }
/* web page text preview: lines that only continue the label above */
.pvlines li.cont { padding-left: 18px; color: var(--muted); }
/* ---- card style ---- */
.cardstyle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.cardstyle .field select, .cardstyle .field input { text-align: left; }
.cardstyle input[type=color] { padding: 4px; height: 44px; min-height: 44px; cursor: pointer; }
.cardstyle .auto { min-height: 44px; }
.layout-tools #lyAlign { margin: 8px 0; }
@media (max-width: 420px) { .cardstyle { grid-template-columns: 1fr; } }@media (min-width: 960px) { .area-card { max-height: calc(100vh - 92px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; } }

/* ---- several rate cards ---- */
.cardtabs { display: flex; flex-wrap: wrap; margin: 0 0 10px; }
.cardtabs button { flex: 1 1 auto; }
.cardsrc { margin: 0 0 10px; }
.mlist-markets li .row { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- rows on the card ---- */
.rowlist { display: grid; gap: 8px; margin: 0 0 10px; }
.rowitem { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.rowitem .num { font: 700 12px var(--f-head); color: var(--muted); text-align: center; }
.rowitem select { text-align: left; min-height: 40px; }
.mlist-markets .addrate { margin-top: 8px; gap: 6px; flex-wrap: nowrap; }
.mlist-markets .addrate input { text-align: left; min-height: 36px; flex: 1; min-width: 0; font-size: 13px; }

/* ---- control panel navigation ---- */
.adminnav { position: sticky; top: 60px; z-index: 9; display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.adminnav a { flex: 0 0 auto; display: grid; gap: 1px; padding: 7px 14px; border-radius: 10px; text-decoration: none; color: var(--text); border: 1px solid transparent; }
.adminnav a b { font: 700 13px var(--f-head); color: var(--navy); }
.adminnav a span { font-size: 11px; color: var(--muted); }
.adminnav a:hover { background: #f4f6fa; }
.adminnav a.on { background: var(--gold-soft); border-color: #ecd78f; }
.adminnav a.back { align-self: center; font: 600 13px var(--f-body); color: var(--muted); padding-right: 18px; border-right: 1px solid var(--line); border-radius: 0; margin-right: 4px; }
@media (max-width: 640px) { .adminnav a span { display: none; } .adminnav { top: 0; position: relative; } }

/* ---- system settings ---- */
.syslayout { max-width: 1180px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .syslayout { grid-template-columns: 1fr 1fr; align-items: start; } .sys-status, .sys-log { grid-column: 1 / -1; } }
.statusgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.statusgrid > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; font-size: 13px; }
.statusgrid span { color: var(--muted); }
.statusgrid b { font: 700 13px var(--f-head); color: var(--navy); text-align: right; }
.sysform { display: grid; gap: 14px; }
.sysrow { display: grid; gap: 6px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.syslabel b { font: 700 13px var(--f-body); color: var(--text); }
.syslabel small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.sysinput { display: grid; gap: 6px; }
.sysinput .secret { display: flex; gap: 6px; }
.sysinput .secret input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; }
.sysinput .field.inline { font-size: 12px; }
.linkbtn { background: none; border: 0; padding: 0; min-height: 0; color: var(--navy); text-decoration: underline; font-size: 12px; justify-self: start; cursor: pointer; }
.maint { display: grid; gap: 16px; }
.maint form, .maint > div { display: grid; gap: 4px; }
.maint .hint { margin: 0; }
.logbox { margin: 0; max-height: 420px; overflow: auto; background: #0f1f3d; color: #dfe6f3; padding: 12px 14px; border-radius: 10px; font: 12px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }.statusgrid .pill { white-space: nowrap; }
.mlist-markets li { display: grid !important; grid-template-columns: minmax(0, 1fr); gap: 10px; align-items: start; }
.mlist-markets li > .row { justify-content: flex-start !important; }
.mlist-markets li .sub { display: block; margin-top: 2px; line-height: 1.5; }

/* ---- WhatsApp setup ---- */
.checklist ul { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 6px; }
.checklist li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; padding: 8px 10px; border-radius: 10px; font-size: 13px; }
.checklist li.ok { background: #eef7f0; } .checklist li.ok b { color: #12803d; }
.checklist li.todo { background: #fff5e6; } .checklist li.todo b { color: #b45309; }
.checklist small { display: block; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.steps-plain { margin: 8px 0; padding-left: 20px; display: grid; gap: 8px; font-size: 13px; line-height: 1.5; }
.watest { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.watest .row select { width: auto; min-height: 44px; }
.testresult { margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13px; display: grid; gap: 4px; word-break: break-all; }
.testresult.ok { background: #eef7f0; } .testresult.bad { background: #fdecea; }
.testresult small { color: var(--muted); }.paramlist { display: grid; gap: 6px; }
.prow { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.prow code { font-weight: 700; color: var(--navy); }
.prow select { text-align: left; min-height: 40px; }

/* ---- previous rate editing ---- */
.prevbtn { background: none; border: 0; padding: 0; min-height: 0; font: inherit; color: inherit; cursor: pointer; border-bottom: 1px dashed currentColor; }
.prevbtn:hover { color: var(--navy); }
.prevbtn.set { color: #b45309; }
.prevbtn span { font-size: 11px; opacity: .7; }
.prevedit { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0; }
.prevedit input { width: 120px; min-height: 36px; text-align: right; }
.meta .pill { margin-left: 4px; }
.rate .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.prevbtn { text-align: left; white-space: nowrap; display: inline-block; }
.rate .meta .pill { margin-left: 0; }
/* long tick-box labels wrap instead of widening the page on phones */
.mcol .auto, .cardstyle .auto, .layout-tools .auto, .syslayout .auto { white-space: normal; min-width: 0; }
@media (max-width: 520px) { .statusgrid { grid-template-columns: 1fr 1fr; } .statusgrid > div { flex-direction: column; align-items: flex-start; gap: 4px; } .statusgrid b { text-align: left; } }
.login-logo { width: 104px; height: 104px; display: block; margin: 0 auto 6px; border-radius: 50%; box-shadow: 0 4px 12px rgba(15,31,61,.16); }

/* ---- association logo in headers ---- */
.brand-logo { width: 34px; height: 34px; border-radius: 50%; background: #fff; object-fit: contain; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
header { gap: 10px; }
.login-logo { object-fit: contain; background: #fff; }
.logoedit { display: flex; gap: 14px; align-items: center; margin: 0 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.logoedit img { width: 72px; height: 72px; border-radius: 50%; object-fit: contain; background: #fff; box-shadow: 0 2px 8px rgba(15,31,61,.12); flex: none; }
.logoedit small { display: block; color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
