/*
 * REOSIT ERP — interface styles
 * © 2026 REOSIT Pvt Ltd. All rights reserved. Contact: 9471308002
 */
:root {
  --erp-sidebar-w: 248px;
  --erp-topbar-h: 56px;
  --erp-sidebar-bg: #16222e;
  --erp-sidebar-fg: #b9c6d2;
  --erp-sidebar-muted: #6e8295;
  --erp-sidebar-active: #22364a;
  --erp-accent: #1b6fa8;
  --erp-accent-dark: #145580;
  --erp-bg: #f2f4f7;
  --erp-surface: #ffffff;
  --erp-border: #dde2e8;
  --erp-text: #1d2733;
  --erp-muted: #637282;
  --bs-primary: #1b6fa8;
  --bs-primary-rgb: 27, 111, 168;
  --bs-link-color: #1b6fa8;
  --bs-link-color-rgb: 27, 111, 168;
  --bs-link-hover-color: #145580;
  --bs-body-font-size: .875rem;
  --bs-body-color: #1d2733;
  --bs-border-color: #dde2e8;
}

html, body { height: 100%; }
body {
  background: var(--erp-bg);
  color: var(--erp-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .875rem;
}

.btn-primary { --bs-btn-bg: var(--erp-accent); --bs-btn-border-color: var(--erp-accent);
  --bs-btn-hover-bg: var(--erp-accent-dark); --bs-btn-hover-border-color: var(--erp-accent-dark);
  --bs-btn-active-bg: var(--erp-accent-dark); --bs-btn-disabled-bg: var(--erp-accent); }
.btn-outline-primary { --bs-btn-color: var(--erp-accent); --bs-btn-border-color: var(--erp-accent);
  --bs-btn-hover-bg: var(--erp-accent); --bs-btn-hover-border-color: var(--erp-accent);
  --bs-btn-active-bg: var(--erp-accent-dark); }
.text-bg-primary { background-color: var(--erp-accent) !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: #6aa7d1; box-shadow: 0 0 0 .2rem rgba(27, 111, 168, .18);
}
.form-check-input:checked { background-color: var(--erp-accent); border-color: var(--erp-accent); }

/* ------------------------------------------------------------------ layout */
.erp-shell { display: flex; min-height: 100vh; }
.erp-sidebar {
  width: var(--erp-sidebar-w); flex: 0 0 var(--erp-sidebar-w);
  background: var(--erp-sidebar-bg); color: var(--erp-sidebar-fg);
  position: fixed; inset: 0 auto 0 0; z-index: 1040;
  display: flex; flex-direction: column; overflow-y: auto;
  transition: transform .2s ease;
}
.erp-brand {
  height: var(--erp-topbar-h); display: flex; align-items: center; gap: .6rem;
  padding: 0 1.1rem; border-bottom: 1px solid rgba(255,255,255,.06);
  color: #fff; text-decoration: none; font-weight: 600; letter-spacing: .02em;
}
.erp-brand:hover { color: #fff; }
.erp-brand-mark {
  width: 30px; height: 30px; border-radius: 6px; background: var(--erp-accent);
  display: grid; place-items: center; font-size: .95rem; color: #fff;
}
.erp-brand small { display: block; font-weight: 400; font-size: .68rem; color: var(--erp-sidebar-muted); letter-spacing: .06em; text-transform: uppercase; }
.erp-nav { padding: .75rem 0 1.5rem; flex: 1; }
.erp-nav-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--erp-sidebar-muted); padding: 1rem 1.25rem .35rem; }
.erp-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .48rem 1.25rem;
  color: var(--erp-sidebar-fg); text-decoration: none; border-left: 3px solid transparent;
}
.erp-nav a:hover { background: rgba(255,255,255,.04); color: #fff; }
.erp-nav a.active { background: var(--erp-sidebar-active); color: #fff; border-left-color: #4aa3df; }
.erp-nav a .bi { font-size: 1rem; width: 1.1rem; text-align: center; opacity: .9; }
.erp-sidebar-foot { padding: .9rem 1.25rem; font-size: .7rem; color: var(--erp-sidebar-muted);
  border-top: 1px solid rgba(255,255,255,.06); }

.erp-main { flex: 1; margin-left: var(--erp-sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.erp-topbar {
  height: var(--erp-topbar-h); background: var(--erp-surface); border-bottom: 1px solid var(--erp-border);
  display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
  position: sticky; top: 0; z-index: 1030;
}
.erp-search { position: relative; flex: 1; max-width: 460px; }
.erp-search .form-control { padding-left: 2.1rem; background: var(--erp-bg); border-color: transparent; }
.erp-search .form-control:focus { background: #fff; }
.erp-search > .bi { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--erp-muted); }
.erp-search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 1050;
  background: #fff; border: 1px solid var(--erp-border); border-radius: .5rem;
  box-shadow: 0 8px 24px rgba(20, 35, 50, .12); max-height: 420px; overflow-y: auto;
}
.erp-search-results:empty { display: none; }
.erp-content { padding: 1.25rem 1.5rem 2rem; flex: 1; }
.erp-footer { padding: .9rem 1.5rem; font-size: .75rem; color: var(--erp-muted);
  border-top: 1px solid var(--erp-border); background: var(--erp-surface); }

.erp-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: .75rem; margin-bottom: 1rem; }
.erp-page-head h1 { font-size: 1.3rem; font-weight: 600; margin: 0; }
.erp-page-head .subtitle { color: var(--erp-muted); margin-top: .15rem; }
.breadcrumb { font-size: .78rem; margin-bottom: .35rem; --bs-breadcrumb-divider-color: var(--erp-muted); }
.breadcrumb a { text-decoration: none; }

/* ------------------------------------------------------------------ surfaces */
.card { border-color: var(--erp-border); border-radius: .5rem; box-shadow: 0 1px 2px rgba(20,35,50,.04); }
.card-header { background: #fff; border-bottom-color: var(--erp-border); font-weight: 600; padding: .7rem 1rem; }
.card-header .small { font-weight: 400; }
.section-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--erp-muted);
  font-weight: 600; margin: 1.25rem 0 .6rem; }
.section-title:first-child { margin-top: 0; }

.kpi { padding: 1rem 1.1rem; }
.kpi-label { font-size: .75rem; color: var(--erp-muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 1.6rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: .78rem; color: var(--erp-muted); }

/* ------------------------------------------------------------------ tables */
.table-erp { margin: 0; font-size: .84rem; }
.table-erp > thead th {
  background: #f7f9fb; color: var(--erp-muted); font-weight: 600; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .04em; border-bottom-width: 1px; white-space: nowrap;
  padding: .6rem .75rem;
}
.table-erp > tbody td { padding: .55rem .75rem; vertical-align: middle; }
.table-erp tbody tr:hover { background: #f8fbfd; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.filter-bar { background: #fff; border: 1px solid var(--erp-border); border-radius: .5rem;
  padding: .75rem; margin-bottom: 1rem; }
.filter-bar .form-control, .filter-bar .form-select { font-size: .84rem; }

.status-badge { font-weight: 500; font-size: .72rem; padding: .35em .7em; white-space: nowrap; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--erp-muted); }
.empty-state .bi { font-size: 2.2rem; display: block; margin-bottom: .6rem; color: #b3bfcb; }

/* permission matrix */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .group-row td { background: #f2f5f8; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--erp-muted); font-weight: 600; }
.matrix .form-check-input { width: 1.1rem; height: 1.1rem; cursor: pointer; }
.matrix .form-check-input:disabled { cursor: not-allowed; }

/* audit diff */
.diff-old { color: #a4262c; text-decoration: line-through; text-decoration-color: rgba(164,38,44,.4); }
.diff-new { color: #1e7b34; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }

.min-w-0 { min-width: 0; }

/* toasts */
.toast-container { z-index: 1090; }

/* htmx loading */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }

/* ------------------------------------------------------------------ login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side {
  background: linear-gradient(160deg, #16222e 0%, #1b3a55 100%); color: #d6e2ec;
  padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side h2 { color: #fff; font-weight: 600; font-size: 1.6rem; }
.auth-side ul { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.auth-side li { padding: .35rem 0; display: flex; gap: .6rem; }
.auth-side li .bi { color: #4aa3df; }
.auth-form { display: grid; place-items: center; padding: 2rem; background: #fff; }
.auth-form .inner { width: 100%; max-width: 360px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 991.98px) {
  .erp-sidebar { transform: translateX(-100%); }
  body.sidebar-open .erp-sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .erp-main { margin-left: 0; }
  .erp-content { padding: 1rem; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media print {
  .erp-sidebar, .erp-topbar, .erp-footer, .no-print { display: none !important; }
  .erp-main { margin: 0; }
  body { background: #fff; }
}

/* notification bell (Phase 10) */
.erp-notif-menu { width: 340px; max-width: calc(100vw - 24px); }
.erp-notif-scroll { max-height: 60vh; overflow-y: auto; }
/* "My work" — big touch targets on phones (Phase 10) */
.erp-work-list .list-group-item { padding-top: .75rem; padding-bottom: .75rem; }
@media (max-width: 575.98px) { .erp-work-list .btn { padding: .45rem .8rem; } }
/* customer portal (Phase 10) */
.portal-body { background: var(--erp-bg, #f4f6f9); }
.portal-nav { background: #12324a; }
.portal-nav .navbar-brand, .portal-nav .nav-link { color: rgba(255,255,255,.85); }
.portal-nav .nav-link:hover, .portal-nav .nav-link.active { color: #fff; }
.portal-nav .nav-link.active { border-bottom: 2px solid #5ab0e6; }
/* reports (Phase 10) */
.erp-report-card:hover { border-color: var(--bs-primary); }
.erp-bar { height: 4px; background: rgba(27,111,168,.12); border-radius: 2px; margin-top: 3px; }
.erp-bar span { display: block; height: 100%; background: #1b6fa8; border-radius: 2px; }

/* 2.1.0 bill / challan item grid: keep every column usable; the table scrolls sideways on phones */
.erp-docgrid { min-width: 920px; }
.erp-docgrid td { padding: .25rem .2rem; }
.erp-docgrid .form-control-sm, .erp-docgrid .form-select-sm { min-width: 0; }
.erp-quick-add { flex: 0 0 auto; }
@media (max-width: 575.98px) {
  [data-erp-charge] .col-5 { flex: 0 0 100%; max-width: 100%; }
  [data-erp-charge] .col-2 { flex: 0 0 30%; max-width: 30%; }
  [data-erp-charge-head] { display: none !important; }
}

/* ------------------------------------------------------------------ 2.3.0 installed app (PWA) */
.erp-offline-bar {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 1090;
  max-width: calc(100% - 2rem); padding: .5rem .9rem; border-radius: .5rem;
  background: #1d2733; color: #fff; font-size: .8rem; box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.erp-install-help { border: 0; border-radius: .75rem; padding: 1.25rem; max-width: 22rem; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.erp-install-help::backdrop { background: rgba(0,0,0,.35); }
.erp-offline-page { min-height: 100vh; display: grid; place-items: center; background: var(--erp-bg); }
/* installed on a phone: keep clear of the notch / home bar */
@media (display-mode: standalone) {
  .erp-topbar { padding-top: env(safe-area-inset-top); height: calc(var(--erp-topbar-h) + env(safe-area-inset-top)); }
  .erp-content { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}

/* ------------------------------------------------------------------ 2.4.0 document verification page */
.erp-verify-page { min-height: 100vh; display: grid; place-items: center; background: var(--erp-bg); padding: 1rem; }
.erp-verify { width: 100%; max-width: 28rem; }
.erp-verify-logo { height: 36px; max-width: 120px; object-fit: contain; }
.erp-verify-badge { display: flex; gap: .75rem; align-items: center; padding: .85rem 1rem; border-radius: .5rem; }
.erp-verify-badge i { font-size: 1.8rem; }
.erp-verify-badge.ok { background: #e7f6ec; color: #16653a; }
.erp-verify-badge.warn { background: #fff4e0; color: #8a5300; }
.erp-verify-badge.bad { background: #fdecec; color: #9b1c1c; }

/* ------------------------------------------------------------------ 2.4.0 comments */
.erp-avatar { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--erp-accent); color: #fff; font-size: .7rem; font-weight: 600; }
.erp-comment-body { font-size: .85rem; white-space: normal; overflow-wrap: anywhere; }
.erp-mention { color: var(--erp-accent); background: rgba(27,111,168,.08); border-radius: .25rem; padding: 0 .15rem; font-weight: 600; }
.erp-mention-menu { position: absolute; left: 0; top: 100%; max-width: 100%; min-width: 16rem; z-index: 1050; }
.erp-mention-menu .dropdown-item { white-space: normal; }

/* ------------------------------------------------------------------ 2.4.0 targets */
.erp-progress { height: .45rem; }
.erp-bronze { color: #b26b2a; }
.erp-target-grid input { min-width: 5.5rem; }

/* ------------------------------------------------------------------ 2.4.0 management dashboard charts */
.erp-chart-wrap { padding: .5rem .75rem; }
.erp-chart { display: block; width: 100%; height: auto; overflow: visible; }
.erp-chart-hit { cursor: default; outline: none; }
.erp-chart-hit.is-on, .erp-chart-hit:focus-visible { fill: rgba(27, 111, 168, .06); }
.erp-chart-cross.is-on, .erp-chart-cross:focus-visible { fill: rgba(27, 111, 168, .05); stroke: none; }
.erp-chart-tip { position: fixed; z-index: 1080; pointer-events: none; background: #fff; color: var(--erp-text);
  border: 1px solid var(--erp-border); border-radius: .375rem; box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: .4rem .6rem; font-size: .78rem; max-width: 18rem; }
.erp-chart-tip-head { font-weight: 600; margin-bottom: .1rem; }
.erp-legend { display: flex; flex-wrap: wrap; gap: .9rem; color: var(--erp-muted); font-weight: 400; }
.erp-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); margin-right: .35rem; vertical-align: -1px; }
.erp-key.line { width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; }
.erp-delta { font-weight: 600; color: var(--erp-text); }
.erp-delta.up i { color: #0ca30c; }
.erp-delta.down i { color: #d03b3b; }
@media print { .erp-chart-tip { display: none !important; } details.card-footer { display: none; } }
.erp-chart-empty { display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 9rem;
  color: var(--erp-muted); font-size: .85rem; background: repeating-linear-gradient(135deg, transparent 0 8px, rgba(0,0,0,.015) 8px 16px); border-radius: .375rem; }
/* on a phone a chart keeps a readable size and scrolls sideways inside its card */
@media (max-width: 575.98px) {
  .erp-chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .erp-chart-wrap .erp-chart { min-width: 500px; }
  .erp-chart-wrap .erp-chart[viewBox^="0 0 1100"] { min-width: 640px; }
}
.erp-mention-menu .dropdown-item.active .text-muted, .erp-mention-menu .dropdown-item:active .text-muted { color: rgba(255,255,255,.85) !important; }
