:root {
  color-scheme: light;
  --canvas: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #7d8799;
  --line: #e8edf4;
  --navy: #111a2e;
  --nav-muted: #9aa6ba;
  --blue: #5268e8;
  --blue-dark: #4055d6;
  --green: #159b72;
  --amber: #db8d24;
  --coral: #e16e72;
  --shadow: 0 12px 32px rgba(32, 48, 82, .055);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Segoe UI", "Noto Sans Bengali", Tahoma, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-container { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex: 0 0 258px;
  flex-direction: column;
  width: 258px;
  height: 100vh;
  padding: 27px 17px 20px;
  overflow-y: auto;
  color: #fff;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(86, 108, 230, .17), transparent 35%),
    var(--navy);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin: 0 6px 29px;
  color: #fff;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  flex: 0 0 41px;
  width: 41px;
  height: 41px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.17);
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, #7182f5, #4b5cda);
  box-shadow: 0 7px 18px rgba(60, 75, 190, .34);
  font-size: 17px;
}
.brand-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand-copy strong { overflow: hidden; font-size: 14px; letter-spacing: -.15px; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { color: #8d9ab1; font-size: 10px; letter-spacing: 1.15px; text-transform: uppercase; }
.auth-box { min-height: 42px; margin: 0 3px 25px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 650;
  line-height: 1.2;
  transition: background .18s ease, box-shadow .18s ease, transform .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-google {
  width: 100%;
  color: #f6f7fb;
  background: rgba(255,255,255,.075);
  border-color: rgba(255,255,255,.12);
}
.btn-google:hover { background: rgba(255,255,255,.13); }
.user-chip { display: flex; align-items: center; gap: 11px; padding: 10px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(255,255,255,.06); }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.user-info { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.u-name { overflow: hidden; color: #eef1f7; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.logout-link { width: fit-content; padding: 0; border: 0; color: #aab4c6; background: transparent; font-size: 11px; text-align: left; }
.logout-link:hover { color: #fff; }
.nav-caption { margin: 0 11px 11px; color: #748199; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }
.nav-menu { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--nav-muted);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.nav-item i { width: 17px; color: #8491a8; font-size: 14px; text-align: center; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-item:hover i { color: #c5ccfa; }
.nav-item.active { border-color: rgba(145,157,255,.14); color: #fff; background: linear-gradient(100deg, rgba(91,108,231,.28), rgba(91,108,231,.12)); box-shadow: inset 3px 0 #8290ff; }
.nav-item.active i { color: #aab4ff; }

.main-content { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.navbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(22px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.91);
  backdrop-filter: blur(14px);
}
.search-bar {
  display: flex;
  width: min(390px, 48vw);
  min-height: 41px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid #e8ecf3;
  border-radius: 10px;
  color: #8993a5;
  background: #f8f9fc;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.search-bar:focus-within { border-color: #b6bfff; background: #fff; box-shadow: 0 0 0 3px rgba(82,104,232,.09); }
.search-bar input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-bar input::placeholder { color: #98a1b0; }
.search-shortcut { display: grid; width: 22px; height: 22px; flex: 0 0 22px; place-items: center; border: 1px solid #e3e7ef; border-radius: 6px; color: #8993a5; background: #fff; font-size: 13px; }
.nav-actions { display: flex; align-items: center; gap: 16px; }
.secure-label { display: inline-flex; align-items: center; gap: 7px; color: #8993a5; font-size: 11px; white-space: nowrap; }
.secure-label i { color: var(--green); }
.btn-install { min-height: 40px; padding: 8px 12px; border-color: #dfe4ff; color: #4c5fd6; background: #f3f5ff; font-size: 11px; }
.btn-install:hover { background: #e9edff; }
.btn-pdf { min-height: 40px; color: #fff; background: var(--navy); box-shadow: 0 4px 10px rgba(17,26,46,.12); }
.btn-pdf:hover { background: #222e49; box-shadow: 0 7px 16px rgba(17,26,46,.18); }
.offline-banner { position: fixed; z-index: 1100; right: 16px; bottom: 16px; left: 16px; width: fit-content; max-width: min(580px, calc(100vw - 32px)); margin: 0 auto; padding: 12px 16px; border: 1px solid #465574; border-radius: 12px; color: #fff; background: #17233a; box-shadow: 0 12px 32px rgba(15,23,42,.22); font-size: 12px; line-height: 1.5; }
.dashboard-page, .page { width: 100%; max-width: 1500px; margin: 0 auto; padding: 34px clamp(22px, 4vw, 56px) 48px; }
.page { display: none; }
.page.active { display: block; }
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; color: var(--blue); font-size: 10px; font-weight: 750; letter-spacing: 1.45px; text-transform: uppercase; }
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: #6579ee; box-shadow: 0 0 0 4px rgba(101,121,238,.12); }
.page-title { margin: 0; color: var(--ink); font-size: clamp(24px, 2.2vw, 30px); font-weight: 750; letter-spacing: -.8px; }
.page-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.date-chip { display: inline-flex; min-height: 39px; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; color: #69758a; background: var(--surface); font-size: 12px; white-space: nowrap; }
.date-chip i { color: var(--blue); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; margin-bottom: 33px; }
.card { margin: 0 0 20px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.stat-card { position: relative; display: flex; min-height: 150px; align-items: flex-start; justify-content: space-between; overflow: hidden; padding: 22px 22px 20px; }
.stat-card::after { position: absolute; right: -24px; bottom: -44px; width: 124px; height: 124px; border: 1px solid currentColor; border-radius: 50%; content: ""; opacity: .055; }
.sales-card { color: var(--amber); }
.profit-card { color: var(--green); }
.due-card { color: var(--coral); }
.stat-content { position: relative; z-index: 1; }
.stat-title { color: #778297; font-size: 12px; font-weight: 600; }
.stat-value { margin: 12px 0 6px; color: var(--ink); font-size: clamp(23px, 2vw, 29px); font-weight: 750; letter-spacing: -.5px; }
.stat-caption { color: #9aa3b1; font-size: 11px; }
.stat-icon { display: grid; width: 43px; height: 43px; flex: 0 0 43px; place-items: center; border-radius: 13px; font-size: 16px; }
.stat-icon.yellow { color: #c77b18; background: #fff4e3; }
.stat-icon.green { color: #0e9269; background: #e4f7ef; }
.stat-icon.coral { color: #d45e66; background: #fff0ef; }
.section-header, .page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 15px; }
.section-header h2, .page-head h1 { margin: 0; color: var(--ink); font-size: 18px; font-weight: 700; letter-spacing: -.25px; }
.section-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.btn-primary { color: #fff; background: var(--blue); box-shadow: 0 5px 12px rgba(82,104,232,.18); }
.btn-primary:hover { background: var(--blue-dark); box-shadow: 0 7px 16px rgba(82,104,232,.24); }
.btn-secondary { color: #556174; background: #edf0f5; }
.table-card { padding: 0; overflow: hidden; }
.table-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 22px 16px; }
.table-title { margin: 0; color: var(--ink); font-size: 14px; font-weight: 700; }
.table-subtitle { margin: 5px 0 0; color: #9aa3b1; font-size: 11px; }
.table-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid #dff2e9; border-radius: 20px; color: #26825f; background: #f0faf5; font-size: 10px; font-weight: 650; white-space: nowrap; }
.table-badge i { font-size: 6px; }
.table-wrapper, .responsive-list { overflow-x: auto; }
table { width: 100%; margin-top: 0; border-collapse: collapse; }
th, td { padding: 13px 15px; border-bottom: 1px solid #edf0f5; text-align: left; vertical-align: middle; }
th { color: #8993a5; background: #fafbfc; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; white-space: nowrap; }
td { color: #566176; font-size: 12px; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom-color: var(--line); }
.total-row { color: #4a5670; background: #f8f9fc; font-weight: 700; }
.total-row td { color: #4a5670; font-size: 11px; }
.product-img { width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 9px; object-fit: cover; }
.small-btn { padding: 6px 8px; border: 0; border-radius: 6px; color: #fff; font-size: 10px; font-weight: 650; cursor: pointer; }
.danger { color: #fff; background: #dc5558; }
.success { background: #1b9c71; }
.stock-btn { background: #5268e8; }
.barcode-btn { background: #7553cf; }
.center { padding: 26px; color: var(--muted); text-align: center; }
.hint { margin: 8px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.page-head { margin-bottom: 20px; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: center; gap: 10px; }
.scanner-card { max-width: 760px; }
.scanner-actions, .lookup-links { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.barcode-video { display: block; width: 100%; max-height: min(58vh, 480px); margin-top: 16px; border-radius: 12px; background: #101827; object-fit: cover; }
.barcode-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.barcode-form input { width: 100%; min-height: 42px; margin: 5px 0; padding: 9px 11px; border: 1px solid #e2e7ef; border-radius: 9px; outline: 0; color: var(--ink); background: var(--surface); }
.barcode-form input:focus { border-color: #aeb8ff; box-shadow: 0 0 0 3px rgba(82,104,232,.09); }
.lookup-results { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.lookup-code { color: var(--muted); font-size: 12px; font-weight: 650; }
.lookup-code code { margin-left: 5px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface-soft); }
.barcode-product-result { display: flex; align-items: center; gap: 14px; margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.barcode-product-result[hidden], .status-box[hidden] { display: none; }
.barcode-product-image { width: 76px; height: 76px; flex: 0 0 76px; border-radius: 8px; object-fit: cover; background: var(--surface); }
.barcode-product-info { display: grid; gap: 5px; color: var(--ink); font-size: 13px; }
.barcode-product-info p { margin: 0; color: var(--muted); font-size: 11px; }
.barcode-local-price { color: #16845f; font-size: 16px; }
.lookup-links a { text-decoration: none; }
.online-toggle { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; color: var(--ink); font-size: 13px; font-weight: 650; cursor: pointer; }
.settings-form .online-toggle input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--blue); }
.online-products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 14px; margin-top: 16px; }
.online-product-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.online-product-image { display: block; width: 100%; height: 150px; object-fit: cover; background: var(--surface-soft); }
.online-product-info { display: grid; gap: 7px; padding: 13px; }
.online-product-info h3 { margin: 0; color: var(--ink); font-size: 14px; }
.online-product-category, .online-product-stock { margin: 0; color: var(--muted); font-size: 12px; }
.online-product-price { color: #16845f; font-size: 16px; }
.modal { position: fixed; z-index: 1000; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(14,22,40,.55); backdrop-filter: blur(4px); }
.modal-content { width: 100%; max-width: 430px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 24px 70px rgba(10,18,38,.22); }
.modal-content h3 { margin: 0 0 18px; color: var(--ink); font-size: 18px; }
.modal-content label { display: block; color: #667187; font-size: 12px; font-weight: 600; }
.modal-content input, .inline-form input, .inline-form select, .settings-form input, .language-select {
  width: 100%;
  min-height: 41px;
  margin: 5px 0;
  padding: 9px 11px;
  border: 1px solid #e2e7ef;
  border-radius: 9px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.modal-content input:focus, .inline-form input:focus, .inline-form select:focus, .settings-form input:focus, .language-select:focus { border-color: #aeb8ff; box-shadow: 0 0 0 3px rgba(82,104,232,.09); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 14px; }
.settings-form { max-width: 650px; }
.settings-card h3, .agent-card h3, .card > h3 { margin-top: 0; color: var(--ink); font-size: 15px; }
.settings-card hr, hr { height: 1px; margin: 22px 0; border: 0; background: var(--line); }
.status-box { margin-top: 10px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; color: #667187; background: var(--surface-soft); }
.data-danger-zone { padding: 17px; border: 1px solid #f4dddd; border-radius: 12px; background: #fffafa; }
.data-danger-zone h3 { color: #b6484e; }
#school-documents-progress { width: 100%; height: 10px; accent-color: var(--blue); }

body[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0f1726;
  --surface: #172235;
  --surface-soft: #202d42;
  --ink: #edf2fb;
  --muted: #9ba8bc;
  --line: #2b3850;
  --shadow: 0 12px 32px rgba(0,0,0,.13);
}
body[data-theme="dark"] .sidebar { background: #10192a; }
body[data-theme="dark"] .navbar { border-color: var(--line); background: rgba(23,34,53,.93); }
body[data-theme="dark"] .search-bar, body[data-theme="dark"] .search-shortcut, body[data-theme="dark"] .date-chip, body[data-theme="dark"] .status-box { border-color: var(--line); color: var(--muted); background: var(--surface-soft); }
body[data-theme="dark"] .search-bar input { color: var(--ink); }
body[data-theme="dark"] th, body[data-theme="dark"] .total-row { color: #c6d0e0; background: #202d42; }
body[data-theme="dark"] td, body[data-theme="dark"] .total-row td { border-color: var(--line); color: #c6d0e0; }
body[data-theme="dark"] tbody tr:hover { background: #1c2a40; }
body[data-theme="dark"] .modal-content input, body[data-theme="dark"] .inline-form input, body[data-theme="dark"] .inline-form select, body[data-theme="dark"] .settings-form input, body[data-theme="dark"] .language-select { border-color: var(--line); color: var(--ink); background: #111b2d; }
body[data-theme="dark"] .barcode-form input { border-color: var(--line); color: var(--ink); background: #111b2d; }
body[data-theme="dark"] .btn-secondary { color: #d5deed; background: #334159; }
body[data-theme="dark"] .btn-install { border-color: #3d4d7b; color: #c1caff; background: #263453; }
body[data-theme="dark"] .data-danger-zone { border-color: #58363d; background: #2b2029; }
body[data-theme="dark"] .table-badge { border-color: #285340; color: #94dfbc; background: #1c382f; }

body[data-theme="night"] {
  color-scheme: dark;
  --canvas: #171411;
  --surface: #241f1a;
  --surface-soft: #302922;
  --ink: #f5eee4;
  --muted: #b9ad9c;
  --line: #40382f;
  --shadow: 0 12px 32px rgba(0,0,0,.16);
}
body[data-theme="night"] .sidebar { background: #201a15; }
body[data-theme="night"] .navbar { border-color: var(--line); background: rgba(36,31,26,.94); }
body[data-theme="night"] .search-bar, body[data-theme="night"] .search-shortcut, body[data-theme="night"] .date-chip, body[data-theme="night"] .status-box { border-color: var(--line); color: var(--muted); background: var(--surface-soft); }
body[data-theme="night"] .search-bar input { color: var(--ink); }
body[data-theme="night"] th, body[data-theme="night"] .total-row { color: #e2d6c6; background: #302922; }
body[data-theme="night"] td, body[data-theme="night"] .total-row td { border-color: var(--line); color: #e2d6c6; }
body[data-theme="night"] tbody tr:hover { background: #302922; }
body[data-theme="night"] .modal-content input, body[data-theme="night"] .inline-form input, body[data-theme="night"] .inline-form select, body[data-theme="night"] .settings-form input, body[data-theme="night"] .language-select { border-color: var(--line); color: var(--ink); background: #1b1713; }
body[data-theme="night"] .barcode-form input { border-color: var(--line); color: var(--ink); background: #1b1713; }
body[data-theme="night"] .btn-secondary { color: #e5d9c9; background: #4a4034; }
body[data-theme="night"] .btn-install { border-color: #51477a; color: #d0c8ff; background: #332e4a; }
body[data-theme="night"] .data-danger-zone { border-color: #624044; background: #342528; }
body[data-theme="night"] .table-badge { border-color: #3b5948; color: #b3dfc5; background: #27382d; }

@media (max-width: 1000px) {
  .sidebar { flex-basis: 226px; width: 226px; padding-right: 13px; padding-left: 13px; }
  .secure-label { display: none; }
  .stats-grid { gap: 12px; }
  .stat-card { padding: 19px; }
  th, td { padding-right: 11px; padding-left: 11px; }
}
@media (max-width: 760px) {
  .sidebar { position: relative; flex-basis: 100%; width: 100%; height: auto; padding: 13px 16px; }
  .app-container { display: block; }
  .brand { min-height: 40px; margin: 0 0 12px; }
  .brand-mark { width: 36px; height: 36px; flex-basis: 36px; border-radius: 11px; }
  .auth-box { position: absolute; top: 14px; right: 16px; width: auto; min-height: 0; margin: 0; }
  .auth-box .btn-google { width: auto; min-height: 36px; padding: 8px 11px; font-size: 11px; }
  .user-chip { padding: 4px; border: 0; background: transparent; }
  .user-avatar { width: 32px; height: 32px; }
  .user-info { display: none; }
  .nav-caption { display: none; }
  .nav-menu { display: flex; flex-direction: row; gap: 5px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .nav-menu::-webkit-scrollbar { display: none; }
  .nav-item { min-height: 37px; flex: 0 0 auto; gap: 7px; padding: 8px 10px; font-size: 11px; white-space: nowrap; }
  .nav-item i { width: auto; font-size: 12px; }
  .nav-item.active { box-shadow: inset 0 -2px #8290ff; }
  .navbar { position: relative; min-height: 63px; flex-wrap: wrap; padding: 11px 18px; }
  .search-bar { width: min(390px, 58vw); }
  .btn-pdf { min-height: 38px; padding: 8px 11px; font-size: 11px; }
  .dashboard-page, .page { padding: 25px 18px 34px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .due-card { grid-column: span 2; }
}
@media (max-width: 480px) {
  .navbar { align-items: stretch; flex-direction: column; gap: 9px; }
  .search-bar { width: 100%; }
  .nav-actions { justify-content: flex-end; }
  .page-intro { align-items: flex-start; flex-direction: column; gap: 13px; }
  .page-title { font-size: 24px; }
  .date-chip { min-height: 33px; font-size: 11px; }
  .stats-grid { grid-template-columns: 1fr; gap: 10px; margin-bottom: 26px; }
  .due-card { grid-column: auto; }
  .stat-card { min-height: 128px; }
  .section-header { align-items: flex-start; }
  .section-header h2 { font-size: 16px; }
  .section-header .btn { flex: 0 0 auto; padding: 8px 10px; font-size: 11px; }
  .table-heading { padding: 16px; }
  .card { padding: 17px; }
  .table-card { padding: 0; }
  .table-heading { padding: 16px; }
  .page-head { align-items: flex-start; }
  .inline-form { grid-template-columns: 1fr; }
  .barcode-form { grid-template-columns: 1fr; }
}
