:root {
  --bg: #eef3f2;
  --surface: #fff;
  --ink: #142022;
  --muted: #5d6e70;
  --line: #d5e2e1;
  --accent: #0d7377;
  --accent-dark: #085054;
  --soft: #e7f4f4;
  --warn: #c45c26;
  --warn-soft: #fff1e4;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1b7a4e;
  --ok-soft: #e7f6ee;
  --shadow: 0 1px 2px rgba(20,32,34,.05), 0 10px 28px rgba(20,32,34,.06);
  --radius: 12px;
  --nav-h: 72px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Cairo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #14919b; outline-offset: 2px; }
.hidden { display: none !important; }
.skip {
  position: absolute; right: -999px; top: 8px;
}
.skip:focus { right: 8px; z-index: 50; background: #fff; padding: 8px 12px; border-radius: 8px; }

.btn {
  border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 700;
  background: var(--accent); color: #fff;
  min-height: 44px;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.err { color: var(--danger); font-size: 13px; min-height: 1.2em; margin: 8px 0 0; }
.ok-box { background: var(--ok-soft); color: var(--ok); padding: 10px 12px; border-radius: 10px; font-weight: 700; }
label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin: 10px 0 4px; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="tel"], input[type="password"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff8e7;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  min-height: 44px;
  font-size: 16px;
}

.app { height: 100%; display: grid; grid-template-columns: 212px 1fr; }
nav.side {
  background: var(--accent-dark);
  color: #d7eeee;
  display: flex; flex-direction: column; padding: 16px 10px;
  gap: 4px;
}
nav.side h1 { font-size: 14px; color: #fff; margin: 0 8px 16px; font-weight: 800; }
nav.side button {
  background: transparent; color: inherit; border: 0; text-align: right;
  padding: 12px 12px; border-radius: 10px; font-weight: 600; min-height: 44px;
}
nav.side button[aria-current="page"], nav.side button:hover { background: rgba(255,255,255,.12); color: #fff; }
nav.side .note { margin-top: auto; font-size: 11px; color: #9ec9c9; padding: 8px; }
nav.side .out { color: #9ec9c9; font-size: 13px; }

nav.bottom { display: none; }

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: #fff;
}
header.top h2 { margin: 0; font-size: 20px; font-weight: 800; }
.shell { display: flex; flex-direction: column; min-height: 100%; background: var(--bg); min-width: 0; }
main { padding: 14px 20px 24px; overflow: auto; height: 100%; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.card .lbl { color: var(--muted); font-size: 12px; font-weight: 700; }
.card .val { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-top: 2px; }
.mint { background: var(--soft); }
.mint .val { color: var(--accent); }
.blue { background: #e7f2fb; }
.blue .val { color: #14919b; }
.amber { background: var(--warn-soft); }
.amber .val { color: var(--warn); }
.green { background: var(--ok-soft); }
.green .val { color: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 0 0 12px; }
.stats div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 700; font-size: 13px;
  min-height: 40px;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); font-size: 13px; }
th { font-size: 12px; color: #fff; font-weight: 700; position: sticky; top: 0; background: var(--accent); }
td.num { font-variant-numeric: tabular-nums; font-weight: 700; text-align: left; direction: ltr; }
tbody tr:nth-child(even) { background: #f7fbfb; }
tbody tr:hover { background: var(--soft); }
tbody tr.clickable { cursor: pointer; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
}
.b-wait { background: var(--warn-soft); color: var(--warn); }
.b-doc { background: #e7f2fb; color: #14919b; }
.b-done { background: var(--ok-soft); color: var(--ok); }
.b-bad { background: var(--danger-soft); color: var(--danger); }
.b-hold { background: #f3e8ff; color: #6b21a8; }
.b-cash { background: var(--ok-soft); color: var(--ok); }
.b-credit { background: var(--warn-soft); color: var(--warn); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.recep { display: grid; grid-template-columns: 340px 1fr; gap: 12px; align-items: start; }
.hits { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; max-height: 140px; overflow: auto; }
.hits button { text-align: right; background: #f8fbfb; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px; }
.hits button:hover, .hits button:focus { border-color: var(--accent); background: var(--soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.balrow { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 10px 0; }
.balrow .card { padding: 8px 10px; }
.balrow .val { font-size: 18px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }
td input, td select { background: #fff; padding: 6px 8px; font-size: 16px; min-height: 40px; }

dialog { border: 0; border-radius: 16px; width: min(480px, 94vw); padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20,32,34,.35); }
.dlg { padding: 22px; }
.dlg h3 { margin: 0 0 14px; }
.actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 14px; flex-wrap: wrap; }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20;
  max-width: 92vw; text-align: center;
}
.toast.show { opacity: 1; }
.visually { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }

.auth-body {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 400px at 80% -10%, #c7ecec 0%, transparent 55%),
    var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 8px; font-size: 22px; }
.brand { color: var(--accent); font-weight: 800; margin: 0 0 4px; font-size: 13px; letter-spacing: .04em; }
code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  nav.side { display: none; }
  nav.bottom {
    display: flex;
    position: sticky;
    bottom: 0;
    z-index: 15;
    background: var(--accent-dark);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    gap: 4px;
    border-top: 1px solid #0a3e41;
  }
  nav.bottom button {
    flex: 1 0 auto;
    min-width: 72px;
    min-height: 52px;
    background: transparent;
    color: #d7eeee;
    border: 0;
    border-radius: 10px;
    font-weight: 700;
    font-size: 12px;
    padding: 8px 10px;
  }
  nav.bottom button[aria-current="page"] { background: rgba(255,255,255,.14); color: #fff; }
  header.top { padding: 10px 14px; }
  header.top h2 { font-size: 17px; }
  main { padding: 12px 12px 20px; }
  .kpis, .split, .recep, .stats, .balrow, .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .toast { bottom: calc(var(--nav-h) + 12px); }
  .sheet { max-height: none; }
}
