@font-face {
  font-family: "AA Urdu";
  src: url("assets/fonts/noto-nastaliq-urdu.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFC;
}

:root {
  --green-950: #073e31;
  --green-900: #0a503d;
  --green-800: #0d6b50;
  --green-700: #15805f;
  --green-100: #dff4ec;
  --green-50: #effaf6;
  --gold: #e9aa29;
  --gold-soft: #fff4d8;
  --ink: #17251f;
  --muted: #68766f;
  --line: #dce5e1;
  --surface: #ffffff;
  --page: #f4f7f5;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 12px 34px rgba(8, 60, 45, .09);
  --radius: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(88px + var(--safe-bottom));
}
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.noscript { padding: 16px; text-align: center; background: #fee4e2; color: #912018; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 12px max(18px, env(safe-area-inset-left)) 12px max(18px, env(safe-area-inset-right));
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid rgba(220,229,225,.9);
  backdrop-filter: blur(16px);
}
.brand-wrap { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--green-700), var(--green-950));
  color: white;
  font-weight: 850;
  letter-spacing: -.8px;
  box-shadow: 0 7px 18px rgba(13,107,80,.22);
}
.eyebrow, .step-label { margin: 0 0 2px; color: var(--green-700); font-size: 10px; font-weight: 850; letter-spacing: 1.35px; }
.app-header h1 { margin: 0; font-size: 16px; line-height: 1.2; letter-spacing: -.25px; }
.icon-button {
  width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 13px; background: white; color: var(--green-800); cursor: pointer;
}
.icon-button:hover { background: var(--green-50); }

.app-main { width: min(100%, 860px); margin: 0 auto; padding: 16px; }
.privacy-strip {
  display: flex; align-items: center; gap: 11px; padding: 12px 14px; margin-bottom: 18px; border: 1px solid #cce8dc; border-radius: 15px; background: var(--green-50); color: var(--green-900);
}
.privacy-strip svg { width: 23px; flex: 0 0 auto; }
.privacy-strip div { min-width: 0; display: flex; flex-direction: column; }
.privacy-strip strong { font-size: 12px; }
.privacy-strip span { color: #4f7164; font-size: 11px; margin-top: 1px; }

.view { display: none; animation: viewIn .24s ease-out; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: .2; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 1px 16px; }
.section-heading h2 { margin: 0; font-size: 26px; letter-spacing: -.65px; }
.record-count { padding: 7px 10px; border-radius: 999px; background: white; border: 1px solid var(--line); color: var(--muted); font-size: 11px; white-space: nowrap; }
.record-count b { color: var(--green-800); font-size: 13px; }

.stepper { display: flex; align-items: center; margin: 0 8px 20px; }
.stepper i { flex: 1; height: 2px; background: var(--line); margin: 0 5px; transition: background .25s; }
.stepper i.done { background: var(--green-700); }
.step { display: flex; align-items: center; gap: 5px; color: #93a099; }
.step span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid #bec9c4; background: var(--page); font-size: 11px; font-weight: 800; }
.step b { font-size: 11px; }
.step.current, .step.done { color: var(--green-800); }
.step.current span { background: var(--green-800); border-color: var(--green-800); color: white; box-shadow: 0 0 0 4px var(--green-100); }
.step.done span { background: var(--green-100); border-color: var(--green-700); }

.scan-card {
  margin-bottom: 16px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(16,54,42,.045);
  transition: opacity .2s, filter .2s, border-color .2s;
}
.scan-card.locked-card { opacity: .54; filter: saturate(.4); }
.card-title-row { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.card-title-row > div:nth-child(2) { min-width: 0; flex: 1; }
.card-title-row h3 { margin: 0 0 3px; font-size: 15px; }
.card-title-row p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.side-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; }
.side-icon svg { width: 23px; }
.front-icon { background: var(--green-100); color: var(--green-800); }
.back-icon { background: var(--gold-soft); color: #9a6500; }
.optional-badge { align-self: flex-start; padding: 4px 7px; border-radius: 8px; background: var(--gold-soft); color: #8a5b00; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }

.capture-zone {
  position: relative;
  min-height: 164px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding: 20px;
  border: 1.5px dashed #aebfb7;
  border-radius: 16px;
  background: linear-gradient(145deg, #fbfdfc, #f2f7f5);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
}
.capture-zone::before, .capture-zone::after { content: ""; position: absolute; width: 25px; height: 25px; border-color: var(--green-700); border-style: solid; opacity: .55; }
.capture-zone::before { top: 10px; left: 10px; border-width: 2px 0 0 2px; border-radius: 5px 0 0; }
.capture-zone::after { right: 10px; bottom: 10px; border-width: 0 2px 2px 0; border-radius: 0 0 5px; }
.capture-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.camera-circle { width: 51px; height: 51px; display: grid; place-items: center; border-radius: 50%; background: var(--green-100); color: var(--green-800); }
.capture-zone strong { font-size: 13px; }
.capture-zone small { max-width: 270px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.image-preview { position: relative; overflow: hidden; border-radius: 16px; background: #12221c; aspect-ratio: 1.59/1; }
.image-preview img { width: 100%; height: 100%; display: block; object-fit: contain; }
.retake-button { position: absolute; right: 10px; top: 10px; padding: 7px 10px; border: 0; border-radius: 10px; color: white; background: rgba(7,34,26,.82); font-size: 11px; font-weight: 700; backdrop-filter: blur(6px); }

.primary-button, .secondary-button, .outline-button, .danger-button, .excel-button {
  min-height: 46px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; border-radius: 13px; padding: 11px 15px; font-weight: 760; font-size: 13px; cursor: pointer; transition: transform .12s, opacity .2s, background .2s;
}
button:active { transform: scale(.985); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.primary-button { color: white; border: 1px solid var(--green-800); background: linear-gradient(135deg, var(--green-700), var(--green-900)); box-shadow: 0 8px 18px rgba(13,107,80,.15); }
.secondary-button { color: var(--green-900); border: 1px solid #b9d7ca; background: var(--green-50); }
.outline-button { color: var(--ink); border: 1px solid var(--line); background: white; }
.danger-button { color: white; border: 1px solid var(--danger); background: var(--danger); }
.danger-outline { min-height: 42px; color: var(--danger); border-color: #f0c7c2; white-space: nowrap; }
.scan-button { width: 100%; margin-top: 12px; }
.scan-button svg { width: 20px; }
.large-button { width: 100%; min-height: 52px; border-radius: 15px; }
.large-button svg { width: 20px; }
.text-button { border: 0; padding: 10px; color: var(--green-800); background: transparent; font-size: 12px; font-weight: 750; cursor: pointer; }
.scan-actions { display: grid; justify-items: center; gap: 2px; margin: 5px 0 20px; }

.ocr-panel { margin: 3px 0 16px; padding: 15px; border: 1px solid #cce8dc; border-radius: 15px; background: var(--green-50); }
.ocr-top { display: flex; justify-content: space-between; color: var(--green-900); font-size: 12px; }
.progress-track { height: 7px; margin: 10px 0 7px; border-radius: 99px; overflow: hidden; background: #d6e8e0; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green-700), var(--gold)); transition: width .25s; }
.ocr-panel p { margin: 0; color: #5d756b; font-size: 10px; }

.back-button { width: 39px; height: 39px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--ink); }
.heading-grow { flex: 1; }
.notice-card { display: flex; align-items: flex-start; gap: 10px; padding: 13px; margin-bottom: 16px; border-radius: 14px; background: var(--gold-soft); color: #765000; }
.notice-card svg { width: 20px; flex: 0 0 auto; }
.notice-card p { margin: 0; font-size: 11px; line-height: 1.5; }
.details-form { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full, .details-form .full { grid-column: 1 / -1; }
.field span { font-size: 11px; font-weight: 780; color: #47564f; }
.field span b { color: var(--danger); }
.field span em { margin-left: 5px; color: var(--green-700); font-size: 9px; font-style: normal; font-weight: 700; }
.field input, .field textarea { width: 100%; border: 1px solid #cad6d0; border-radius: 12px; background: #fcfdfc; color: var(--ink); outline: 0; padding: 12px; font-size: 14px; transition: border .2s, box-shadow .2s; }
.field input { height: 47px; }
.field textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
#address { font-family: "AA Urdu", Inter, ui-sans-serif, system-ui, sans-serif; unicode-bidi: plaintext; }
#address.urdu-text { min-height: 132px; font-size: 17px; line-height: 2.25; text-align: right; }
.field input:focus, .field textarea:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px var(--green-100); }
.field input.invalid { border-color: var(--danger); background: var(--danger-soft); }
.form-error { grid-column: 1/-1; margin: 0; padding: 10px 12px; border-radius: 11px; background: var(--danger-soft); color: var(--danger); font-size: 11px; }

.records-heading { align-items: flex-end; }
.records-toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.search-box { position: relative; flex: 1; }
.search-box svg { position: absolute; left: 12px; top: 50%; width: 19px; color: var(--muted); transform: translateY(-50%); }
.search-box input { width: 100%; height: 43px; border: 1px solid var(--line); border-radius: 12px; background: white; padding: 8px 12px 8px 39px; outline: none; font-size: 12px; }
.search-box input:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px var(--green-100); }
.records-list { display: grid; gap: 11px; }
.record-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 4px 14px rgba(16,54,42,.04); }
.avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--green-100); color: var(--green-900); font-weight: 850; font-size: 13px; }
.record-info { min-width: 0; }
.record-info h3 { margin: 0 0 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.record-info .cnic { margin: 0 0 4px; color: var(--green-800); font-size: 11px; font-weight: 760; letter-spacing: .35px; }
.record-info .meta { margin: 0; color: var(--muted); font-family: "AA Urdu", Inter, ui-sans-serif, system-ui, sans-serif; font-size: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; unicode-bidi: plaintext; }
.record-menu { display: flex; gap: 5px; }
.record-action { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--muted); }
.record-action svg { width: 17px; }
.record-action.delete { color: var(--danger); border-color: #f0d3cf; }
.empty-state { padding: 42px 22px; text-align: center; border: 1px dashed #c6d3cd; border-radius: var(--radius); background: rgba(255,255,255,.65); }
.empty-icon { width: 66px; height: 66px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 20px; background: var(--green-100); color: var(--green-800); }
.empty-icon svg { width: 31px; height: 31px; }
.empty-state h3 { margin: 0 0 6px; font-size: 16px; }
.empty-state p { max-width: 310px; margin: 0 auto 17px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.export-panel { display: flex; flex-direction: column; gap: 13px; padding: 16px; margin-top: 16px; border-radius: 17px; background: var(--green-950); color: white; }
.export-panel > div { display: flex; flex-direction: column; }
.export-panel strong { font-size: 13px; }
.export-panel span { margin-top: 2px; color: #b7d5ca; font-size: 10px; }
.excel-button { width: 100%; color: #073e31; border: 1px solid #d7f1e7; background: #effaf6; }
.excel-button svg { width: 20px; }

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 7px max(10px, env(safe-area-inset-right)) calc(7px + var(--safe-bottom)) max(10px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  box-shadow: 0 -8px 24px rgba(10,48,37,.07);
  backdrop-filter: blur(16px);
}
.nav-item { position: relative; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 13px; background: transparent; color: #7a8982; cursor: pointer; }
.nav-item.active { color: var(--green-800); background: var(--green-50); }
.nav-item svg { width: 23px; height: 23px; }
.nav-item span:last-child { font-size: 10px; font-weight: 760; }
.nav-icon-wrap { position: relative; height: 23px; }
.nav-icon-wrap b { position: absolute; top: -7px; right: -12px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; border: 2px solid white; border-radius: 99px; background: var(--gold); color: #503300; font-size: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(87px + var(--safe-bottom)); z-index: 70; max-width: calc(100vw - 32px); padding: 11px 15px; border-radius: 12px; background: #13231d; color: white; opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: .22s; box-shadow: 0 10px 25px rgba(0,0,0,.2); font-size: 12px; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.app-dialog { width: min(92vw, 390px); padding: 0; border: 0; border-radius: 21px; color: var(--ink); box-shadow: 0 30px 90px rgba(0,0,0,.25); }
.app-dialog::backdrop { background: rgba(5,28,21,.6); backdrop-filter: blur(3px); }
.app-dialog form { padding: 23px; text-align: center; }
.dialog-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 13px; border-radius: 18px; }
.dialog-icon.warning { background: var(--danger-soft); color: var(--danger); }
.dialog-icon.install { background: var(--green-100); color: var(--green-800); }
.dialog-icon svg { width: 29px; height: 29px; }
.app-dialog h3 { margin: 0 0 7px; font-size: 18px; }
.app-dialog p { margin: 0 0 19px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dialog-actions.single { grid-template-columns: 1fr; }

@media (min-width: 700px) {
  body { padding-bottom: 30px; }
  .app-header { padding-left: max(25px, calc((100vw - 860px)/2)); padding-right: max(25px, calc((100vw - 860px)/2)); }
  .app-main { padding: 24px; }
  .scan-card { padding: 21px; }
  #scanView { display: none; }
  #scanView.active { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  #scanView .section-heading, #scanView .stepper, #scanView .ocr-panel, #scanView .scan-actions { grid-column: 1/-1; }
  #scanView .scan-card { margin: 0; }
  .capture-zone { min-height: 184px; }
  .export-panel { flex-direction: row; align-items: center; justify-content: space-between; }
  .excel-button { width: auto; }
  .bottom-nav { position: sticky; bottom: 16px; width: min(430px, calc(100% - 32px)); margin: 0 auto; border: 1px solid var(--line); border-radius: 18px; padding: 6px; box-shadow: 0 12px 35px rgba(10,48,37,.15); }
  .toast { bottom: 95px; }
}

@media (max-width: 390px) {
  .app-main { padding: 13px; }
  .app-header h1 { font-size: 14px; }
  .section-heading h2 { font-size: 23px; }
  .details-form { grid-template-columns: 1fr; padding: 14px; }
  .field.full, .details-form .full { grid-column: 1; }
  .records-toolbar { align-items: stretch; }
  .danger-outline { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
