:root {
  --bg: #0B0E33; --panel: #131848; --panel2: #1A2060; --line: rgba(175, 195, 255, 0.14);
  --text: #EEF1FF; --muted: #AFC3FF; --cyan: #28C1FA; --green: #34D399; --amber: #FFB86B; --red: #FF7A8A;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px;
  font-variant-numeric: tabular-nums; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 22px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.logo { width: 40px; height: 40px; object-fit: contain; }
.brand { display: flex; flex-direction: column; flex: 1; line-height: 1.25; min-width: 0; }
.brand b { font-size: 18px; }
.brand span { color: var(--muted); font-size: 12.5px; }
.actions, .chips { display: flex; gap: 8px; align-items: center; }
button { font: inherit; border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer; color: var(--text); }
button:disabled { opacity: .55; cursor: progress; }
button.primary { background: var(--cyan); color: #06143A; font-weight: 600; }
button.secondary { background: var(--panel2); border: 1px solid var(--line); }
button.ghost { background: transparent; color: var(--muted); }
button.small { padding: 3px 10px; font-size: 12.5px; background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.chip { background: var(--panel2); border: 1px solid var(--line); padding: 6px 12px; font-size: 14px; }
button:hover { filter: brightness(1.12); }
.tabs { display: flex; gap: 4px; padding: 10px 22px 0; align-items: center; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); border-radius: 10px 10px 0 0; padding: 10px 16px; }
.tabs button.on { background: var(--panel); color: var(--text); }
.month { margin-inline-start: auto; color: var(--muted); font-size: 13px; display: flex; flex-direction: row; gap: 8px; align-items: center; }
.month input { padding: 5px 8px; font-size: 14px; }
main { background: var(--panel); margin: 0 22px 22px; border-radius: 12px; border-start-start-radius: 0; padding: 18px 20px 22px; min-height: 60vh; }
.tab { display: none; } .tab.on { display: block; }
h3 { margin: 22px 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
h3:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card .k { color: var(--muted); font-size: 12.5px; }
.card .v { font-size: 26px; font-weight: 650; margin-top: 4px; }
.card .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card.good .v { color: var(--green); } .card.warn .v { color: var(--amber); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: end; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: rgba(255, 255, 255, 0.03); }
tr.void td { color: rgba(238, 241, 255, 0.4); text-decoration: line-through; }
.empty { color: var(--muted); padding: 18px 10px; }
.pill { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.paid { color: var(--green); background: rgba(52, 211, 153, .14); }
.pill.partial { color: var(--amber); background: rgba(255, 184, 107, .14); }
.pill.unpaid { color: var(--red); background: rgba(255, 122, 138, .14); }
.pill.off { color: var(--muted); background: rgba(175, 195, 255, .12); }
.owe { color: var(--amber); } .credit { color: var(--green); }
.muted { color: var(--muted); font-size: 13px; }
.msg-preview { white-space: pre-wrap; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); line-height: 1.6; }
.row-actions { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.row-start { display: flex; gap: 8px; flex-wrap: wrap; }
/* dialogs: never taller than the screen; the title stays on top and the buttons at the bottom while the middle scrolls */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 0;
  width: min(620px, 94vw); max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain; }
dialog::backdrop { background: rgba(3, 5, 25, 0.7); }
dialog > form, dialog > .statement { padding: 0 24px; }
dialog h2 { margin: 0 0 6px; font-size: 19px; grid-column: 1 / -1; }
.dlg-head { position: sticky; top: 0; z-index: 1; background: var(--panel); padding-top: 20px; padding-bottom: 6px; }
.dlg-head h2 { margin: 0; overflow-wrap: anywhere; }
.dlg-head .total { margin: 6px 0 0; }
dialog .form-end { position: sticky; bottom: 0; z-index: 1; background: var(--panel); padding: 12px 0 18px; border-top: 1px solid var(--line); }
dialog#dlg-pin .statement { padding-top: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
dialog .grid { grid-template-columns: 1fr 1fr; }
.wide { grid-column: 1 / -1; }
.new-customer { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
input, select { font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 10px; color-scheme: dark; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--cyan); outline-offset: -1px; }
/* numbers, dates, times, phones, links and passwords are typed left to right, also on the Arabic page */
[dir=rtl] input[inputmode], [dir=rtl] input[type=date], [dir=rtl] input[type=time], [dir=rtl] input[type=month],
[dir=rtl] input[type=password], [dir=rtl] .ltr-input { direction: ltr; text-align: right; }
.form-end { display: flex; gap: 8px; justify-content: flex-end; align-items: end; flex-wrap: wrap; }
.total { font-size: 17px; font-weight: 600; margin: 4px 0; }
.error { color: var(--red); margin: 0; min-height: 1em; }
.statement { display: flex; flex-direction: column; gap: 10px; }
dialog.login { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; background: var(--bg); }
dialog.login[open] { display: flex; align-items: center; justify-content: center; }
dialog.login::backdrop { background: var(--bg); }
.login-box { width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px;
  display: flex; flex-direction: column; gap: 12px; }
.login-box .lang-switch { align-self: flex-end; }
.login-box img { width: 54px; } .login-box h2 { margin: 0; }
.pin-big { font-size: 46px; font-weight: 800; letter-spacing: .2em; color: var(--cyan); margin: 8px 0; direction: ltr; text-align: center; }
.problem { background: rgba(255, 122, 138, .12); border: 1px solid rgba(255, 122, 138, .35); border-radius: 12px; padding: 10px 14px;
  margin-bottom: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.problem div { flex: 1; font-size: 13.5px; min-width: 200px; overflow-wrap: anywhere; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photos img { height: 120px; border-radius: 10px; border: 1px solid var(--line); }
.by { color: var(--muted); font-size: 12.5px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--green); color: #04261A;
  padding: 10px 18px; border-radius: 10px; font-weight: 600; opacity: 0; transition: opacity .25s; pointer-events: none;
  width: max-content; max-width: 92vw; text-align: center; z-index: 30; }
#toast.show { opacity: 1; }
#toast.warn { background: var(--amber); color: #3A2200; }
@media (max-width: 700px) {
  .top { flex-wrap: wrap; padding: 12px 12px; } .actions { order: 3; width: 100%; } .actions button { flex: 1; }
  .tabs { padding: 8px 8px 0; } .tabs button { padding: 8px 11px; }
  main { margin: 0 8px 8px; padding: 14px; } dialog .grid, .new-customer { grid-template-columns: 1fr; }
  input, select { font-size: 16px; } /* 16px: phones don't zoom in when a field is tapped */
  dialog > form, dialog > .statement { padding: 0 16px; }
  dialog .form-end button { padding: 8px 12px; }
}
a { color: var(--cyan); text-decoration: none; } a:hover { text-decoration: underline; }

.handover { background: rgba(255, 184, 107, .12); border: 1px solid rgba(255, 184, 107, .35); border-radius: 12px; padding: 10px 14px;
  margin-bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.handover div { flex: 1; min-width: 200px; }
a.wa { color: #25D366; font-weight: 600; }

.prog { height: 12px; border-radius: 99px; background: rgba(175,195,255,.16); overflow: hidden; margin: 8px 0 4px; direction: ltr; }
.prog i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #28C1FA, #34D399); transition: width .6s; }
.prog.full i { background: #34D399; }
.card.full { border-color: rgba(52,211,153,.7); background: rgba(52,211,153,.10); }
.est { font-size: 14px; color: var(--muted); }

/* phones: every table row becomes a small card, each value with its column name in front, so nothing is cut off */
@media (max-width: 600px) {
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  td { border: 0; padding: 4px 2px; display: flex; gap: 12px; align-items: baseline; text-align: start; white-space: normal; }
  td.num { text-align: start; }
  td::before { content: attr(data-label); flex: 0 0 38%; color: var(--muted); font-size: 12.5px; }
  td[data-label=""]::before { content: none; }
  td .cv { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  td.empty { display: block; }
  td button.small { padding: 6px 12px; font-size: 13.5px; margin: 2px 0; }
}
