/* ==========================================================
   Auto Print — Neumorphism (soft UI) theme
   ========================================================== */
:root {
  --bg: #e6ebf2;
  --card: #e6ebf2;
  --text: #2a3247;
  --muted: #727c92;
  --border: rgba(160, 172, 194, .35);
  --primary: #4a6cf7;
  --primary-dark: #3553d6;
  --primary-soft: rgba(74, 108, 247, .14);
  --danger: #e04b4b;
  --success: #1f9d55;
  --warn: #e08a00;
  --light: #ffffff;
  --dark: #c3cad6;
  --radius: 18px;
  --radius-sm: 12px;
  --raised: 7px 7px 16px var(--dark), -7px -7px 16px var(--light);
  --raised-sm: 4px 4px 9px var(--dark), -4px -4px 9px var(--light);
  --raised-xs: 2px 2px 5px var(--dark), -2px -2px 5px var(--light);
  --inset: inset 4px 4px 9px var(--dark), inset -4px -4px 9px var(--light);
  --inset-sm: inset 2px 2px 5px var(--dark), inset -2px -2px 5px var(--light);
  --shadow: var(--raised);
  --bar-h: 68px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .9rem; }
h3 { font-size: 1rem; margin: .3rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.wrap { word-break: break-word; max-width: 320px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.4rem; background: var(--bg);
  box-shadow: 0 6px 16px var(--dark), 0 -1px 0 var(--light) inset;
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand small {
  font-weight: 600; font-size: .68rem; padding: 2px 8px; border-radius: 999px; margin-left: .3rem;
  background: var(--bg); color: var(--warn); box-shadow: var(--inset-sm); vertical-align: middle;
}
.menu { display: flex; gap: .5rem; flex: 1; flex-wrap: wrap; }
.nav-item {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .95rem; border-radius: var(--radius-sm); color: var(--muted); font-weight: 600;
  transition: box-shadow .2s, color .2s;
}
.nav-item .ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.nav-item:hover { color: var(--text); box-shadow: var(--raised-sm); }
.nav-item.active { color: var(--primary); box-shadow: var(--inset); }

.account { position: relative; margin-left: auto; }
.account summary {
  list-style: none; cursor: pointer; display: flex; gap: .5rem; align-items: center;
  padding: .45rem .9rem; border-radius: 999px; background: var(--bg); font-size: .9rem;
  box-shadow: var(--raised-sm); transition: box-shadow .2s;
}
.account summary::-webkit-details-marker { display: none; }
.account details[open] summary { box-shadow: var(--inset); }
.account .uid { color: var(--muted); }
.account .bal { font-weight: 800; color: var(--success); }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 12px); min-width: 230px; z-index: 30;
  background: var(--bg); border-radius: 16px; box-shadow: var(--raised);
  padding: .6rem; display: flex; flex-direction: column; gap: .2rem;
}
.dropdown .who { padding: .5rem .7rem .8rem; margin-bottom: .3rem; border-bottom: 1px solid var(--border); word-break: break-word; }
.dropdown a, .dropdown .linklike { padding: .55rem .7rem; border-radius: 10px; color: var(--text); text-align: left; }
.dropdown a:hover, .dropdown .linklike:hover { box-shadow: var(--inset-sm); color: var(--primary); }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; width: 100%; }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.2rem 3rem; }
.guest { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem 1rem; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--raised);
  padding: 1.5rem; margin-bottom: 1.6rem;
}
.card.auth { width: 100%; max-width: 410px; padding: 2rem 1.7rem; }
.card.auth h1 { text-align: center; }
.card.auth > .muted { text-align: center; margin-top: -.4rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; }
.grid { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.stats { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1.6rem; }
.stat { background: var(--bg); border-radius: var(--radius); box-shadow: var(--raised); padding: 1.1rem 1.3rem; }
.stat .n { font-size: 1.6rem; font-weight: 800; }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: 1rem; font-weight: 600; font-size: .92rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .4rem; padding: .7rem .9rem;
  font: inherit; color: inherit; background: var(--bg);
  border: 0; border-radius: var(--radius-sm); box-shadow: var(--inset);
  transition: box-shadow .2s;
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--inset), 0 0 0 2px var(--primary-soft); }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: auto; box-shadow: none; margin: 0 .4rem 0 0; accent-color: var(--primary); }
input[type="file"] { box-shadow: var(--inset-sm); }
.form-narrow { max-width: 440px; }
.form-row { display: grid; gap: 0 1.2rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.search { display: flex; gap: .7rem; }
.search input { margin: 0; min-width: 0; }
.inline { display: inline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem; font: inherit; font-weight: 700; cursor: pointer;
  border: 0; border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
  box-shadow: var(--raised-sm); white-space: nowrap; transition: box-shadow .15s, transform .15s, color .15s;
}
.btn:hover { color: var(--primary); }
.btn:active { box-shadow: var(--inset); transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: var(--raised-xs); }
.btn-primary {
  background: linear-gradient(145deg, #5b7cff, var(--primary-dark)); color: #fff;
  box-shadow: 5px 5px 12px rgba(53, 83, 214, .35), -4px -4px 10px var(--light);
}
.btn-primary:hover { color: #fff; background: linear-gradient(145deg, #6886ff, var(--primary)); }
.btn-primary:active { box-shadow: inset 3px 3px 8px rgba(20, 40, 140, .45), inset -2px -2px 6px rgba(255,255,255,.2); }
.btn-primary:disabled { background: linear-gradient(145deg, #9aaaf0, #8396e6); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { color: #b82e2e; }
.btn-block { width: 100%; }
.btn-lg { padding: 1rem 1.3rem; font-size: 1.1rem; border-radius: 16px; }
.btn-small { padding: .35rem .8rem; font-size: .85rem; border-radius: 10px; }
.btn-tiny { padding: .12rem .5rem; font-size: .75rem; border-radius: 8px; box-shadow: var(--raised-xs); }
.btn-google .g { font-weight: 800; color: #4285f4; }
.or { text-align: center; margin: 1.3rem 0; border-top: 1px solid var(--border); line-height: 0; }
.or span { background: var(--bg); padding: 0 .7rem; color: var(--muted); font-size: .85rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
td.actions { display: table-cell; white-space: nowrap; }
td.actions > * { display: inline-block; margin: 3px 2px; vertical-align: middle; }

.alert {
  padding: .8rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1.2rem; width: 100%; max-width: 1100px;
  background: var(--bg); box-shadow: var(--raised-sm); border-left: 4px solid currentColor; font-weight: 500;
}
.guest .alert { max-width: 410px; }
.alert-error { color: #b42323; }
.alert-success { color: #146c3a; }
.alert-info { color: var(--primary-dark); }
.alert-warn { color: #9a5d00; }
.alert a { color: inherit; text-decoration: underline; }
.error-msg { color: #b42323; background: var(--bg); box-shadow: var(--inset-sm); padding: .7rem .9rem; border-radius: var(--radius-sm); margin: .9rem 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -.3rem; padding: 0 .3rem; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
th, td { text-align: left; padding: .7rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th {
  color: var(--muted); font-weight: 700; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 0; background: rgba(195, 202, 214, .38);
}
thead th:first-child { border-radius: 10px 0 0 10px; }
thead th:last-child { border-radius: 0 10px 10px 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .35); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.bkash { color: var(--danger); }
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--bg);
  box-shadow: var(--raised-xs); font-size: .75rem; font-weight: 700; color: var(--muted);
}
.tag-color { background: linear-gradient(90deg, #ffe3e3, #e3f0ff, #e6ffe8); color: #5b3fd1; }
.status { font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--bg); box-shadow: var(--inset-sm); }
.status-ready { color: var(--primary); }
.status-printed { color: var(--success); }
.status-cancelled { color: var(--muted); }
.role-admin { color: #b42323; }
.role-treasurer { color: #9a5d00; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.2rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; word-break: break-word; }

/* ---------- Codes ---------- */
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .08em; white-space: nowrap; }
.code.big { font-size: 2.3rem; letter-spacing: .12em; color: var(--primary); }
.code-box {
  display: inline-flex; align-items: center; gap: .8rem; padding: .7rem 1rem;
  border-radius: 16px; background: var(--bg); box-shadow: var(--inset); font-size: 1.3rem; margin: .3rem 0 1rem;
}

/* ---------- Upload & print card ---------- */
.print-card { max-width: 540px; margin: 0 auto 1.6rem; }
.upload-zone {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: 2rem 1rem; cursor: pointer; font: inherit; color: var(--text);
  border: 0; border-radius: var(--radius); background: var(--bg); box-shadow: var(--raised);
  transition: box-shadow .2s, transform .2s;
}
.upload-zone:hover { transform: translateY(-2px); box-shadow: 10px 10px 22px var(--dark), -10px -10px 22px var(--light); }
.upload-zone:active { box-shadow: var(--inset); transform: none; }
.upload-zone .icon {
  width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; margin-bottom: .4rem;
  border-radius: 50%; box-shadow: var(--inset); font-size: 1.8rem; color: var(--primary);
}
.upload-zone strong { font-size: 1.15rem; }
.upload-zone small { color: var(--muted); }
.progress { padding: 1.6rem; text-align: center; color: var(--muted); border-radius: var(--radius); box-shadow: var(--inset); }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: .3rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.chosen { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--bg); box-shadow: var(--inset); }
.chosen .icon { font-size: 1.8rem; }
.chosen > div { flex: 1; min-width: 0; }
.chosen strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chosen small { color: var(--muted); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; margin: 1.5rem 0; }
.mode { margin: 0; cursor: pointer; position: relative; }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode > span {
  display: flex; flex-direction: column; align-items: center; gap: .4rem; text-align: center;
  padding: 1.1rem .5rem; border-radius: var(--radius); font-weight: 700;
  background: var(--bg); box-shadow: var(--raised-sm); border: 2px solid transparent;
  transition: box-shadow .2s, border-color .2s, color .2s;
}
.mode small { font-weight: 500; color: var(--muted); }
.mode input:checked + span { box-shadow: var(--inset); border-color: var(--primary-soft); color: var(--primary); }
.mode input:focus-visible + span { outline: 2px solid var(--primary-soft); outline-offset: 3px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; box-shadow: var(--raised-xs); border: 3px solid var(--bg); }
.swatch.bw { background: linear-gradient(135deg, #111 50%, #fff 50%); }
.swatch.color { background: conic-gradient(#f44336, #ffeb3b, #4caf50, #2196f3, #9c27b0, #f44336); }

.copies { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; font-weight: 700; }
.stepper { display: flex; align-items: center; gap: .4rem; padding: .3rem; border-radius: 14px; box-shadow: var(--inset); }
.stepper button {
  width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--bg); box-shadow: var(--raised-xs);
  font-size: 1.3rem; cursor: pointer; color: var(--text);
}
.stepper button:hover { color: var(--primary); }
.stepper button:active { box-shadow: var(--inset-sm); }
.stepper input { width: 56px; margin: 0; padding: .3rem; box-shadow: none; background: transparent; text-align: center; font-weight: 800; -moz-appearance: textfield; }
.stepper input:focus { box-shadow: none; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; }

.summary { background: var(--bg); border-radius: var(--radius); box-shadow: var(--inset); padding: 1rem 1.2rem; margin-bottom: 1.5rem; }
.summary > div { display: flex; justify-content: space-between; gap: 1rem; }
.summary .total { font-size: 1.2rem; margin: .4rem 0; }

/* ---------- Modals ---------- */
dialog.modal {
  border: 0; border-radius: 24px; padding: 1.9rem 1.6rem 1.5rem; width: min(92vw, 390px); text-align: center;
  background: var(--bg); color: var(--text); box-shadow: 12px 12px 30px rgba(40, 50, 80, .35), -6px -6px 18px rgba(255,255,255,.5);
}
dialog.modal::backdrop { background: rgba(40, 48, 70, .45); backdrop-filter: blur(3px); }
dialog.modal h2 { margin: .7rem 0 .5rem; }
.modal-icon {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 800; background: var(--bg); box-shadow: var(--raised);
}
.modal-icon.ok { color: var(--success); }
.modal-icon.warn { color: var(--warn); }
.file-name { font-weight: 700; word-break: break-word; margin: .3rem 0; }

/* ---------- Misc ---------- */
.balance-card { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.balance-big { font-size: 2.4rem; font-weight: 800; color: var(--success); }
.doc { display: flex; flex-direction: column; }
.doc .doc-icon {
  font-size: 1.8rem; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center;
  border-radius: 16px; box-shadow: var(--inset); margin-bottom: .5rem;
}
.doc .actions { margin-top: auto; padding-top: .8rem; }
.apikey { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; background: var(--bg); box-shadow: var(--inset); padding: .7rem .9rem; border-radius: var(--radius-sm); }
pre { background: #1f2638; color: #e6e9f2; padding: 1rem; border-radius: var(--radius-sm); overflow-x: auto; font-size: .85rem; box-shadow: var(--inset-sm); }
.pagination { display: flex; gap: .6rem; margin-top: 1.2rem; flex-wrap: wrap; }

/* ==========================================================
   Phone: icon menu in a bottom bar
   ========================================================== */
@media (max-width: 760px) {
  body:not(.layout-guest) { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 12px); }
  .topbar { padding: .6rem .9rem; gap: .6rem; box-shadow: 0 4px 12px var(--dark); }
  .brand { font-size: 1.02rem; }
  .account summary { padding: .35rem .75rem; font-size: .84rem; }
  .dropdown { position: fixed; right: .75rem; left: auto; top: 58px; max-width: calc(100vw - 1.5rem); }

  .menu {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    flex-wrap: nowrap; justify-content: space-around; gap: 0;
    height: calc(var(--bar-h) + env(safe-area-inset-bottom));
    padding: .45rem .4rem calc(.45rem + env(safe-area-inset-bottom));
    background: var(--bg); border-radius: 22px 22px 0 0;
    box-shadow: 0 -6px 18px var(--dark), 0 1px 0 var(--light) inset;
  }
  .menu-wide { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .menu-wide::-webkit-scrollbar { display: none; }
  .nav-item {
    flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: .2rem;
    padding: .2rem .15rem; border-radius: 14px; font-size: .68rem; font-weight: 700; text-align: center;
    box-shadow: none !important;
  }
  .menu-wide .nav-item { flex: 0 0 auto; min-width: 70px; }
  .nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav-item .ico {
    width: 40px; height: 30px; padding: 5px 9px; border-radius: 12px; box-sizing: border-box;
    transition: box-shadow .2s;
  }
  .nav-item:active .ico { box-shadow: var(--inset-sm); }
  .nav-item.active .ico { box-shadow: var(--inset); }

  .container { padding: 1.2rem .9rem 1.5rem; }
  h1 { font-size: 1.35rem; }
  .card { padding: 1.15rem; border-radius: 16px; margin-bottom: 1.2rem; }
  .card.auth { padding: 1.6rem 1.2rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: .9rem; }
  .stat { padding: .9rem 1rem; }
  .stat .n { font-size: 1.25rem; word-break: break-word; }
  .grid { gap: 1rem; }
  .page-head { flex-direction: column; align-items: stretch; }
  .search { width: 100%; }
  .modes { gap: .8rem; margin: 1.2rem 0; }
  .upload-zone { padding: 1.6rem .8rem; }
  .code.big { font-size: 1.7rem; letter-spacing: .06em; }
  .balance-big { font-size: 2rem; }
  .wrap { max-width: 220px; }
  td.wrap { min-width: 150px; }
  th, td { padding: .6rem .55rem; }
  dl.facts { grid-template-columns: 1fr; gap: .1rem; }
  dl.facts dd { margin-bottom: .5rem; }
}
@media (max-width: 360px) {
  .account .uid { display: none; }
  .stats { grid-template-columns: 1fr; }
}
