/* Pawn Broker System - Unified Design */
:root {
  --primary: #5b21b6;
  --primary-h: #4c1d95;
  --primary-l: #ede9fe;
  --accent: #7c3aed;
  --green: #059669;
  --green-l: #d1fae5;
  --red: #dc2626;
  --red-l: #fee2e2;
  --amber: #d97706;
  --amber-l: #fef3c7;
  --blue: #2563eb;
  --blue-l: #dbeafe;
  --bg: #f5f3ff;
  --surface: #ffffff;
  --border: #e4e4e7;
  --text: #18181b;
  --muted: #71717a;
  --r: 14px;
  --r-sm: 8px;
  --sh: 0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.05);
  --sh-md: 0 4px 12px rgba(0,0,0,.08);
  --sh-lg: 0 12px 28px rgba(0,0,0,.12);
  --t: all .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
}
@media (min-width: 768px) { body { font-size: 15px; } }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 99px; }

/* Layout */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  flex: 1;
}
@media (min-width: 768px) { .container { padding: 1.5rem 2rem; } }

/* Top bar */
.topbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(91,33,182,.3);
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; }
@media (min-width: 768px) { .topbar h1 { font-size: 1.4rem; } }

/* Page header */
.ph {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border-radius: var(--r);
  padding: 1rem 1.25rem;
  box-shadow: var(--sh);
  border: 1px solid var(--border);
}
.ph h2 { font-size: 1.2rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.ph-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
@media (min-width: 640px) {
  .ph { flex-direction: row; align-items: center; justify-content: space-between; }
  .ph h2 { font-size: 1.35rem; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  border-radius: var(--r-sm);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--t);
  text-decoration: none;
  white-space: nowrap;
  min-height: 36px;
  font-family: inherit;
  line-height: 1;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn:active { transform: translateY(0); }
.btn i { font-size: .9em; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-h); color: #fff; }
.btn-success  { background: var(--green); color: #fff; }
.btn-success:hover  { background: #047857; color: #fff; }
.btn-danger   { background: var(--red); color: #fff; }
.btn-danger:hover   { background: #b91c1c; color: #fff; }
.btn-secondary{ background: #52525b; color: #fff; }
.btn-secondary:hover{ background: #3f3f46; color: #fff; }
.btn-ghost    { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover    { background: #f4f4f5; color: var(--text); }
.btn-lg { padding: .65rem 1.4rem; font-size: .95rem; min-height: 44px; }

/* Icon action buttons */
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px;
  font-size: .85rem;
  cursor: pointer; border: none;
  transition: var(--t);
  font-family: inherit;
}
.btn-icon:hover { transform: scale(1.12); box-shadow: var(--sh); }
.btn-icon.edit { background: #ede9fe; color: var(--primary); }
.btn-icon.edit:hover { background: var(--primary); color: #fff; }
.btn-icon.del  { background: var(--red-l); color: var(--red); }
.btn-icon.del:hover  { background: var(--red); color: #fff; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--sh);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: var(--t);
}
.card-hd {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: #fafaf9;
  font-weight: 600;
  font-size: .88rem;
  display: flex; align-items: center; gap: .5rem;
}
.card-bd { padding: 1.1rem; }

/* Form controls */
.field { margin-bottom: .9rem; }
.field label {
  display: block;
  font-size: .76rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .35rem;
}
.field label span { color: var(--red); }
.fc {
  width: 100%;
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .88rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: var(--t);
  min-height: 40px;
}
.fc:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}
.fc[readonly] { background: #fafaf9; color: var(--muted); cursor: not-allowed; }
.input-group { display: flex; }
.input-prefix {
  padding: .55rem .8rem;
  background: #f4f4f5;
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  font-size: .88rem;
  color: var(--muted);
  white-space: nowrap;
  display: flex; align-items: center;
}
.input-group .fc { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: .1rem 1rem; }
@media (min-width: 580px) { .form-grid.c2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 768px) { .form-grid.c3 { grid-template-columns: 1fr 1fr 1fr; } }
@media (min-width: 768px) { .form-grid.c4 { grid-template-columns: 1fr 1fr 1fr 1fr; } }

/* Table */
.tbl-wrap {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--sh);
  border: 1px solid var(--border);
  overflow: hidden;
}
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 620px; }
table.tbl thead {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}
table.tbl thead th {
  padding: .75rem .9rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  border: none;
}
table.tbl tbody tr { border-bottom: 1px solid #f4f4f5; transition: var(--t); }
table.tbl tbody tr:hover { background: #faf9ff; }
table.tbl tbody tr:last-child { border-bottom: none; }
table.tbl tbody td { padding: .75rem .9rem; font-size: .85rem; vertical-align: middle; }
table.tbl .sum-row { background: #f9f8ff; font-weight: 700; border-top: 2px solid #ddd8fe; }

/* Mobile cards */
.m-cards { display: none; }
@media (max-width: 767px) {
  .tbl-scroll { display: none; }
  .m-cards { display: flex; flex-direction: column; gap: .75rem; }
}
.m-card {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--sh);
  border: 1px solid var(--border);
  padding: .9rem;
  transition: var(--t);
}
.m-card:hover { box-shadow: var(--sh-md); border-color: #c4b5fd; }
.m-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .65rem; }
.m-card-title { font-weight: 600; font-size: .92rem; flex: 1; }
.m-card-badge { font-size: .74rem; white-space: nowrap; }
.m-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .85rem; margin-bottom: .75rem; }
.m-card-field label { font-size: .68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: .1rem; }
.m-card-field span { font-size: .84rem; font-weight: 500; }
.m-card-actions { display: flex; gap: .5rem; border-top: 1px solid var(--border); padding-top: .7rem; }
.m-card-actions .btn { flex: 1; justify-content: center; min-height: 40px; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: .2em .6em; font-size: .72em; font-weight: 600; border-radius: 6px; white-space: nowrap; }
.badge-purple { background: var(--primary-l); color: var(--primary); }
.badge-green  { background: var(--green-l); color: #065f46; }
.badge-red    { background: var(--red-l); color: #991b1b; }
.badge-amber  { background: var(--amber-l); color: #78350f; }
.badge-blue   { background: var(--blue-l); color: #1e40af; }
.badge-gray   { background: #f4f4f5; color: #52525b; }

/* Amount colors */
.cr       { color: var(--green); font-weight: 600; }
.db       { color: var(--red); font-weight: 600; }
.bal-pos  { color: var(--green); font-weight: 700; }
.bal-neg  { color: var(--red); font-weight: 700; }
.bal-zero { color: var(--muted); font-weight: 600; }

/* Stats strip */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; margin-bottom: 1.1rem; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh); border: 1px solid var(--border); padding: .85rem 1rem; text-align: center; }
.stat-val { font-size: 1.2rem; font-weight: 700; margin-bottom: .15rem; }
.stat-lbl { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }

/* Alerts */
.alert { padding: .8rem .95rem; border-radius: var(--r-sm); margin-bottom: .9rem; font-size: .85rem; border-left: 3px solid transparent; display: flex; align-items: flex-start; gap: .5rem; }
.alert-green { background: var(--green-l); border-color: var(--green); color: #065f46; }
.alert-red   { background: var(--red-l);   border-color: var(--red);   color: #991b1b; }
.alert-amber { background: var(--amber-l); border-color: var(--amber); color: #78350f; }
.alert-blue  { background: var(--blue-l);  border-color: var(--blue);  color: #1e40af; }

/* Modal */
.overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
  padding: 1rem;
}
.overlay.on { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto;
  animation: mIn .2s cubic-bezier(.34,1.56,.64,1);
}
.modal.wide { max-width: 700px; }
@keyframes mIn {
  from { opacity: 0; transform: scale(.94) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-hd {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
.modal-hd h3 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.modal-bd { padding: 1.1rem 1.25rem; }
.modal-ft {
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap;
  position: sticky; bottom: 0;
  background: var(--surface);
}
.x-btn {
  background: none; border: none; cursor: pointer;
  padding: .25rem; color: var(--muted);
  font-size: 1.2rem; line-height: 1;
  transition: var(--t); border-radius: 4px;
}
.x-btn:hover { color: var(--text); background: #f4f4f5; }

/* Toast */
#toasts {
  position: fixed; bottom: 1.1rem; right: 1.1rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .4rem;
  max-width: 320px; width: calc(100vw - 2.2rem);
}
.toast {
  display: flex; align-items: center; gap: .65rem;
  padding: .75rem .9rem;
  border-radius: var(--r-sm);
  box-shadow: var(--sh-lg);
  font-size: .84rem; font-weight: 500;
  animation: tIn .25s ease;
  position: relative; overflow: hidden;
}
@keyframes tIn  { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes tOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }
.toast.bye { animation: tOut .25s ease forwards; }
.toast::after {
  content: '';
  position: absolute; bottom: 0; left: 0;
  height: 2.5px; background: rgba(255,255,255,.45);
  animation: tProg 3s linear forwards;
}
@keyframes tProg { from { width: 100%; } to { width: 0; } }
.toast.ok   { background: var(--green); color: #fff; }
.toast.err  { background: var(--red);   color: #fff; }
.toast.info { background: var(--blue);  color: #fff; }
.toast i { font-size: 1rem; flex-shrink: 0; }

/* Spinner */
.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rot .65s linear infinite;
  vertical-align: middle;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* Section label */
.section-lbl {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: .9rem 0 .5rem;
  display: flex; align-items: center; gap: .5rem;
}
.section-lbl::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Pagination */
.pages { display: flex; flex-wrap: wrap; gap: .25rem; list-style: none; justify-content: center; margin: .85rem 0 0; }
.pages .pg {
  display: flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px;
  border-radius: 7px; font-size: .82rem; font-weight: 500;
  color: var(--muted); text-decoration: none;
  background: var(--surface); border: 1.5px solid var(--border);
  transition: var(--t);
}
.pages .pg.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.pages .pg.off { opacity: .4; pointer-events: none; }
.pages .pg:not(.off):not(.on):hover { background: var(--primary-l); border-color: var(--accent); color: var(--primary); }

/* Empty state */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty i { font-size: 2.5rem; display: block; margin-bottom: .75rem; opacity: .35; }

/* Filter bar */
.filter-bar {
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--sh); border: 1px solid var(--border);
  padding: 1rem 1.1rem; margin-bottom: 1.1rem;
}
.filter-grid { display: grid; grid-template-columns: 1fr; gap: .6rem; }
@media (min-width: 580px) { .filter-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .filter-grid { grid-template-columns: 2fr 1fr 1fr auto; align-items: end; } }

/* Info/warn boxes */
.info-box  { background: var(--blue-l);  border: 1px solid #bfdbfe; border-radius: var(--r-sm); padding: .75rem .9rem; font-size: .82rem; color: #1e40af; display: flex; align-items: flex-start; gap: .5rem; }
.warn-box  { background: var(--amber-l); border: 1px solid #fde68a; border-radius: var(--r-sm); padding: .75rem .9rem; font-size: .82rem; color: #78350f; display: flex; align-items: flex-start; gap: .5rem; }

/* Credit/debit panels */
.cr-panel { border-left: 3px solid var(--green); background: #f0fdf4; border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: .75rem .9rem; }
.db-panel { border-left: 3px solid var(--red);   background: #fff5f5; border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: .75rem .9rem; }

/* Footer */
footer {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: rgba(255,255,255,.8);
  text-align: center; padding: .75rem;
  font-size: .76rem; margin-top: auto;
}

/* Home page */
.home-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.home-inner { width: 100%; max-width: 400px; }
.home-inner h2 { font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: .35rem; }
.home-inner p { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 1.75rem; }
.nav-list { display: flex; flex-direction: column; gap: .6rem; }
.nav-item {
  display: flex; align-items: center; gap: .85rem;
  padding: .9rem 1.1rem; border-radius: var(--r);
  text-decoration: none; color: #fff; font-weight: 600; font-size: .9rem;
  transition: var(--t); box-shadow: var(--sh-md);
}
.nav-item:hover { transform: translateY(-2px); box-shadow: var(--sh-lg); color: #fff; }
.nav-item .ni { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.2); border-radius: 9px; font-size: 1.1rem; flex-shrink: 0; }
.nav-item .nt { flex: 1; }
.nav-item .nt small { display: block; font-weight: 400; font-size: .72rem; opacity: .8; margin-top: 1px; }
.nav-item .na { opacity: .6; }
.ni-1 { background: linear-gradient(135deg, #667eea, #764ba2); }
.ni-2 { background: linear-gradient(135deg, #f093fb, #f5576c); }
.ni-3 { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.ni-4 { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.ni-5 { background: linear-gradient(135deg, #fa709a, #fee140); }
.ni-6 { background: linear-gradient(135deg, #30cfd0, #5614b0); }

/* Utilities */
.ta-r { text-align: right; }
.ta-c { text-align: center; }
.fw7 { font-weight: 700; }
.fw6 { font-weight: 600; }
.c-muted { color: var(--muted); }
.c-green  { color: var(--green); }
.c-red    { color: var(--red); }
.d-flex { display: flex; }
.ai-c   { align-items: center; }
.jc-b   { justify-content: space-between; }
.jc-c   { justify-content: center; }
.jc-e   { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.gap1 { gap: .25rem; }
.gap2 { gap: .5rem; }
.gap3 { gap: .75rem; }
.w100 { width: 100%; }
.mb0 { margin-bottom: 0 !important; }
.mb2 { margin-bottom: .5rem; }
.mb3 { margin-bottom: .85rem; }
.mb4 { margin-bottom: 1.25rem; }
.mt2 { margin-top: .5rem; }
.mt3 { margin-top: .85rem; }
.mt4 { margin-top: 1.25rem; }
small, .small { font-size: .78rem; }
code { font-size: .82rem; background: #f4f4f5; padding: .1em .35em; border-radius: 4px; font-family: monospace; }
