@font-face {
  font-family: "Jameel Noori Nastaleeq";
  src: url("/jameel-noori.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: Roboto;
  src: url("/roboto-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --primary: #00666e;
  --on-primary: #fff;
  --primary-container: #8ce4fd;
  --on-primary-container: #00363c;
  --secondary-container: #d6f1f8;
  --surface: #fff;
  --variant: #e0ecee;
  --muted: #3f484a;
  --outline: #869fa3;
  --background: #f7fbfb;
  --ink: #191c1d;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --urdu: "Jameel Noori Nastaleeq", "Geeza Pro", serif;
  font-family: Roboto, Arial, sans-serif;
  background: var(--background);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #26c6da;
  --on-primary: #00373d;
  --primary-container: #0a3d44;
  --on-primary-container: #b4f2fb;
  --secondary-container: #13363d;
  --surface: #1b2022;
  --variant: #262e32;
  --muted: #d4dee0;
  --outline: #5b6e73;
  --background: #121516;
  --ink: #f1f3f4;
  --error: #ff8a80;
  --error-container: #8c0012;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
button svg .icon-cut { fill: none; stroke: var(--primary); stroke-width: 1.5; }

.app-shell { max-width: 620px; min-height: 100dvh; margin: 0 auto; padding-bottom: env(safe-area-inset-bottom); }
.android-toolbar {
  display: flex;
  align-items: center;
  min-height: calc(64px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 4px 0 16px;
  background: var(--primary);
  color: var(--on-primary);
}
.android-toolbar h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 22px;
  font-weight: 400;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.toolbar-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
}
.toolbar-icon svg { width: 24px; height: 24px; }
.toolbar-icon:active { background: #ffffff26; }
#history-panel .android-toolbar { padding-left: 0; }
.menu-wrap { position: relative; }
.android-menu {
  position: absolute;
  z-index: 4;
  top: 48px;
  right: 0;
  min-width: 200px;
  padding: 8px 0;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 13px #0004;
}
.android-menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
}
.android-menu button:active { background: var(--variant); }
.android-menu .danger { color: var(--error); }
.android-menu button span { width: 20px; font-size: 20px; text-align: center; }
.android-menu hr { margin: 4px 0; border: 0; border-top: 1px solid var(--variant); }

.android-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 48px;
  border-bottom: 1px solid #c8cccd;
  background: var(--surface);
}
.android-tabs button {
  position: relative;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 15px/1.4 Arial, sans-serif;
}
.android-tabs button[aria-current] { color: var(--primary); font-weight: 700; }
.android-tabs button[aria-current]::after {
  position: absolute;
  inset: auto 0 -1px;
  height: 3px;
  background: var(--primary);
  content: "";
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}
.button.primary { background: var(--primary); color: var(--on-primary); }
.button.outlined { border-color: var(--outline); background: transparent; color: var(--primary); }
.button.danger { border-color: var(--error); color: var(--error); }
.button.text { min-width: 60px; background: transparent; color: var(--primary); }
.form-error { margin: 8px 0 0; color: var(--error); font-size: 13px; line-height: 1.45; }

.access-page {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: center;
  padding: 22px;
}
.access-card { padding: 20px; border-radius: 20px; background: var(--surface); box-shadow: 0 7px 18px #0002; }
.access-card h1, .access-card h2 { margin: 0; text-align: center; }
.access-card h1 { font-size: 24px; color: var(--primary); }
.access-card h2 { margin-top: 10px; font-size: 16px; }
.access-card p { margin: 16px 0 0; font-size: 15px; line-height: 1.45; }
#access-message:empty { display: none; }
#access-message { color: var(--error); }
#retry-session { margin-top: 12px; }
#login-form { display: grid; gap: 12px; margin-top: 16px; }
#login-form .primary { border-radius: 14px; }
.access-input { display: grid; gap: 4px; font-size: 13px; }
.access-input input, .records-search input {
  min-width: 0;
  height: 54px;
  padding: 0 14px;
  border: 1px solid var(--outline);
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}
.access-note { margin: 16px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.records-body { padding: 8px 12px 16px; }
.records-search { position: relative; display: block; margin: 6px 0 12px; }
.records-search svg { position: absolute; top: 16px; left: 12px; width: 22px; height: 22px; fill: var(--muted); }
.records-search input { width: 100%; padding-left: 42px; }
#history-empty { padding: 12px; color: var(--muted); text-align: center; }
.history-list { margin: 0; padding: 0; list-style: none; }

dialog { max-width: calc(100% - 32px); border: 0; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: #0007; }
.android-message { width: 430px; padding: 22px; border-radius: 20px; }
.android-message h2 { margin: 0 0 12px; font-size: 20px; }
.android-message p { line-height: 1.45; }
.android-message form { display: flex; justify-content: flex-end; margin-top: 14px; }
.about-content { text-align: center; }
.about-content img { width: 60px; height: 60px; }
.manual-content { display: grid; gap: 8px; max-height: 55dvh; overflow: auto; }
.manual-content section { padding: 10px; border-radius: 8px; background: var(--variant); }
.manual-content h3, .manual-content p { margin: 0; font-size: 14px; }
.manual-content h3 { margin-bottom: 5px; color: var(--primary); }

.android-print-dialog { width: min(560px, 100%); max-height: 90dvh; padding: 10px 14px; border-radius: 20px; box-shadow: 0 7px 22px #0004; }
.android-print-dialog.full-view { width: 100vw; max-width: 100vw; max-height: 100dvh; }
.android-print-dialog.full-view .receipt-scroll { max-height: 72dvh; }
.print-toolbar { display: flex; align-items: center; gap: 8px; }
.print-toolbar-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-container);
  color: var(--on-primary-container);
}
.print-toolbar form { margin-left: auto; }
.print-close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--variant); color: var(--muted); font-size: 21px; }
.print-title-row { display: flex; align-items: center; gap: 5px; }
.print-title-row h2 { margin: 0; font-size: 16px; line-height: 1.2; }
.print-title-row span { padding: 2px 5px; border-radius: 5px; background: #e0f2fe; color: #0369a1; font-size: 10px; font-weight: 700; white-space: nowrap; }
.print-toolbar p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.print-tabs { display: flex; align-items: center; gap: 3px; margin: 6px 0 8px; padding: 4px; border-radius: 12px; background: var(--variant); }
.print-tabs button, .print-tabs span { padding: 6px 4px; border: 0; border-radius: 8px; color: var(--muted); font-size: 11px; line-height: 1.3; text-align: center; }
.print-tabs button { flex: 1; background: transparent; }
.print-tabs button[aria-pressed="true"] { background: var(--surface); color: var(--primary); font-weight: 700; }
.print-tabs span { background: var(--primary-container); color: var(--on-primary-container); }
.receipt-scroll { position: relative; min-height: 150px; max-height: 50dvh; overflow: auto; padding: 12px 10px 42px; border-radius: 16px; background: var(--variant); }
.print-zoom { position: sticky; z-index: 1; bottom: 0; display: flex; width: max-content; margin: 4px 0 0 auto; border-radius: 14px; background: var(--surface); color: var(--primary); box-shadow: 0 1px 6px #0002; }
.print-zoom button { min-width: 30px; height: 32px; padding: 0 4px; border: 0; background: transparent; color: inherit; font-size: 14px; }
#zoom-reset { font-size: 11px; font-weight: 700; }
.printer-status { display: flex; gap: 8px; align-items: center; margin: 6px 0; padding: 6px 8px; border: 1px solid var(--variant); border-radius: 12px; background: var(--background); }
.printer-status > span { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #a86100; }
.printer-status strong, .printer-status small { display: block; font-size: 12px; }
.printer-status small { color: var(--muted); }
.print-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 7px; }
#print-document { display: none; }

@media print {
  @page { margin: 0; }
  html[data-print-active="true"] body > :not(#print-document) { display: none !important; }
  html[data-print-active="true"] #print-document { display: block; width: 80mm; color: #000; background: #fff; }
  html[data-print-active="true"] #print-document[data-paper="58mm"] { width: 58mm; }
  #print-document > .android-receipt-body { break-inside: avoid; width: 100%; max-width: 100%; }
  #print-document > .android-receipt-body + .android-receipt-body { break-before: page; }
  .test-print { padding: 3mm; }
}
