:root {
  --brand: #1f7a52;
  --brand-strong: #17603f;
  --brand-soft: #e3f2ea;
  --brand-text: #135c3b;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #f6f8f6;
  --text: #1c2a23;
  --text-2: #56675e;
  --text-3: #86958c;
  --border: #e1e7e3;
  --border-strong: #c9d3cd;
  --ok-bg: #e3f2ea; --ok: #17603f;
  --warn-bg: #fbf0d9; --warn: #8a5a0b;
  --bad-bg: #fbe7e6; --bad: #a12b2b;
  --info-bg: #e5eefa; --info: #1d4f8c;
  --muted-bg: #eef1ef; --muted: #5b6862;
  --radius: 10px;
  --sidebar: 232px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #3fb07a; --brand-strong: #5cc48f; --brand-soft: #173a2a; --brand-text: #8fdcb3;
    --bg: #111714; --surface: #18201c; --surface-2: #1e2823; --text: #e6eee9; --text-2: #a7b6ad; --text-3: #7a8a80;
    --border: #2a3630; --border-strong: #3a4a42;
    --ok-bg: #173a2a; --ok: #8fdcb3; --warn-bg: #3d2f12; --warn: #f2c46b; --bad-bg: #432020; --bad: #f19a9a;
    --info-bg: #1b2d47; --info: #9cc3f2; --muted-bg: #242e29; --muted: #a7b6ad;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
p { margin: 0 0 10px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
small, .small { font-size: 12px; }
.muted { color: var(--text-2); }
.block { display: block; }
.mono { font-family: var(--mono); font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.t-ok { color: var(--ok) !important; } .t-warn { color: var(--warn) !important; } .t-bad { color: var(--bad) !important; } .t-info { color: var(--info) !important; }
.ti { font-size: 17px; line-height: 1; vertical-align: -3px; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand b { display: block; font-size: 15px; }
.brand small { display: block; color: var(--text-2); line-height: 1.1; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex: none; }
.sidebar nav { display: grid; gap: 2px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav.on { background: var(--brand-soft); color: var(--brand-text); }
.me { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 4px 0; display: flex; align-items: center; gap: 6px; }
.me-link { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; color: var(--text); }
.me-link:hover { text-decoration: none; }
.me-link b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-link small { display: block; color: var(--text-2); line-height: 1.1; }
.me form { margin: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--info-bg); color: var(--info); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; }
.backdrop { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.menu-btn { display: none; }
.search { flex: 1; max-width: 420px; position: relative; margin: 0; }
.search .ti { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); vertical-align: 0; }
.search input { padding-left: 34px; background: var(--surface-2); }
.topbar .btn { margin-left: auto; }
.content { padding: 24px 28px 32px; width: 100%; max-width: 1280px; }
.foot { padding: 0 28px 20px; color: var(--text-3); font-size: 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); margin-bottom: 8px; font-size: 13px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin: 3px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Controls */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 11px; width: 100%; min-height: 38px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; accent-color: var(--brand); padding: 0; }
input[type=file] { padding: 6px; }
input:disabled { background: var(--surface-2); color: var(--text-2); }
.btn, button.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; padding: 8px 14px; min-height: 38px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
@media (prefers-color-scheme: dark) { .btn.primary, .btn.primary:hover { color: #0c1a12; } }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 16px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metrics.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; color: var(--text); display: block; }
a.metric:hover { border-color: var(--border-strong); text-decoration: none; }
.metric small { color: var(--text-2); font-size: 12.5px; }
.metric b { display: block; font-size: 26px; font-weight: 600; line-height: 1.25; margin: 2px 0; }
.metric span { color: var(--text-3); font-size: 12px; }

.bars { display: grid; gap: 10px; }
.bars a { color: var(--text); display: block; }
.bars a:hover { text-decoration: none; }
.bars a:hover .bar i { background: var(--brand-strong); }
.bar-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

.alerts { display: grid; gap: 4px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 8px; margin: 0 -8px; border-radius: 8px; color: var(--text); }
.alert:hover { background: var(--surface-2); text-decoration: none; }
.alert .ti { color: var(--bad); margin-top: 2px; }
.alert.warn .ti { color: var(--warn); }
.alert.info .ti { color: var(--info); }
.alert small { display: block; color: var(--text-2); }
.activity { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.activity li { display: flex; gap: 10px; align-items: flex-start; }
.activity .ti { color: var(--text-3); margin-top: 2px; }
.activity small { color: var(--text-3); }

/* Flash */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; }
.flash .ti { margin-top: 1px; }
.flash.success { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.warning { background: var(--warn-bg); color: var(--warn); }
.flash.info { background: var(--info-bg); color: var(--info); }

/* Pills */
.pill { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: 999px; white-space: nowrap; vertical-align: 1px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.muted { background: var(--muted-bg); color: var(--muted); }

/* Filters, tabs */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input[name=q] { flex: 1 1 200px; max-width: 280px; }
.filters select { width: auto; max-width: 200px; }
.filters .inline { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.filters .inline input { width: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 8px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.on { color: var(--brand-text); border-color: var(--brand); }

/* Tables */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; margin-bottom: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 3px; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; white-space: nowrap; }
.table td.wrap { white-space: normal; min-width: 200px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table .chk { width: 36px; padding-right: 0; }
.table.compact td, .table.compact th { padding: 7px 10px; }
.card .table th { background: transparent; }
.card > .table { margin: 0 -6px; width: calc(100% + 12px); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; flex-wrap: wrap; }
.pager nav { display: flex; gap: 2px; }
.pager a, .pager .gap { min-width: 32px; height: 32px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; color: var(--text-2); }
.pager a:hover { background: var(--surface); text-decoration: none; }
.pager a.on { background: var(--brand); color: #fff; }
.empty { text-align: center; padding: 40px 20px; }
.empty > .ti { font-size: 34px; color: var(--text-3); }
.empty h2 { margin: 10px 0 4px; }

/* Asset detail */
.asset-hero { padding: 16px 20px; }
.hero-title { font-size: 18px; font-weight: 600; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 16px; align-items: start; }
.detail-grid > .card { margin-bottom: 16px; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; font-weight: 400; color: var(--text-2); padding: 6px 16px 6px 0; width: 150px; vertical-align: top; }
.kv td { padding: 6px 0; }
.qr-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.qr { display: inline-block; background: #fff; padding: 8px; border-radius: 8px; line-height: 0; }
.qr img, .qr canvas { display: block; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 14px; }
.file { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.file > div { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.file img { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; display: block; }
.file-icon { width: 54px; height: 54px; border-radius: 6px; background: var(--bad-bg); color: var(--bad); display: flex; align-items: center; justify-content: center; }
.file-icon .ti { font-size: 26px; }
.upload-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.upload-row input[type=file] { flex: 1 1 220px; }
.upload-row input[name=label] { flex: 1 1 180px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { display: flex; gap: 12px; padding: 0 0 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 8px; top: 22px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li > .ti { color: var(--brand); background: var(--surface); margin-top: 2px; }
.timeline a.small { margin-left: 6px; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.danger-zone p { margin: 0; }

/* Forms */
.form { display: grid; gap: 14px; margin: 0; }
.form > .card { margin-bottom: 0; }
.form .card { display: grid; gap: 14px; }
.form .card h2 { margin: 0; }
.form label { display: block; font-weight: 500; font-size: 13px; }
.form label > input, .form label > select, .form label > textarea { display: block; margin-top: 5px; }
.form label > .err { display: block; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.req { color: var(--bad); }
.err { color: var(--bad); font-weight: 400; }
.has-err input { border-color: var(--bad); }
label.check { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-actions form { margin: 0; }
.dispose-fields:not(.show) { display: none; }
.current { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.current small { display: block; }
.inline-form { display: flex; gap: 8px; margin: 0; align-items: center; }
.inline-form input { max-width: 340px; }
.card > .inline-form { margin-bottom: 14px; }
.master td { vertical-align: middle; }
.master .inline-form input { min-height: 32px; padding: 5px 9px; }
.drop { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 22px; text-align: center; justify-items: center; color: var(--text-2); }
.drop > .ti { font-size: 30px; color: var(--brand); }
.drop > .ti, .drop > span { display: block; margin-bottom: 4px; }
.form .drop input { max-width: 340px; margin: 8px auto 0; }
.steps { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 6px; }

/* Auth */
body.plain { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box .card { padding: 26px; }
.auth-box h1 { margin-bottom: 14px; font-size: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 16px; font-size: 15px; }

/* Print pages */
.print-page { background: #fff; color: #111; padding: 20px; color-scheme: light;
  --brand: #1f7a52; --brand-strong: #17603f; --surface: #fff; --surface-2: #f3f5f3; --text: #111; --text-2: #555; --border: #ddd; --border-strong: #bbb; }
.print-page .btn.primary, .print-page .btn.primary:hover { color: #fff; }
.print-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, 66mm); gap: 4mm; }
.label { width: 66mm; height: 32mm; border: 1px dashed #bbb; border-radius: 2mm; padding: 2.5mm; display: flex; gap: 3mm; align-items: center; overflow: hidden; break-inside: avoid; color: #111; }
.label .qr { padding: 0; }
.label > div:last-child { min-width: 0; font-size: 9pt; line-height: 1.3; }
.label b { font-size: 8pt; color: #444; }
.label .big { font-size: 11pt; font-weight: 700; }
.label small { display: block; font-size: 7.5pt; color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet { max-width: 780px; margin: 0 auto; font-size: 13px; color: #111; }
.sheet-head { display: flex; justify-content: space-between; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 18px; }
.sheet-head h1 { font-size: 22px; }
.sheet h2 { font-size: 14px; margin: 18px 0 8px; }
.sheet-table { width: 100%; border-collapse: collapse; }
.sheet-table th, .sheet-table td { border: 1px solid #999; padding: 7px 9px; text-align: left; }
.sheet-table th { background: #f2f2f2; font-weight: 600; width: 22%; }
.notes-box { border: 1px solid #999; min-height: 60px; padding: 8px; margin-bottom: 14px; }
.signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; margin-top: 60px; text-align: center; }
.signs span { display: block; border-top: 1px solid #111; margin-bottom: 6px; }

@media print {
  .no-print, .sidebar, .topbar, .foot, .actions, .back, .tabs, .filters, .pager, .danger-zone, .upload-row { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card, .table-card { border-color: #ccc; break-inside: avoid; }
  .print-page { padding: 0; }
  .label { border-color: #ddd; }
  @page { margin: 8mm; }
}

/* Responsive */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > .card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 28px; }
  .foot { padding: 0 16px 16px; }
  .metrics, .metrics.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none !important; }
  .danger-zone { flex-direction: column; align-items: flex-start; }
  .filters select, .filters input[name=q] { max-width: none; flex: 1 1 140px; }
}
@media (max-width: 480px) {
  .metric b { font-size: 22px; }
  .kv th { width: 110px; }
  .signs { grid-template-columns: 1fr; gap: 40px; }
}
