/*
 * Shop Manager — interface styles.
 * Identity: the shopkeeper's khata (ledger book). Ledger-green frame, cool paper, emerald
 * actions, a brass accent used only for the mark and the selected menu item.
 * Money is always set in tabular figures so columns of amounts line up.
 */

/* ---- Tokens ---- */
:root {
  --ledger: #0e3b36;
  --ledger-2: #15504a;
  --ledger-ink: #d7e6e2;
  --paper: #f3f5f4;
  --surface: #ffffff;
  --ink: #17201e;
  --muted: #5e6b68;
  --rule: #dce3e0;
  --rule-strong: #c5d0cc;
  --action: #0f6e5a;
  --action-hover: #0b5747;
  --action-soft: #e4f1ed;
  --brass: #e0a526;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn-soft: #fff6e0;
  --warn-ink: #6b4a00;
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar: 248px;
  --font: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Roboto, Arial, sans-serif;
  color-scheme: light;
}

/* ---- Base ---- */
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14.5px/1.5 var(--font);
}
h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 17px;
  font-weight: 650;
  margin: 0 0 12px;
}
h3 {
  font-size: 15px;
  font-weight: 650;
  margin: 16px 0 8px;
}
p {
  margin: 0 0 10px;
}
a {
  color: var(--action);
}
:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.muted,
small {
  color: var(--muted);
}
.small {
  font-size: 12.5px;
}
.n,
td.n,
.today-figure,
.ledger dd,
.summary-card b,
.stat b {
  font-variant-numeric: tabular-nums;
}
.n {
  text-align: right;
  white-space: nowrap;
}
code {
  word-break: break-all;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Frame: sidebar + top bar ---- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--ledger);
  color: var(--ledger-ink);
  padding: 18px 12px 24px;
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 10px;
}
.brand b {
  display: block;
  color: #fff;
  font-size: 16px;
  font-weight: 650;
}
.brand span {
  display: block;
  font-size: 12.5px;
  color: var(--ledger-ink);
  opacity: 0.8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
}
.nav-group {
  margin-top: 10px;
}
.nav-label {
  margin: 0 0 4px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--ledger-ink);
  opacity: 0.6;
}
.nav-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 0;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ledger-ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  position: relative;
}
.nav-item:hover {
  background: var(--ledger-2);
  color: #fff;
}
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 0 3px 3px 0;
  background: var(--brass);
}
.nav-item .icon {
  flex: none;
  opacity: 0.9;
}
.nav-item .count {
  margin-left: auto;
}
.count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brass);
  color: #2b1d00;
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  line-height: 18px;
}
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 28px;
  background: rgba(243, 245, 244, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
#identity {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.menu-toggle {
  display: none;
  border: 0;
  background: none;
  padding: 6px;
  margin-left: -6px;
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
#notice {
  display: none;
  margin: 14px 28px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--action-soft);
  color: #0b4337;
  border: 1px solid #b9dcd1;
}
#notice.show {
  display: block;
}
.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(10, 26, 24, 0.45);
}

/* Signed out: the sign-in page uses the whole screen. */
body.signed-out .shell {
  display: block;
}
body.signed-out .sidebar,
body.signed-out .topbar {
  display: none;
}
body.signed-out #notice {
  max-width: 420px;
  margin: 16px auto 0;
}
/* Signed in without a menu (temporary password, renewal). */
body.no-nav .shell {
  grid-template-columns: minmax(0, 1fr);
}
body.no-nav .sidebar,
body.no-nav .menu-toggle {
  display: none !important;
}

/* Phones and small tablets: the menu becomes a drawer. */
@media (max-width: 960px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    z-index: 40;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(84vw, 300px);
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.2);
  }
  body.drawer-open .sidebar {
    transform: none;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .topbar {
    padding: 8px 14px;
    min-height: 54px;
  }
  .topbar h1 {
    font-size: 17px;
  }
  #notice {
    margin: 10px 12px 0;
  }
}
@media (max-width: 560px) {
  #identity {
    display: none;
  }
}

/* ---- Page content ---- */
#view {
  width: 100%;
  max-width: 1100px;
  padding: 22px 28px 48px;
}
#view.narrow {
  max-width: 640px;
  margin: 0 auto;
}
.admin-view {
  max-width: 1180px;
}
@media (max-width: 960px) {
  #view {
    padding: 14px 12px 40px;
  }
}
form,
section {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0 0 16px;
}
@media (max-width: 560px) {
  form,
  section {
    padding: 14px;
  }
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.empty {
  color: var(--muted);
  padding: 14px 0 4px;
  margin: 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 14px;
  margin-bottom: 12px;
}
form > label,
form > .password-field {
  margin-bottom: 12px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 550;
  color: #33403d;
}
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--action);
  box-shadow: 0 0 0 3px rgba(15, 110, 90, 0.15);
}
input[readonly] {
  background: #f6f8f7;
  color: var(--muted);
}
input[type='file'] {
  padding: 7px;
  background: #f9fbfa;
}
textarea {
  resize: vertical;
}
.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.check input {
  width: auto;
}

/* Buttons */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}
button:hover {
  border-color: var(--action);
  color: var(--action);
}
button.primary {
  background: var(--action);
  border-color: var(--action);
  color: #fff;
  font-weight: 600;
}
button.primary:hover {
  background: var(--action-hover);
  border-color: var(--action-hover);
  color: #fff;
}
form > button.primary {
  margin-top: 4px;
}
button.danger {
  color: var(--danger);
  border-color: #eab8b3;
}
button.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}
button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--action);
  font-weight: 550;
  text-decoration: underline;
  text-underline-offset: 2px;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.topbar #logout {
  padding: 6px 12px;
  font-size: 13px;
}

/* Tables */
.scroll {
  overflow-x: auto;
  margin: 0 -4px 6px;
  padding: 0 4px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
}
th {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: #f8faf9;
  white-space: nowrap;
}
tbody tr:hover td {
  background: #fafcfb;
}
td button {
  padding: 5px 10px;
  font-size: 13px;
}

/* Badges and banners */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}
.b-active {
  background: #e3f4ea;
  color: #17663a;
}
.b-trial {
  background: #e6f0ee;
  color: var(--ledger);
}
.b-expired {
  background: var(--danger-soft);
  color: var(--danger);
}
.b-pending {
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.b-suspended {
  background: #eceef0;
  color: #4a5363;
}
.banner {
  padding: 10px 28px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--rule);
}
.banner.info {
  background: #e7f0ee;
  color: var(--ledger);
}
.banner.warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.banner.messages ul {
  margin: 6px 0;
  padding-left: 18px;
}
.void {
  color: var(--danger);
}
.admin-tip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.warning {
  background: var(--warn-soft);
  color: var(--warn-ink);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
@media (max-width: 960px) {
  .banner {
    padding: 10px 14px;
  }
}

/* ---- Home ---- */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.quick-actions button {
  padding: 10px 16px;
}
.today {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  background: var(--ledger);
  color: #fff;
  border-color: var(--ledger);
}
.today-label {
  margin: 0;
  color: var(--ledger-ink);
}
.today-figure {
  margin: 2px 0 0;
  font-size: clamp(32px, 6vw, 46px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.ledger-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}
.ledger-filters label {
  color: var(--ledger-ink);
  font-weight: 500;
}
.ledger-filters label {
  flex: 1 1 140px;
}
.ledger-filters input,
.ledger-filters select {
  min-width: 0;
  border-color: transparent;
}
.ledger-filters button {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.ledger-filters button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: #fff;
}
/* The period summary is set like ruled ledger lines: label left, amount right. */
.ledger dl {
  margin: 0;
  columns: 2;
  column-gap: 40px;
}
.ledger dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  break-inside: avoid;
}
.ledger dt {
  color: var(--muted);
}
.ledger dd {
  margin: 0;
  font-weight: 650;
}
.home-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 760px) {
  .ledger dl {
    columns: 1;
  }
  .home-columns {
    grid-template-columns: minmax(0, 1fr);
  }
  .quick-actions button {
    flex: 1 1 calc(50% - 10px);
  }
}

/* Salesman's own month, inside the green Today panel. */
.my-month {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 32px;
  margin: 0;
}
.my-month dt {
  color: var(--ledger-ink);
  font-size: 13px;
}
.my-month dd {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* Competition board */
.leaderboard td.rank {
  width: 64px;
  font-weight: 650;
  white-space: nowrap;
}
.leaderboard td.rank .icon {
  width: 16px;
  height: 16px;
  margin-right: 4px;
  vertical-align: -3px;
  color: var(--brass);
}
.leaderboard tr.me td {
  background: var(--action-soft);
}
.leaderboard tr.me td:first-child {
  box-shadow: inset 3px 0 0 var(--action);
}

@media (max-width: 600px) {
  /* Phones: each salesman becomes a compact row — rank, name, then sales over commission. */
  .leaderboard table,
  .leaderboard tbody {
    display: block;
    min-width: 0;
  }
  .leaderboard thead,
  .leaderboard td:nth-child(3),
  .leaderboard td:nth-child(4) {
    display: none;
  }
  .leaderboard tr {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    column-gap: 8px;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid var(--rule);
  }
  .leaderboard td {
    padding: 0;
    border: 0;
    background: none !important;
    box-shadow: none !important;
  }
  .leaderboard tr.me {
    background: var(--action-soft);
    box-shadow: inset 3px 0 0 var(--action);
  }
  .leaderboard td.rank {
    grid-row: span 2;
    width: auto;
  }
  .leaderboard td:nth-child(2) {
    grid-row: span 2;
    font-weight: 600;
  }
  .leaderboard td:nth-child(5) {
    font-weight: 650;
  }
  .leaderboard td:nth-child(6) {
    font-size: 12px;
    color: var(--muted);
  }
  .leaderboard td:nth-child(6)::before {
    content: 'Commission ';
  }
}

/* Developer credit */
.credit a {
  color: inherit;
  text-decoration: none;
}
.credit a:hover {
  text-decoration: underline;
}
.credit {
  margin: auto 10px 0;
  padding-top: 24px;
  font-size: 12px;
  color: var(--ledger-ink);
  opacity: 0.55;
}
.auth-panel .credit {
  margin: 40px 0 0;
  color: var(--muted);
  opacity: 1;
}

/* ---- Sign in / sign up ---- */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
}
.auth-brand {
  background: var(--ledger);
  color: var(--ledger-ink);
  padding: 56px clamp(28px, 6vw, 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}
.auth-mark b {
  color: #fff;
  font-size: 20px;
}
.auth-brand h2 {
  color: #fff;
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 650;
  line-height: 1.15;
  max-width: 14ch;
  margin-bottom: 24px;
}
.auth-brand ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.auth-brand li {
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  max-width: 34ch;
}
.auth-offer {
  margin-top: 24px;
  color: var(--brass);
  font-weight: 600;
}
.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px clamp(20px, 6vw, 80px);
}
.auth-panel form {
  width: 100%;
  max-width: 420px;
  border: 0;
  padding: 0;
  background: none;
  margin: 0 0 6px;
}
.auth-panel h2 {
  font-size: 24px;
  margin-bottom: 18px;
}
.auth-panel form > button.primary {
  width: 100%;
  padding: 11px;
  margin-top: 6px;
}
.auth-switch {
  max-width: 420px;
  margin: 12px 0 0;
  color: var(--muted);
}
.hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0;
}
@media (max-width: 860px) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .auth-brand {
    padding: 22px 20px;
  }
  .auth-brand h2,
  .auth-brand ul,
  .auth-offer {
    display: none;
  }
  .auth-mark {
    margin: 0;
  }
  .auth-panel {
    padding: 24px 20px 40px;
    justify-content: flex-start;
  }
}

/* ---- Forms used across screens ---- */
.password-field {
  display: flex;
  gap: 6px;
}
.password-field input {
  flex: 1;
}
.password-toggle {
  flex: none;
  min-width: 62px;
}
.setup-group {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.setup-group > summary {
  padding: 15px 18px;
  cursor: pointer;
  font-weight: 650;
  font-size: 15.5px;
}
.setup-group[open] > summary {
  border-bottom: 1px solid var(--rule);
}
.setup-content {
  padding: 16px 18px 4px;
}
.setup-content form,
.setup-content section {
  border-color: var(--rule);
  background: #fbfcfc;
}
.payment-choices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: 14px 0;
  color: var(--muted);
}
.payment-choices .check {
  font-size: 14.5px;
  color: var(--ink);
}
#bank-fields {
  margin-top: 4px;
}
.sale-payment {
  margin-top: 6px;
}
.totals {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #f6f9f8;
  border: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
}
.invoice-options {
  margin-top: 14px;
  color: var(--muted);
}
.invoice-options summary {
  cursor: pointer;
  font-weight: 550;
}
.invoice-options > label {
  margin: 10px 0;
}
.invoice-options input[type='number'] {
  max-width: 220px;
}
#item-table {
  margin: 10px 0 6px;
}
#item-table th:first-child {
  width: 48%;
}
#item-table td:first-child select {
  min-width: 210px;
}
#item-table td input {
  min-width: 70px;
}
#add-item {
  margin-bottom: 4px;
}

/* Mobile: invoice / purchase item rows become stacked cards. */
@media (max-width: 640px) {
  #item-table,
  #item-table tbody {
    display: block;
    width: 100%;
  }
  #item-table thead {
    display: none;
  }
  #item-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 6px 8px;
    align-items: end;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
  }
  #item-table td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
  }
  #item-table td:first-child {
    grid-column: 1/-1;
  }
  #item-table td input,
  #item-table td:first-child select {
    min-width: 0;
  }
  #item-table td:nth-child(2)::before {
    content: 'Qty';
  }
  #item-table td:nth-child(3)::before {
    content: 'Rate (Rs)';
  }
  #item-table td:nth-child(4)::before {
    content: 'Amount';
  }
  #item-table td:nth-child(n + 2):nth-child(-n + 4)::before {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 3px;
  }
  #item-table td.n {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-weight: 700;
    padding-bottom: 8px;
  }
  #item-table td:last-child button {
    min-width: 42px;
    height: 40px;
  }
  #add-item {
    width: 100%;
  }
}
/* Phones: 16 px inputs stop iOS zooming in; comfortable tap targets. */
@media (max-width: 768px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }
  button {
    min-height: 40px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 380px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- Password confirmation dialog ---- */
dialog.password-confirm {
  max-width: 400px;
  width: calc(100% - 32px);
  border: 0;
  border-radius: var(--radius);
  padding: 22px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(10, 26, 24, 0.3);
}
.password-confirm form {
  border: 0;
  padding: 0;
  margin: 0;
}
.password-confirm label {
  margin: 12px 0;
}
.confirm-buttons {
  display: flex;
  gap: 8px;
}
dialog::backdrop {
  background: rgba(10, 26, 24, 0.5);
}

/* ---- Subscription, payments, account security ---- */
.status-card {
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0 0 16px;
  border: 1px solid var(--rule);
  background: var(--surface);
}
.status-card.ok {
  background: #eef8f2;
  border-color: #bfe2cc;
}
.status-card.warn {
  background: var(--warn-soft);
  border-color: #f0d08d;
}
.status-card p {
  margin: 4px 0;
}
.pay-instructions {
  background: var(--action-soft);
  border: 1px solid #b9dcd1;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.pay-instructions div {
  white-space: pre-line;
  margin-top: 4px;
  font-size: 15px;
}
.payment {
  display: flex;
  gap: 16px;
}
.payment .shot {
  flex: 0 0 120px;
}
.payment .shot img {
  width: 120px;
  max-height: 200px;
  object-fit: cover;
  object-position: top;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background: #f2f4f3;
}
.payment-body {
  flex: 1;
  min-width: 0;
}
.payment-body h3 {
  margin: 0 0 4px;
}
.payment-body p {
  margin: 4px 0;
}
.review {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.review label {
  flex: 0 0 auto;
}
.review input {
  flex: 1 1 220px;
  width: auto;
}
@media (max-width: 640px) {
  .payment {
    flex-direction: column;
  }
  .payment .shot,
  .payment .shot img {
    width: 100%;
    flex-basis: auto;
    max-height: 260px;
  }
}
.tfa-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.tfa-box ol {
  padding-left: 20px;
}
.tfa-box form {
  border: 0;
  padding: 0;
}
.qr svg {
  display: block;
  width: 200px;
  height: 200px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}
.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px 16px;
  padding-left: 20px;
}
.codes code,
.tfa-box code {
  font-size: 15px;
  letter-spacing: 0.04em;
}
.recovery {
  border-color: #f0d08d;
}

/* ---- Admin panel ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.summary-card small {
  display: block;
}
.summary-card b {
  display: block;
  font-size: 17px;
}
.summary-card.stat {
  display: block;
  text-align: left;
  min-height: 72px;
  cursor: pointer;
}
.summary-card.stat:hover {
  border-color: var(--action);
  background: #f7fbfa;
  color: inherit;
}
.summary-card.stat b {
  font-size: 24px;
  color: var(--ledger);
}
.attention {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quick button {
  font-size: 13.5px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.filters input {
  flex: 1 1 240px;
  width: auto;
}
.filters select {
  flex: 0 1 220px;
  width: auto;
}
.danger-text {
  color: var(--danger);
}
#shop-delete {
  border-color: #eab8b3;
}
#shop-delete button.primary {
  background: var(--danger);
  border-color: var(--danger);
}
#back-shops {
  margin-bottom: 12px;
}
@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .attention .quick {
    width: 100%;
  }
}

/* ---- Receipt dialog and printing (80 mm thermal roll) ---- */
dialog {
  position: fixed;
  max-width: 810px;
  width: 96%;
  max-height: 92vh;
  overflow: auto;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 14px;
  background: #f4f6f9;
}
dialog::backdrop {
  background: #0006;
}
dialog > button {
  margin-top: 10px;
}
.sheet {
  background: #fff;
  color: #111;
  max-width: 760px;
  margin: 0 auto;
  padding: 22px;
  border: 1px solid #ccc;
}
.sheet h1 {
  margin: 0;
  font-size: 22px;
  text-align: center;
}
.sheet .invoice-address {
  color: #555;
  text-align: center;
}
.sheet h2 {
  text-align: center;
  margin: 12px 0;
  letter-spacing: 1px;
}
.sheet th,
.sheet td {
  border-bottom: 1px solid #ccc;
  color: #111;
}
.sheet th {
  background: #eee;
}

.invoice-sum {
  width: 260px;
  max-width: 100%;
  margin-left: auto;
  margin-top: 10px;
}
.invoice-sum td {
  border: 0;
  padding: 3px 8px;
}
.invoice-thanks {
  text-align: center;
  color: #555;
  clear: both;
}
.invoice-policy {
  text-align: center;
  margin-top: 10px;
  border-top: 1px solid #ccc;
  padding-top: 8px;
}
.invoice-policy [lang='ur'] {
  font-family: 'Noto Nastaliq Urdu', 'Urdu Typesetting', 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  line-height: 2;
}
@media print {
  body > * {
    display: none !important;
  }
  body > dialog[open] {
    display: block !important;
    position: static;
    overflow: visible;
    max-height: none;
    width: 100%;
    max-width: none;
    background: #fff;
    border: 0;
    margin: 0;
    padding: 0;
  }
  dialog > button {
    display: none !important;
  }
  dialog::backdrop {
    background: white;
  }
  .sheet {
    border: 0;
    margin: 0;
    max-width: none;
    padding: 0;
  }
  .sheet thead {
    display: table-header-group;
  }
  .sheet tr {
    break-inside: avoid;
  }
  .invoice-policy,
  .invoice-sum {
    break-inside: avoid;
  }
  @page {
    margin: 12mm;
  }
}

/* 80 mm roll: 4 mm side insets leave a conservative 72 mm printable area.
   The printer driver selects roll width and page length; no fixed height. */
#receipt {
  width: calc(80mm + 28px);
  max-width: 96vw;
}
#receipt-content.sheet {
  box-sizing: border-box;
  width: 80mm;
  max-width: 100%;
  padding: 4mm;
  margin: 0 auto;
  font:
    12px/1.35 Arial,
    Helvetica,
    sans-serif;
  overflow-wrap: anywhere;
  color: #000;
  background: #fff;
}
#receipt-content .receipt-logo {
  display: block;
  width: 34mm;
  height: auto;
  margin: 0 auto 2mm;
}
/* Always in view, however long the invoice is, so it can be sent or printed on the spot. */
#receipt-actions {
  position: sticky;
  bottom: -14px;
  margin: 10px -14px -14px;
  padding: 10px 14px 14px;
  background: var(--paper);
  border-top: 1px solid var(--rule-strong);
}
#share-whatsapp {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}
#share-whatsapp button {
  width: 100%;
  margin-top: 8px;
}
.receipt-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
#receipt-content.sheet h1 {
  font-size: 17px;
  line-height: 1.2;
  margin: 0 0 2mm;
}
#receipt-content.sheet h2 {
  font-size: 12px;
  letter-spacing: 0.5px;
  margin: 3mm 0;
}
#receipt-content .invoice-address {
  font-size: 11px;
  line-height: 1.35;
  color: #000;
}
#receipt-content .two {
  display: block;
  margin: 0 0 3mm;
}
#receipt-content .invoice-meta {
  text-align: left;
  margin-top: 1mm;
  overflow-wrap: anywhere;
}
#receipt-content > table:not(.invoice-sum) {
  width: 100%;
  table-layout: fixed;
  border-top: 1px dashed #000;
}
#receipt-content > table:not(.invoice-sum) th,
#receipt-content > table:not(.invoice-sum) td {
  padding: 1.1mm 0.4mm;
  font-size: 10.5px;
  line-height: 1.3;
  vertical-align: top;
  border-bottom: 1px dashed #aaa;
  background: #fff;
  color: #000;
  overflow-wrap: anywhere;
  white-space: normal;
}
#receipt-content > table:not(.invoice-sum) th:nth-child(1) {
  width: 5%;
}
#receipt-content > table:not(.invoice-sum) th:nth-child(2) {
  width: 32%;
}
#receipt-content > table:not(.invoice-sum) th:nth-child(3) {
  width: 11%;
}
#receipt-content > table:not(.invoice-sum) th:nth-child(4) {
  width: 24%;
}
#receipt-content > table:not(.invoice-sum) th:nth-child(5) {
  width: 28%;
}
#receipt-content .n {
  text-align: right;
  white-space: normal;
  overflow-wrap: anywhere;
}
#receipt-content .invoice-sum {
  width: 100%;
  margin: 2mm 0 0;
  border-top: 1px dashed #000;
  font-size: 12px;
  table-layout: fixed;
}
#receipt-content .invoice-sum td {
  padding: 0.7mm 0.4mm;
  border: 0;
  color: #000;
}
#receipt-content .invoice-sum td:first-child {
  width: 61%;
}
#receipt-content p {
  margin: 2.5mm 0;
}
#receipt-content .invoice-thanks {
  font-size: 11px;
  color: #000;
}
#receipt-content .invoice-policy {
  font-size: 10.5px;
  border-top: 1px dashed #000;
  padding-top: 2mm;
  margin-top: 3mm;
}
#receipt-content .invoice-policy [lang='ur'] {
  font-size: 13px;
  line-height: 1.8;
}
@media print {
  @page {
    size: auto;
    margin: 0;
  }
  html,
  body {
    width: 80mm !important;
    max-width: 80mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
  body > dialog:not(#receipt) {
    display: none !important;
  }
  body > dialog#receipt[open] {
    display: block !important;
    position: static !important;
    box-sizing: border-box;
    width: 80mm !important;
    max-width: 80mm !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
  }
  #receipt-content.sheet {
    width: 80mm !important;
    max-width: 80mm !important;
    padding: 3mm 4mm !important;
    border: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
  }
  #receipt-actions {
    display: none !important;
  }
  /* Thermal printers print one colour: solid black keeps the logo sharp. */
  #receipt-content .receipt-logo {
    filter: brightness(0);
  }
  #receipt-content thead {
    display: table-header-group;
  }
  #receipt-content tr,
  #receipt-content .invoice-sum,
  #receipt-content .invoice-policy {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* Receipt particulars: paired fields share a row on screen and on the roll. */
#receipt-content .invoice-number {
  font-size: 13px;
  letter-spacing: 0;
  margin: 3mm 0;
  font-weight: 700;
}
#receipt-content .receipt-details {
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 3mm;
  overflow-wrap: anywhere;
}
#receipt-content .receipt-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 2mm;
  align-items: start;
  margin-bottom: 1mm;
  break-inside: avoid;
}
#receipt-content .receipt-pair > span:last-child {
  text-align: right;
}
#receipt-content .receipt-customer {
  margin-top: 1mm;
}
