/* Palette shared with the labeling system (LabelPrint). */
:root {
  --brand: #0A6B4E; --brand-deep: #084C38; --brand-tint: #E1EFEA; --brand-tint-hover: #D2E7DF; --brand-tint-border: #CFE3DA;
  --amber: #E08A22; --amber-deep: #B96E10;
  --tech: #4F8FAF; --tech-tint: #E7EEF2; --tech-border: #D3E0E8; --tech-text: #2E5568;
  --bg: #F8F7F4; --surface: #FFFFFF; --hover: #F1F0EC; --border: #E4E6E2; --border-2: #D8DCD5;
  --text: #2E3432; --muted: #6B7370; --status-text: #5A625E; --danger: #B3261E;
  --on-brand-1: #CFE6DD; --on-brand-2: #A9CFC2;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Segoe UI", "Noto Sans Hebrew", "Noto Sans Arabic", Arial, sans-serif;
  font-size: 15px;
}
button { font: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, .display:focus-visible, .cur:focus-visible {
  outline: 2px solid var(--tech); outline-offset: 2px;
}
[hidden] { display: none !important; }

.win { display: flex; flex-direction: column; min-height: 100vh; }
/* Web page: a centered card instead of a full window. */
body.web { background: #EFEEEA; padding: 32px 16px; }
body.web .win { min-height: 0; max-width: 760px; margin: 0 auto; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.webfoot { max-width: 760px; margin: 12px auto 0; display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; font-size: 12px; color: var(--status-text); }
.webfoot a { color: var(--brand); }
@media (max-width: 800px) { .webfoot { padding: 0 16px 16px; } }
@media (max-width: 800px) { body.web { padding: 0; } body.web .win { margin: 0; border: none; border-radius: 0; min-height: 100vh; } }

.bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--brand); color: #fff; }
.logo { width: 24px; height: 24px; border-radius: 6px; background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; font-weight: 600; }
.title { font-size: 15px; font-weight: 600; margin: 0; }
.ver { margin-inline-start: auto; font-size: 12px; color: var(--on-brand-1); }
.icon-btn { background: none; border: none; color: var(--on-brand-1); padding: 4px; border-radius: 6px; display: flex; }
.icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

.body { flex: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; padding: 16px; }

.display {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; margin-bottom: 10px; direction: ltr; text-align: left; cursor: copy;
}
.display .expr { font-size: 13px; color: var(--muted); min-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.display .value { font-size: 30px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.display .value.err { color: var(--danger); font-size: 22px; }

.vat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.vat { height: 40px; border-radius: 8px; background: var(--surface); color: var(--brand); border: 1px solid var(--brand); font-weight: 600; font-size: 14px; }
.vat:hover { background: var(--brand-tint); }
.vat-info { font-size: 13px; color: var(--muted); min-height: 22px; margin-bottom: 8px; text-align: center; }
.vat-info b { color: var(--brand); font-weight: 600; }
.vat-info .num { direction: ltr; unicode-bidi: isolate; }

.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; direction: ltr; }
.k { height: 46px; font-size: 18px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.k:hover { background: var(--hover); }
.k:active { transform: scale(.97); }
.k.op { background: var(--brand-tint); color: var(--brand-deep); border-color: var(--brand-tint-border); }
.k.op:hover { background: var(--brand-tint-hover); }
.k.eq { background: var(--amber-deep); color: #fff; border: none; font-weight: 700; font-size: 22px; }
.k.eq:hover { background: #9A5B0C; }
.k.flash { background: var(--hover); }

/* The converter column is as tall as the calculator column (or the window, if taller).
   Its rows share that height equally and the text scales with the row height (cqh =
   percent of the row's own height). If rows would drop below their minimum, the page
   grows instead; the desktop app then enlarges its window (see fitWindow in app.js). */
.conv { display: flex; flex-direction: column; min-height: 0; }
.hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
#currencies { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.cur {
  flex: 1 1 0; min-height: 38px; container-type: size;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  padding: 0 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  text-align: start; color: var(--text);
}
.cur:hover { background: var(--hover); }
.cur.src { background: var(--brand-tint); border-color: var(--brand); }
.cur .name { font-size: clamp(13px, 30cqh, 18px); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cur.src .name { color: var(--brand-deep); font-weight: 600; }
.cur .amt { direction: ltr; unicode-bidi: isolate; font-size: clamp(15px, 38cqh, 26px); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cur.src .amt { color: var(--brand-deep); }
.cur.off .amt { color: var(--muted); font-weight: 400; }

/* History: a labeled pill in the display's corner, opening a list right under the display. */
.display-wrap { position: relative; }
.display-wrap .display { margin-bottom: 10px; }
.hist-btn {
  position: absolute; top: 7px; right: 8px; z-index: 2; direction: inherit;
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px 2px 10px;
  background: var(--brand-tint); color: var(--brand-deep); border: 1px solid var(--brand-tint-border);
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.hist-btn:hover, .hist-btn[aria-expanded="true"] { background: var(--brand-tint-hover); }
.hist-count { background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; padding: 0 5px; text-align: center; }
.display-wrap:has(.hist-btn:not([hidden])) .display .expr { padding-right: 120px; }
.hist {
  position: absolute; top: calc(100% - 4px); inset-inline: 0; z-index: 5;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(20, 30, 26, .14); padding: 10px 12px 12px;
}
.hist-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.hist-head h2 { margin: 0; font-size: 15px; color: var(--brand-deep); }
.link-btn { background: none; border: none; color: var(--brand); font-size: 13px; padding: 2px 4px; border-radius: 4px; }
.link-btn:hover { text-decoration: underline; }
.hist-empty { margin: 6px 0; font-size: 13px; color: var(--muted); }
.hist-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.hist-list button {
  width: 100%; text-align: left; direction: ltr; background: none; border: none; border-bottom: 1px solid var(--border);
  padding: 7px 6px; color: var(--text); border-radius: 0;
}
.hist-list li:last-child button { border-bottom: none; }
.hist-list button:hover { background: var(--hover); }
.hist-list .h-expr { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-list .h-res { display: block; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

.extras { border: none; padding: 0; margin: 0 0 12px; }
.extras legend { padding: 0; margin-bottom: 6px; }
.chk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

.info-box { display: flex; align-items: center; gap: 8px; background: var(--tech-tint); border: 1px solid var(--tech-border); color: var(--tech-text); border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-top: 10px; }
.dot-blue { width: 7px; height: 7px; border-radius: 50%; background: var(--tech); flex: none; }

/* Sponsor strip (web only): one banner from banners.json, rotated slowly. */
.sponsor { display: flex; align-items: stretch; background: var(--brand); color: #fff; }
.sp-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: #fff; text-decoration: none; transition: opacity .6s; }
.sp-link.fade { opacity: 0; }
.sp-link:hover .sp-cta, .sp-link:focus-visible .sp-cta { background: #9A5B0C; }
.sp-link:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.sp-icon { width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.14); display: flex; align-items: center; justify-content: center; flex: none; }
.sp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sp-k { font-size: 12px; color: var(--on-brand-1); }
.sp-t { font-size: 14px; font-weight: 600; line-height: 1.35; }
.sp-cta { display: inline-flex; align-items: center; gap: 6px; background: var(--amber-deep); color: #fff; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; flex: none; }
[dir="ltr"] .sp-arrow { transform: scaleX(-1); }
.sp-close { background: none; border: none; color: var(--on-brand-1); font-size: 20px; line-height: 1; padding: 0 12px; }
.sp-close:hover { color: #fff; background: rgba(255,255,255,.1); }
.sp-close:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
@media (prefers-reduced-motion: reduce) { .sp-link { transition: none; } }
@media (max-width: 560px) { .sp-icon { display: none; } .sp-t { font-size: 13px; } .sp-cta { padding: 6px 10px; } }

.status { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--hover); border-top: 1px solid var(--border-2); font-size: 12px; color: var(--status-text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--brand); }
.dot.warn { background: var(--amber); }

.toast { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); background: var(--brand-deep); color: #fff; padding: 6px 14px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .15s; }
.toast.show { opacity: 1; }

.overlay { position: fixed; inset: 0; background: rgba(20, 30, 26, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: 12px; padding: 18px 20px; width: 100%; max-width: 420px; max-height: 100%; overflow: auto; }
.dialog h2 { margin: 0 0 14px; font-size: 17px; color: var(--brand-deep); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field select, .field input { height: 36px; border: 1px solid var(--border-2); border-radius: 8px; padding: 0 10px; font: inherit; color: var(--text); background: var(--surface); }
.field input { direction: ltr; text-align: start; }
.err { color: var(--danger); font-size: 12px; min-height: 16px; }
.btn-outline { background: var(--surface); color: var(--brand); border: 1px solid var(--brand); border-radius: 8px; padding: 8px 14px; font-weight: 600; }
.btn-outline:hover { background: var(--brand-tint); }
.btn-primary { background: var(--brand); color: #fff; border: none; border-radius: 8px; padding: 8px 18px; font-weight: 600; }
.btn-primary:hover { background: var(--brand-deep); }
.lic { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.lic-machine { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); margin: 6px 0; }
.lic-machine code { font-family: Consolas, monospace; font-size: 14px; color: var(--text); background: var(--hover); border-radius: 4px; padding: 1px 6px; }
.lic-status { margin: 6px 0 10px; color: var(--text); }
.lic-status.ok { color: var(--brand-deep); font-weight: 600; }
.lic-status.bad { color: var(--danger); }
.field textarea { border: 1px solid var(--border-2); border-radius: 8px; padding: 6px 10px; font: 12px Consolas, monospace; color: var(--text); background: var(--surface); resize: vertical; word-break: break-all; }
.about { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; line-height: 1.6; }
.about-title { font-weight: 600; color: var(--text); }
.muted { color: var(--muted); font-size: 12px; margin-top: 4px; }
.dlg-actions { display: flex; gap: 8px; margin-top: 16px; }

@media (max-width: 560px) {
  .body { grid-template-columns: minmax(0, 1fr); }
  /* Stacked on a phone: no fixed height to fit into, so rows keep a natural size. */
  .cur { flex: none; height: 46px; }
  .k { height: 52px; }
}
