/* Rasiid — digital receipts for Somali business
   Design: white base (cheap on data), ink-blue text, Somali-sky action blue,
   system fonts only (no web-font downloads on 3G), receipt = thermal till slip. */

:root {
  --ink: #1a2e35;
  --muted: #5d7078;
  --line: #dce4e7;
  --sky: #2f7fd0;       /* action blue */
  --sky-dark: #24619f;
  --paid: #1f8a4c;
  --unpaid: #b4690e;
  --paper: #ffffff;
  --bg: #f2f5f6;
  --mono: ui-monospace, 'Cascadia Mono', 'Roboto Mono', Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 480px; margin: 0 auto; padding: 0 14px 60px; }

/* ---------- Header ---------- */
header {
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  max-width: 480px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.logo {
  font-family: var(--mono);
  font-weight: 700; font-size: 1.15rem; letter-spacing: 0.06em;
  color: #fff; text-decoration: none;
}
.logo span { color: #7db8ea; }
nav { display: flex; gap: 4px; align-items: center; }
nav a {
  color: #cfdbe1; text-decoration: none; font-size: 0.82rem;
  padding: 6px 8px; border-radius: 6px;
}
nav a.active, nav a:hover { background: rgba(255,255,255,0.12); color: #fff; }
.lang-switch {
  font-family: var(--mono); font-size: 0.75rem;
  border: 1px solid rgba(255,255,255,0.3); border-radius: 6px; overflow: hidden;
  display: flex;
}
.lang-switch a { padding: 4px 7px; color: #cfdbe1; text-decoration: none; border-radius: 0; }
.lang-switch a.on { background: #fff; color: var(--ink); font-weight: 700; }

/* ---------- Cards & forms ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 16px;
  margin-top: 16px;
}
h1 { font-size: 1.25rem; margin: 20px 0 4px; }
h2 { font-size: 1rem; margin-bottom: 10px; }
.sub { color: var(--muted); font-size: 0.88rem; }

label { display: block; font-size: 0.82rem; font-weight: 600; margin: 12px 0 4px; color: var(--ink); }
input, select, textarea {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 1rem; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--sky); outline-offset: 1px; border-color: var(--sky);
}

.btn {
  display: inline-block; width: 100%; text-align: center;
  background: var(--sky); color: #fff;
  border: none; border-radius: 8px;
  padding: 13px 16px; font-size: 1rem; font-weight: 700;
  cursor: pointer; text-decoration: none; margin-top: 16px;
}
.btn:hover { background: var(--sky-dark); }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.btn.secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--ink); }
.btn.secondary:hover { background: var(--bg); }
.btn.paid-btn { background: var(--paid); }
.btn.paid-btn:hover { background: #16693a; }
.btn.whatsapp { background: #1faa53; }
.btn.whatsapp:hover { background: #178a43; }

.error {
  background: #fbeaea; color: #8f2020; border: 1px solid #eec7c7;
  border-radius: 8px; padding: 10px 12px; font-size: 0.88rem; margin-top: 12px;
}
.success {
  background: #e8f6ee; color: #16693a; border: 1px solid #bfe4cd;
  border-radius: 8px; padding: 10px 12px; font-size: 0.88rem; margin-top: 12px;
}

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px;
}
.stat .num { font-family: var(--mono); font-size: 1.25rem; font-weight: 700; }
.stat .lbl { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat.paid .num { color: var(--paid); }
.stat.unpaid .num { color: var(--unpaid); }

.inv-list { margin-top: 8px; }
.inv-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-top: 8px;
  text-decoration: none; color: var(--ink);
}
.inv-row:hover { border-color: var(--sky); }
.inv-row .who { font-weight: 600; font-size: 0.95rem; }
.inv-row .when { font-size: 0.75rem; color: var(--muted); font-family: var(--mono); }
.inv-row .amt { font-family: var(--mono); font-weight: 700; }
.pill {
  font-size: 0.65rem; font-weight: 800; letter-spacing: 0.05em;
  border-radius: 99px; padding: 3px 9px; font-family: var(--mono);
}
.pill.paid { background: #e8f6ee; color: var(--paid); }
.pill.unpaid { background: #fdf1e3; color: var(--unpaid); }

/* ---------- Invoice line editor ---------- */
.item-row { display: grid; grid-template-columns: 1fr 62px 90px; gap: 6px; margin-top: 6px; }
.add-line {
  background: none; border: 1.5px dashed var(--line); color: var(--sky);
  border-radius: 8px; width: 100%; padding: 9px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; margin-top: 8px;
}
.add-line:hover { border-color: var(--sky); }
.live-total {
  display: flex; justify-content: space-between; margin-top: 14px;
  font-family: var(--mono); font-weight: 700; font-size: 1.1rem;
  border-top: 2px solid var(--ink); padding-top: 10px;
}

/* ---------- The receipt (signature element) ----------
   Rendered as a thermal till slip: monospace ledger, dashed rules,
   perforated bottom edge, rubber "PAID" stamp. */
.receipt {
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.88rem;
  margin-top: 20px;
  padding: 22px 18px 30px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 2px 10px rgba(26,46,53,0.08);
  position: relative;
}
.receipt::after { /* perforated tear edge */
  content: '';
  position: absolute; left: 0; right: 0; bottom: -9px; height: 10px;
  background:
    linear-gradient(-45deg, transparent 70%, var(--paper) 70%) 0 0 / 12px 10px repeat-x,
    linear-gradient(45deg, transparent 70%, var(--paper) 70%) 6px 0 / 12px 10px repeat-x;
  filter: drop-shadow(0 2px 2px rgba(26,46,53,0.08));
}
.receipt .biz { text-align: center; font-weight: 700; font-size: 1.05rem; letter-spacing: 0.03em; }
.receipt .biz-sub { text-align: center; color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.receipt .rule { border: none; border-top: 1.5px dashed var(--line); margin: 12px 0; }
.receipt .meta { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--muted); }
.receipt table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.receipt td { padding: 4px 0; vertical-align: top; }
.receipt td.r { text-align: right; white-space: nowrap; }
.receipt .qty { color: var(--muted); font-size: 0.78rem; }
.receipt .total-row { border-top: 2px solid var(--ink); font-weight: 700; font-size: 1.05rem; }
.receipt .total-row td { padding-top: 8px; }
.receipt .thanks { text-align: center; color: var(--muted); font-size: 0.78rem; margin-top: 14px; }
.receipt .code { text-align: center; letter-spacing: 0.35em; color: var(--muted); font-size: 0.72rem; margin-top: 4px; }

.stamp {
  position: absolute; top: 16px; right: 12px;
  transform: rotate(9deg);
  border: 3px solid var(--paid); color: var(--paid);
  border-radius: 6px; padding: 3px 10px;
  font-weight: 800; letter-spacing: 0.12em; font-size: 0.8rem;
  opacity: 0.85;
}
.stamp.unpaid { border-color: var(--unpaid); color: var(--unpaid); }

/* Pay box on unpaid public invoice */
.paybox {
  background: #eef5fc; border: 1px solid #cadff2; border-radius: 10px;
  padding: 14px; margin-top: 14px;
}
.paybox .pay-num {
  font-family: var(--mono); font-weight: 800; font-size: 1.2rem;
  letter-spacing: 0.04em;
}
.paybox .net { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.paybox p { font-size: 0.82rem; color: var(--muted); margin-top: 8px; }

.actions { display: grid; gap: 8px; margin-top: 16px; }
.actions .btn { margin-top: 0; }

footer { text-align: center; color: var(--muted); font-size: 0.72rem; margin-top: 40px; font-family: var(--mono); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Module tab bar */
.modules {
  max-width: 480px; margin: 8px auto 0;
  display: flex; gap: 2px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.modules::-webkit-scrollbar { display: none; }
.modules a {
  color: #cfdbe1; text-decoration: none; font-size: 0.8rem; font-weight: 600;
  padding: 6px 11px; border-radius: 7px 7px 0 0; white-space: nowrap;
}
.modules a.active { background: var(--bg); color: var(--ink); }

/* ---- v2 polish: modern depth & motion, still 3G-light ---- */
body { background: linear-gradient(180deg, #eef2f4 0%, #f2f5f6 240px); }
header { background: linear-gradient(160deg, #16333c, #1a2e35 60%, #21414c); }
.card, .stat, .inv-row {
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(26,46,53,0.05);
}
.btn { border-radius: 11px; box-shadow: 0 2px 6px rgba(47,127,208,0.28); transition: transform .06s ease, box-shadow .12s ease; }
.btn:active { transform: scale(0.985); box-shadow: 0 1px 3px rgba(47,127,208,0.2); }
.btn.secondary, .add-line { box-shadow: none; }
.btn.paid-btn { box-shadow: 0 2px 6px rgba(31,138,76,0.28); }
.btn.whatsapp { box-shadow: 0 2px 6px rgba(31,170,83,0.28); }
input, select, textarea { border-radius: 10px; transition: border-color .12s ease; }
.inv-row { transition: transform .08s ease, border-color .12s ease; }
.inv-row:active { transform: scale(0.99); }
.stat .num { letter-spacing: -0.02em; }
.pill { padding: 4px 10px; }
.receipt { border-radius: 10px 10px 0 0; }
.modules a { transition: background .12s ease; }
@media (prefers-reduced-motion: reduce) { .btn, .inv-row { transition: none; } .btn:active, .inv-row:active { transform: none; } }

/* ---- POS ---- */
.pos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.pos-item {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 8px; cursor: pointer; text-align: center; font-family: inherit;
  display: flex; flex-direction: column; gap: 3px; align-items: center;
  transition: transform .06s ease, border-color .1s ease;
}
.pos-item:active { transform: scale(0.96); border-color: var(--sky); }
.pos-item:disabled { opacity: 0.45; cursor: not-allowed; }
.pos-name { font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.pos-price { font-family: var(--mono); font-size: 0.85rem; color: var(--sky); font-weight: 700; }
.pos-oos { font-size: 0.62rem; color: var(--unpaid); font-weight: 800; text-transform: uppercase; }
.cart-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.cart-name { flex: 1; font-size: 0.92rem; font-weight: 600; }
.cart-amt { font-family: var(--mono); font-weight: 700; }
.cart-minus {
  width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--line);
  background: var(--bg); font-size: 1.1rem; font-weight: 700; color: var(--unpaid); cursor: pointer;
}
.meta-line { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 0.95rem; }
.meta-line:last-child { border-bottom: none; }

.day-head {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  margin: 16px 2px 2px; padding-bottom: 4px; border-bottom: 1px dashed var(--line);
}
