:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8fafc; --border: #dde3ea; --text: #1b2430; --muted: #5d6b7c;
  --primary: #1f5fa8; --primary-ink: #ffffff; --primary-soft: #e6eef8;
  --ok: #1e8a4c; --ok-soft: #e3f4ea; --warn: #b26a00; --warn-soft: #fff3dc; --bad: #c0392b; --bad-soft: #fbe7e5;
  --info-soft: #eaf2fb; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--primary); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; } h2 { font-size: 1.15rem; margin: 0 0 .5rem; } h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.container { max-width: 1280px; margin: 0 auto; padding: 16px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--primary); color: #fff; padding: 10px 16px; box-shadow: var(--shadow); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-link { display: inline-flex; align-items: center; gap: 8px; flex: none; color: #fff; text-decoration: none; }
.brand-mark { display: block; width: 34px; height: 34px; }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { padding-left: 10px; border-left: 1px solid rgba(255,255,255,.35); opacity: .95; }
.role-chip { font-size: .7rem; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.2); letter-spacing: .04em; }
.who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.who-name { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .95; font-size: .9rem; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.grid { display: grid; gap: 12px; } .grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row-end { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }

label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; min-height: 40px; width: 100%; }
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.radio-row { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text); font-size: .95rem; }
.radio-row label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-weight: 400; font-size: .95rem; }

.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 8px; border: 1px solid transparent;
  padding: 9px 14px; min-height: 40px; cursor: pointer; background: var(--surface-2); color: var(--text); border-color: var(--border); text-decoration: none; }
.btn:hover { filter: brightness(.97); } .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-bad { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .85rem; } .btn-block { width: 100%; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--primary); border-color: transparent; }
.banner { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; background: var(--info-soft); color: var(--primary); }
.banner-warn { background: var(--warn-soft); color: var(--warn); } .banner-ok { background: var(--ok-soft); color: var(--ok); } .banner-bad { background: var(--bad-soft); color: var(--bad); }
.error { color: var(--bad); font-size: .9rem; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.tbl { border-collapse: collapse; width: 100%; font-size: .88rem; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tbl th { background: var(--surface-2); position: sticky; top: 0; z-index: 1; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tbl tr:hover td { background: #fafcff; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* thumbnails & uploads */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); flex: 0 0 auto; }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.thumb .del { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.thumb .flag { position: absolute; left: 3px; bottom: 3px; font-size: .65rem; padding: 1px 5px; border-radius: 4px; background: var(--bad); color: #fff; font-weight: 700; }
.thumb.uploading img { opacity: .45; }
.thumb .prog { position: absolute; left: 6px; right: 6px; bottom: 8px; height: 7px; border-radius: 99px; background: rgba(255,255,255,.85); overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.1); }
.thumb .prog > i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .15s; }
.thumb .pct { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: var(--text); text-shadow: 0 0 3px #fff; }
.thumb.failed { border-color: var(--bad); } .thumb.failed .pct { color: var(--bad); }
.add-tile { width: 84px; height: 84px; border-radius: 8px; border: 2px dashed var(--border); display: grid; place-items: center; color: var(--primary); cursor: pointer; font-size: .75rem; text-align: center; background: var(--surface); flex: 0 0 auto; padding: 4px; }
.add-tile:hover { border-color: var(--primary); background: var(--primary-soft); }
.add-tile input { display: none; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 10px 16px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* stats */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .sub { font-size: .8rem; color: var(--muted); }
.progressbar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); margin-top: 8px; }
.progressbar > i { display: block; height: 100%; background: var(--primary); }

/* toasts, dialogs */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(92vw, 420px); }
.toast { background: #1b2430; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem; }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--bad); }
dialog.modal { border: 0; border-radius: 12px; padding: 18px; width: min(94vw, 460px); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog.modal form, dialog.modal .body { display: flex; flex-direction: column; gap: 10px; }
dialog::backdrop { background: rgba(15, 23, 42, .55); }
dialog.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
dialog.lightbox[open] { display: grid; place-items: center; }
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 6px; box-shadow: 0 6px 30px rgba(0,0,0,.5); background: #222; }
.lb-close { position: fixed; top: 10px; right: 14px; font-size: 34px; color: #fff; background: none; border: 0; cursor: pointer; z-index: 2; }
.lb-nav { position: fixed; top: 50%; transform: translateY(-50%); font-size: 46px; color: #fff; background: rgba(0,0,0,.35); border: 0; width: 48px; height: 72px; cursor: pointer; border-radius: 8px; }
.lb-prev { left: 8px; } .lb-next { right: 8px; }
.lb-cap { position: fixed; bottom: 12px; left: 0; right: 0; text-align: center; color: #fff; font-size: .9rem; text-shadow: 0 1px 3px #000; padding: 0 12px; }

/* login */
.login-body { background: linear-gradient(160deg, #1f5fa8 0%, #183f6e 100%); min-height: 100vh; }
.login-wrap { min-height: calc(100vh - 32px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.login-footer { color: rgba(255,255,255,.82); font-size: .78rem; text-align: center; max-width: 440px; line-height: 1.5; padding: 0 8px; }
.login-footer div + div { margin-top: 2px; opacity: .85; }
.login-card { width: min(100%, 380px); display: flex; flex-direction: column; gap: 12px; padding: 26px; }
.login-logo { width: 200px; height: auto; align-self: center; margin: 4px 0 8px; }
.login-card h1, .login-card > .muted { text-align: center; }

.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 14px 0 6px; z-index: 5; }
.hidden { display: none !important; }
.skeleton { color: var(--muted); padding: 24px; text-align: center; }

@media (max-width: 640px) {
  .container { padding: 12px; }
  .card { padding: 12px; }
  .who-name { display: none; }
  .tbl { font-size: .82rem; }
  /* keep the sticky header on one row on phones */
  .topbar { flex-wrap: nowrap; padding: 8px 12px; gap: 8px; }
  .brand { gap: 6px; min-width: 0; font-size: .9rem; }
  .brand-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding-left: 8px; }
  .brand-name { display: none; }
  .brand-mark { width: 30px; height: 30px; }
  .role-chip { flex: none; padding: 2px 6px; }
  .who { flex: none; gap: 4px; }
  .topbar .btn-sm { padding: 4px 8px; font-size: .8rem; }
}
@media (max-width: 360px) { .brand-sub { display: none; } }
@media print { .topbar, .sticky-actions, .btn { display: none !important; } }
