/* =============================================================================
   Y-PRMS — application chrome
   Auth screens, role-gated consoles, portfolio charts, chat, store, activity.
   Loaded after styles.css so it can refine the base sheet styling.
   ========================================================================== */

/* ---------- Boot & login ---------- */
.boot-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 24px;
}
.boot-screen.hidden { display: none !important; }
.boot-screen.fatal { color: var(--danger); }
.boot-screen p { margin: 0; max-width: 560px; line-height: 1.65; }
.boot-screen code {
  background: #eef1f5;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
  color: var(--text);
}
.boot-spinner {
  width: 34px; height: 34px;
  border: 3px solid #dbe2ea;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: yp-spin 0.8s linear infinite;
}
.boot-screen.fatal .boot-spinner { display: none; }
@keyframes yp-spin { to { transform: rotate(360deg); } }

.login-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 150;
  background:
    radial-gradient(1200px 600px at 15% -10%, #dbeafe 0%, transparent 55%),
    radial-gradient(900px 500px at 110% 110%, #e0e7ff 0%, transparent 55%),
    var(--bg);
}
.login-screen.show { display: flex; }

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 32px 30px 26px;
  width: min(410px, 100%);
}
.login-brand { text-align: center; margin-bottom: 26px; }
/* The wordmark is a white-background JPEG-sourced PNG, so it sits directly on
   the white card with no visible edge. Height drives the size; width follows. */
.login-logo {
  display: block;
  width: auto;
  height: 54px;
  max-width: 82%;
  margin: 0 auto 18px;
}
.login-brand h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.login-brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 6px 8px;
  opacity: 0.55;
  border-radius: 6px;
}
.pw-toggle:hover { opacity: 1; background: #f1f5f9; }

.btn-block { width: 100%; padding: 11px 16px; font-size: 0.95rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-error {
  display: none;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.83rem;
  margin-bottom: 14px;
  line-height: 1.45;
}
.login-error.show { display: block; }

.login-foot {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

.hint { display: block; color: var(--muted); font-size: 0.74rem; margin-top: 5px; }
.check-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.88rem; font-weight: 500; color: var(--text);
  padding: 10px 0;
}
.check-line input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- App shell / header ---------- */
.app-shell.hidden { display: none !important; }

header.app-header { padding: 10px 20px; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-logo {
  display: block;
  width: auto;
  height: 32px;
  flex-shrink: 0;
}
.brand-rule {
  width: 1px;
  height: 30px;
  background: var(--border);
  flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand h1 { font-size: 1.02rem; margin: 0; letter-spacing: -0.01em; }
.brand p { margin: 1px 0 0; color: var(--muted); font-size: 0.73rem; }

.tab-bar { display: flex; gap: 4px; flex: 1; justify-content: center; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 8px 15px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: #f1f5f9; color: var(--text); }
.tab.active { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; }
.tab.hidden { display: none !important; }
.tab-badge {
  display: inline-block;
  margin-left: 7px;
  background: var(--danger);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
}
.tab-badge.hidden { display: none !important; }

.tab-panel.hidden { display: none !important; }

.conn-dot { font-size: 0.7rem; color: var(--done); line-height: 1; }
.conn-dot.offline { color: var(--notdone); }

.user-menu-wrap { position: relative; }
.user-chip { padding: 4px 12px 4px 5px; text-align: left; }
.user-chip-text { display: flex; flex-direction: column; line-height: 1.15; }
.user-chip-text small { font-size: 0.66rem; color: var(--muted); text-transform: capitalize; }
.user-chip:hover .user-chip-text small { color: inherit; }

.user-menu {
  position: absolute;
  top: 42px; right: 0;
  width: 236px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 65;
  overflow: hidden;
}
.user-menu.hidden { display: none !important; }
.um-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.8rem;
}
.um-head span { color: var(--muted); font-size: 0.76rem; }
.um-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 11px 14px;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  color: var(--text);
}
.um-item:hover { background: #f8fafc; color: var(--danger); }

.role-pill {
  display: inline-block;
  align-self: flex-start;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.66rem !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-admin  { background: #ede9fe; color: #5b21b6 !important; }
.role-master { background: #dbeafe; color: #1e40af !important; }
.role-user   { background: #f1f5f9; color: #475569 !important; }

.master-only.hidden, .admin-only.hidden { display: none !important; }

/* ---------- Portfolio roll-up ---------- */
.portfolio {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.portfolio.hidden { display: none !important; }

.pf-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.pf-stat {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  background: #fbfcfe;
}
.pf-stat b { display: block; font-size: 1.45rem; line-height: 1.15; letter-spacing: -0.02em; }
.pf-stat span {
  display: block;
  font-size: 0.71rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 3px;
}
.pf-stat.bad b { color: var(--danger); }
.pf-stat.good b { color: var(--done); }

/* ---------- Card pie ---------- */
/* Belt-and-braces: a Chart.js canvas must never paint outside its box, or it
   overlaps whatever follows it in the flow. */
.card-chart canvas { max-width: 100%; max-height: 100%; display: block; }

.card-chart { display: flex; align-items: center; gap: 14px; margin-top: 2px; }
.card-pie {
  position: relative;
  width: 98px;
  height: 98px;
  flex-shrink: 0;
  overflow: hidden;
}
.card-pie .pie-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.card-pie .pie-center b { font-size: 1.15rem; letter-spacing: -0.02em; line-height: 1; }
.card-pie .pie-center span {
  font-size: 0.58rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.card-legend { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.card-legend div { display: flex; align-items: center; gap: 7px; font-size: 0.76rem; color: var(--muted); }
.card-legend i { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.card-legend b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }

.no-data-note { font-size: 0.78rem; color: var(--muted); text-align: center; padding: 26px 0; flex: 1; }

/* Push the footer to the bottom so tiles line up on a row. */
.project-card .card-footer { margin-top: auto; }

/* ---------- Chat-style comments ---------- */
.panel-content.chat { background: #f7f9fc; padding: 14px; }

.chat-msg { display: flex; gap: 9px; margin-bottom: 14px; align-items: flex-start; }
.chat-msg.mine { flex-direction: row-reverse; }

.chat-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 15px;
}

.chat-bubble-wrap { max-width: 78%; min-width: 0; }
.chat-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.7rem;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.chat-msg.mine .chat-meta { justify-content: flex-end; }
.chat-meta .c-name { font-weight: 700; color: var(--text); font-size: 0.76rem; }
.chat-meta .c-code {
  background: #e8edf4;
  color: #475569;
  border-radius: 4px;
  padding: 0 5px;
  font-weight: 700;
  font-size: 0.64rem;
  letter-spacing: 0.02em;
}
.chat-meta .c-time { color: var(--muted); }

.chat-bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 3px;
  padding: 8px 11px;
  font-size: 0.87rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.chat-msg.mine .chat-bubble {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  border-radius: 12px 12px 3px 12px;
}
.chat-msg.mine .chat-bubble .mention { color: #bfdbfe; }

.chat-day { text-align: center; font-size: 0.7rem; color: var(--muted); margin: 4px 0 14px; }
.chat-day span { background: #e8edf4; padding: 2px 11px; border-radius: 999px; font-weight: 600; }

.chat-empty { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 40px 12px; line-height: 1.6; }

.chat-composer { display: flex; gap: 8px; align-items: flex-end; }
.chat-composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 132px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.87rem;
  line-height: 1.4;
}
.chat-composer textarea:focus { outline: none; border-color: var(--primary); }
.chat-send {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-send:hover { background: var(--primary-hover); }
.chat-send:disabled { background: #cbd5e1; cursor: not-allowed; }

/* ---------- Sheet tabs (Mech / Base VMC / BOP / Quality) ---------- */
.sheet-tabs {
  display: flex;
  gap: 3px;
  margin: 14px 0 0;
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
}
.sheet-tab {
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  border-radius: 8px 8px 0 0;
  padding: 9px 18px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  bottom: -2px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.sheet-tab:hover { background: #f1f5f9; color: var(--text); }
.sheet-tab.active {
  background: var(--card);
  color: var(--primary);
  border-color: var(--border);
  border-bottom: 2px solid var(--card);
}
/* Row count / completion badge on each tab. */
.sheet-tab .st-count {
  font-size: 0.7rem;
  font-weight: 700;
  background: #eef1f5;
  color: #64748b;
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 20px;
  text-align: center;
}
.sheet-tab.active .st-count { background: #dbeafe; color: #1e40af; }
.sheet-tab .st-warn { color: var(--danger); font-weight: 800; font-size: 0.72rem; }
.sheet-tab.is-empty { color: #94a3b8; }

/* ---------- BOP and Quality tabs (both card views) ---------- */
.bop-view.hidden, .bop-detail.hidden,
#bop-cards-wrap.hidden, #bom-cards-wrap.hidden { display: none !important; }
.bop-hint { margin: 14px 0 16px; color: var(--muted); font-size: 0.85rem; line-height: 1.6; }

.bop-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.bop-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  text-align: left;
  font: inherit;
  color: inherit;
}
.bop-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.13);
  transform: translateY(-2px);
}
.bop-card-head { display: flex; align-items: center; gap: 10px; }
.bop-badge {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: #eef2ff;
  color: var(--primary);
  font-weight: 800;
  font-size: 0.82rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bop-card-title { min-width: 0; flex: 1; }
.bop-card-title strong { display: block; font-size: 0.95rem; word-break: break-word; }
.bop-card-title span { font-size: 0.72rem; color: var(--muted); }
.bop-card-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.bop-chip {
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #475569;
  border-radius: 5px;
  padding: 2px 8px;
  font-weight: 600;
}
.bop-chip.warn { background: #fff7ed; color: #b45309; }
.bop-chip.none { background: transparent; color: #94a3b8; font-weight: 400; }

/* ---------- BOP indent state: yellow not indented, red awaiting PO, green PO ---------- */
.bop-card.st-open     { background: #fefce8; border-color: #facc15; border-left: 6px dashed #eab308; }
.bop-card.st-partial  { background: #fef9c3; border-color: #eab308; border-left: 6px solid #ca8a04; }
.bop-card.st-partial:hover { border-color: #ca8a04; box-shadow: 0 6px 18px rgba(202, 138, 4, 0.2); }
.bop-indent-pill.st-partial  { background: #fde047; color: #713f12; }
.bop-legend-key.st-partial::before { background: #ca8a04; }
.bop-toolbar.st-partial { background: #fef9c3; border-left-color: #ca8a04; }
/* An indented BOP's lines: green once on a PO, red until then. */
table.bop-table tr.bop-ord-yes td { background: #dcfce7; }
table.bop-table tr.bop-ord-no td  { background: #fee2e2; }
table.bop-table tr.bop-ord-yes td.bop-sno { box-shadow: inset 4px 0 0 #16a34a; }
table.bop-table tr.bop-ord-no td.bop-sno  { box-shadow: inset 4px 0 0 #dc2626; }
.bop-card.st-indented { background: #fef2f2; border-color: #fca5a5; border-left: 6px solid #dc2626; }
.bop-card.st-po       { background: #f0fdf4; border-color: #86efac; border-left: 6px solid #16a34a; }
.bop-card.st-open:hover     { border-color: #eab308; box-shadow: 0 6px 18px rgba(234, 179, 8, 0.18); }
.bop-card.st-indented:hover { border-color: #dc2626; box-shadow: 0 6px 18px rgba(220, 38, 38, 0.15); }
.bop-card.st-po:hover       { border-color: #16a34a; box-shadow: 0 6px 18px rgba(22, 163, 74, 0.15); }

.bop-indent-pill {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
.bop-indent-pill.st-open     { background: #fef08a; color: #854d0e; }
.bop-indent-pill.st-indented { background: #fecaca; color: #991b1b; }
.bop-indent-pill.st-po       { background: #bbf7d0; color: #166534; }

.bop-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.bop-legend-key { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; }
.bop-legend-key::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.bop-legend-key.st-open::before     { background: #facc15; }
.bop-legend-key.st-indented::before { background: #dc2626; }
.bop-legend-key.st-po::before       { background: #16a34a; }

/* The strip above an open BOP: its purchase state, Import, Indent BOP. */
.bop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-left: 6px solid #cbd5e1;
  border-radius: var(--radius);
  background: var(--card);
}
.bop-toolbar.st-open     { background: #fefce8; border-left-color: #eab308; }
.bop-toolbar.st-indented { background: #fef2f2; border-left-color: #dc2626; }
.bop-toolbar.st-po       { background: #f0fdf4; border-left-color: #16a34a; }
.bop-toolbar-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.bop-toolbar-info .sub { font-size: 0.8rem; color: var(--muted); }

/* BOP import dialog: which section each table lands in. */
.bop-import-assign { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; }
.bop-import-block { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.82rem; }
.bop-import-block select { width: auto; min-width: 130px; }
.bop-import-block .sub { font-size: 0.74rem; color: var(--muted); }
.bop-import-sec { margin: 14px 0 6px; font-size: 0.82rem; letter-spacing: 0.02em; }

/* ---------- BOP document ---------- */
.bop-doc { margin-top: 10px; }

.bop-section { margin-bottom: 30px; }

.bop-sheet-wrap {
  border: 2px solid #94a3b8;
  border-radius: 4px;
  overflow: auto;
  max-height: calc(100vh - 380px);
  background: #fff;
}

table.bop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
table.bop-table th, table.bop-table td {
  border: 1px solid #94a3b8;
  padding: 5px 7px;
  text-align: center;
  vertical-align: middle;
}

/* Document masthead, mirroring the source workbook. */
table.bop-table tr.bop-org td {
  background: #efeee4;
  font-weight: 400;               /* only the mark is bold — see .org-mark */
  font-size: 1rem;
  padding: 9px;
  letter-spacing: 0.01em;
}

/* The company mark: "YANTRIK" bold in the brand maroon, the rest plain. */
.org-mark {
  font-weight: 800;
  color: var(--brand-maroon);
  letter-spacing: 0.02em;
}
table.bop-table tr.bop-title td {
  background: #efeee4;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 9px;
}
table.bop-table tr.bop-meta td { background: #efeee4; padding: 5px 8px; }
table.bop-table tr.bop-meta td.k { text-align: left; font-weight: 700; width: 190px; }
table.bop-table tr.bop-meta td.v { font-weight: 700; font-size: 0.95rem; }

table.bop-table thead th {
  background: #efeee4;
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: inset 0 -2px 0 0 #94a3b8;
}

/* Amber row = quantity still to be confirmed, exactly as in the source file. */
table.bop-table tr.bop-pending td { background: #ffc000; }
table.bop-table tr.bop-pending input { color: #4a3000; font-weight: 700; }

table.bop-table td.bop-sno { width: 58px; color: var(--muted); font-weight: 700; }
table.bop-table td.bop-del { width: 38px; }

table.bop-table input.bop-in {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  padding: 4px 3px;
  border-radius: 4px;
  color: inherit;
}
table.bop-table input.bop-in:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}
table.bop-table input.bop-in[readonly] { cursor: default; }
table.bop-table td.bop-desc input { text-align: left; }

/* Successive rows sharing a DESCRIPTION read as one block, the way the
   merged cells do in the workbook. Merged for real in Excel and in print. */
table.bop-table tr.bop-group-mid td.bop-desc,
table.bop-table tr.bop-group-mid td.bop-desc input { color: #94a3b8; }
table.bop-table tr.bop-group-mid td.bop-desc { border-top-style: dashed; }

.bop-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.bop-section-head h3 { margin: 0; font-size: 0.95rem; letter-spacing: 0.02em; }
.bop-section-head .sub { font-size: 0.78rem; color: var(--muted); }
.bop-section-tools { display: flex; gap: 8px; }

.bop-empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

/* ---------- Quality BOM document ----------
   Built on the BOP document styles; only what the quality workbook does
   differently is restated here — the peach banner, the yellow assembly bands
   and the dark-gold column heads. */
table.bom-table tr.bom-title td {
  background: #f2c9a8;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 10px;
}
table.bom-table tr.bom-meta td { padding: 3px 8px; }
table.bom-table tr.bom-meta td.k {
  text-align: left;
  font-weight: 700;
  width: 150px;
  background: #fff;
}
table.bom-table tr.bom-meta td.v { font-weight: 700; }
table.bom-table thead th { background: #b8860b; color: #1a1f29; }

table.bom-table tr.bom-group td {
  background: #ffff00;
  padding: 2px 6px;
}
.bom-group-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
table.bom-table input.bom-group-in {
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}
table.bom-table input.bom-group-in:focus { background: #fffde0; }
.bom-group-tools { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ---------- BOM status column ----------
   Frosted-glass tints: a translucent wash of the status colour over the white
   sheet, a matching hairline, and a soft inner highlight for the glass edge.
   Because the fills are rgba, the cell underneath still reads through. */
table.bom-table td.bom-status-cell {
  padding: 3px 5px;
  transition: background-color 0.15s;
}
table.bom-table select.bom-status {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
  text-align-last: center;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: none;
  color: inherit;
  backdrop-filter: saturate(1.4) blur(3px);
  -webkit-backdrop-filter: saturate(1.4) blur(3px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
table.bom-table select.bom-status:focus {
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75),
              0 0 0 2px rgba(37, 99, 235, 0.28);
}
table.bom-table select.bom-status:disabled { cursor: default; opacity: 1; }

/* OK — green */
table.bom-table td.st-ok { background: rgba(34, 197, 94, 0.10); }
table.bom-table select.st-ok {
  background-color: rgba(34, 197, 94, 0.16);
  border-color: rgba(21, 128, 61, 0.32);
  color: #15803d;
}
/* Not Ok — red */
table.bom-table td.st-not-ok { background: rgba(239, 68, 68, 0.10); }
table.bom-table select.st-not-ok {
  background-color: rgba(239, 68, 68, 0.16);
  border-color: rgba(185, 28, 28, 0.32);
  color: #b91c1c;
}
/* Rework — orange */
table.bom-table td.st-rework { background: rgba(249, 115, 22, 0.11); }
table.bom-table select.st-rework {
  background-color: rgba(249, 115, 22, 0.18);
  border-color: rgba(194, 65, 12, 0.32);
  color: #c2410c;
}
/* Under Check Process — blue */
table.bom-table td.st-check { background: rgba(59, 130, 246, 0.10); }
table.bom-table select.st-check {
  background-color: rgba(59, 130, 246, 0.16);
  border-color: rgba(29, 78, 216, 0.30);
  color: #1d4ed8;
}

/* No PO — grey, locked until the part is on a purchase order */
table.bom-table td.st-nopo { background: rgba(148, 163, 184, 0.12); }
table.bom-table select.st-nopo {
  background-color: rgba(148, 163, 184, 0.16);
  border-color: rgba(100, 116, 139, 0.30);
  color: #64748b;
}
/* PO Generated — indigo, waiting for an inspection result */
table.bom-table td.st-pogen { background: rgba(99, 102, 241, 0.10); }
table.bom-table select.st-pogen {
  background-color: rgba(99, 102, 241, 0.16);
  border-color: rgba(67, 56, 202, 0.30);
  color: #4338ca;
}

/* The dropdown list itself is drawn by the OS — keep it legible on white. */
table.bom-table select.bom-status option { background: #fff; color: var(--text); }

/* Static preview inside the import dialog: same tints, no control. */
.import-preview td.bom-status-cell {
  font-weight: 700;
  font-size: 0.74rem;
}
.import-preview td.st-ok      { color: #15803d; }
.import-preview td.st-not-ok  { color: #b91c1c; }
.import-preview td.st-rework  { color: #c2410c; }
.import-preview td.st-check   { color: #1d4ed8; }

/* ---------- BOM import dialog ---------- */
.import-warn {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.import-help { margin: 0 0 14px; font-size: 0.82rem; color: var(--muted); line-height: 1.6; }
.import-file { display: block; width: 100%; font-size: 0.84rem; }
.import-or {
  margin: 14px 0 8px;
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.import-paste {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.5;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
.import-paste:focus { outline: none; border-color: var(--primary); }

.import-result:not(:empty) { margin-top: 16px; }
.import-summary { margin: 0 0 6px; font-size: 0.86rem; }
.import-meta { margin: 0 0 8px; font-size: 0.78rem; color: var(--muted); }
.import-error {
  margin: 0;
  font-size: 0.84rem;
  color: var(--danger);
  font-weight: 600;
  line-height: 1.6;
}
.import-warn-line { margin: 0 0 4px; font-size: 0.78rem; color: var(--warn); }

/* The preview is the real BOM table, so it reads exactly as it will look. */
.import-preview {
  margin-top: 10px;
  border: 2px solid #94a3b8;
  border-radius: 4px;
  overflow: auto;
  max-height: 320px;
  background: #fff;
}
.import-preview table.bom-table td,
.import-preview table.bom-table th,
.import-preview table.bop-table td,
.import-preview table.bop-table th { padding: 3px 6px; font-size: 0.78rem; }
.import-preview table.bop-table td.bop-desc { text-align: left; }
.import-preview table.bom-table tr.bom-group td {
  font-weight: 800;
  letter-spacing: 0.02em;
}

@media print {
  .bop-sheet-wrap { max-height: none; overflow: visible; }
  #bop-back, #bom-back, .bop-section-tools, .bop-hint { display: none !important; }
  table.bop-table td.bop-del { display: none !important; }
  .bom-group-tools { display: none !important; }
  table.bop-table tr.bop-pending td,
  table.bom-table tr.bom-title td,
  table.bom-table tr.bom-group td,
  table.bom-table td.bom-status-cell,
  table.bom-table select.bom-status,
  table.bom-table thead th {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  /* A dropdown prints as a boxed control; flatten it to plain coloured text. */
  table.bom-table select.bom-status {
    border-color: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ---------- Console shared ---------- */
.console-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.console-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -0.02em; }
.console-sub { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }
.console-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* A read-only account, or one told which areas it holds. */
.readonly-banner {
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.83rem;
  margin-bottom: 14px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 9px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}
.readonly-banner.hidden { display: none !important; }

/* ---------- User console ---------- */
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 14px;
}
.user-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.user-card.inactive { opacity: 0.62; background: #fbfbfc; }
.uc-head { display: flex; align-items: center; gap: 11px; }
.uc-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.95rem;
  flex-shrink: 0;
}
.uc-id { min-width: 0; flex: 1; }
.uc-id strong { display: block; font-size: 0.95rem; word-break: break-word; }
.uc-id span { font-size: 0.76rem; color: var(--muted); }
.uc-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.uc-actions { display: flex; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: auto; }
.uc-actions .btn { flex: 1; }
.uc-tag { font-size: 0.7rem; color: var(--muted); background: #f1f5f9; border-radius: 5px; padding: 2px 8px; }
.uc-tag.off { background: #fee2e2; color: #991b1b; font-weight: 700; }

.empty-note {
  grid-column: 1 / -1;
  text-align: center;
  padding: 46px 20px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ---------- Store (Challan / Bill / Inventory) ---------- */
#panel-store .sheet-tabs { margin-top: 0; }
#panel-store .sheet-filters { margin: 4px 0 12px; }
#panel-store #store-portfolio { margin: 0 0 4px; }

/* The registers are wider than a tracking sheet, so they scroll sideways
   inside their own box rather than pushing the page out.  The height cap from
   .sheet-wrap is kept deliberately — without a bounded container the sticky
   column headings have nothing to stick to. */
table.store-sheet { min-width: 1100px; }
table.store-sheet td { vertical-align: middle; }

/* Free-text fields (party, description, remarks) get the room they need. */
table.store-sheet th.col-wide, table.store-sheet td.col-wide { min-width: 210px; }

/* Calculated columns are output, not input: flat, right-aligned, never typed
   into, and tinted so they read differently from the editable cells. */
table.store-sheet th.col-calc { background: #dbeafe; color: #1e40af; }
table.store-sheet td.col-calc {
  background: #f8fafc;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
table.store-sheet td.calc-value { font-weight: 700; color: var(--text); }

table.store-sheet .cell-money { text-align: right; }

/* Derived state — the stock flag. Editable statuses keep using .status-select. */
.store-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.store-ok   { background: #dcfce7; color: #166534; }
.store-wait { background: #ffedd5; color: #c2410c; }
.store-bad  { background: #fee2e2; color: #991b1b; }
.store-off  { background: #f1f5f9; color: #64748b; }

/* The same four tints on a status dropdown. */
select.status-select.store-ok   { background: #dcfce7; color: #166534; }
select.status-select.store-wait { background: #ffedd5; color: #c2410c; }
select.status-select.store-bad  { background: #fee2e2; color: #991b1b; }
select.status-select.store-off  { background: #f1f5f9; color: #64748b; }

/* ---------- Purchase (indents, quotations, POs) ---------- */
#panel-purchase .sheet-tabs { margin-top: 0; }
#panel-purchase .sheet-filters { margin: 4px 0 12px; }
#panel-purchase #purchase-portfolio { margin: 0 0 4px; }

table.purchase-sheet tr.purchase-row { cursor: pointer; }
table.purchase-sheet tr.purchase-row:hover td { background: #f8fafc; }
table.purchase-sheet td { white-space: normal; }
table.purchase-sheet td.col-sno { white-space: nowrap; }
table.purchase-sheet .txt-left { text-align: left; padding-left: 10px; }
table.purchase-sheet .txt-right { text-align: right; padding-right: 10px; font-weight: 600; color: #475569; }
table.purchase-sheet .num { text-align: right; padding-right: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.purchase-sheet th.col-wide, table.purchase-sheet td.col-wide { min-width: 210px; }
table.purchase-sheet small.muted, .form-table small.muted { display: block; color: var(--muted); font-size: 0.74rem; }

.l1-cell { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.l1-cell small { color: var(--muted); font-size: 0.72rem; }
.po-late { color: var(--danger); font-weight: 700; }

/* The indent document: header card, then materials, then quotations. Its
   tables grow to their content rather than scrolling inside a capped box. */
.indent-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin: 8px 0 20px;
}
.indent-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.indent-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.indent-title h2 { margin: 0; font-size: 1.2rem; letter-spacing: -0.01em; }
.indent-tools { display: flex; gap: 8px; }
.indent-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px 18px;
  margin: 14px 0 0;
}
.indent-meta dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.indent-meta dd { margin: 2px 0 0; font-weight: 600; word-break: break-word; }
.indent-remarks { margin: 12px 0 0; padding: 8px 12px; background: #f8fafc; border-radius: 8px; font-size: 0.86rem; white-space: pre-wrap; }
.sheet-wrap.indent-wrap { max-height: none; min-height: 0; margin-bottom: 22px; }
.indent-wrap table.store-sheet { min-width: 760px; }

/* Comparative statement. Two heading rows, so the headings do not stick. */
table.compare-sheet thead th { position: static; }
table.compare-sheet th.q-vendor { font-size: 0.8rem; text-transform: none; letter-spacing: 0; min-width: 220px; }
table.compare-sheet th.q-vendor strong { display: block; font-size: 0.86rem; }
table.compare-sheet th.q-vendor small { display: block; font-weight: 400; color: var(--muted); }
.q-rank {
  display: inline-block;
  margin: 3px 3px 0;
  font-size: 0.68rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 8px;
  background: #e2e8f0;
  color: #475569;
}
.q-rank.l1 { background: #dcfce7; color: #166534; }
.q-rank.ok { background: #16a34a; color: #fff; }
table.compare-sheet .q-l1 { background: #f0fdf4; }
table.compare-sheet th.q-l1 { background: #dcfce7; }
table.compare-sheet .q-approved { background: #dcfce7; }
table.compare-sheet th.q-approved { background: #bbf7d0; }
table.compare-sheet .q-dim { color: #94a3b8; }
table.compare-sheet td.q-best { color: #15803d; font-weight: 800; }
table.compare-sheet tr.q-foot td { background-color: #fbfcfd; }
table.compare-sheet tr.q-foot td.q-l1 { background: #f0fdf4; }
table.compare-sheet tr.q-foot td.q-approved { background: #dcfce7; }
table.compare-sheet tr.q-total td { font-weight: 800; font-size: 0.95rem; border-top: 2px solid #94a3b8; }
.q-actions { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

.po-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.86rem;
  margin-bottom: 12px;
}
.po-banner .btn { margin-left: auto; }

/* ---------- Several POs per indent: green ordered, red open, yellow partial ---------- */
.store-partial { background: #fef9c3; color: #854d0e; }

.indent-card.ord-none    { border-top: 5px solid #dc2626; }
.indent-card.ord-partial { border-top: 5px solid #eab308; background: #fefce8; }
.indent-card.ord-full    { border-top: 5px solid #16a34a; background: #f0fdf4; }

.ord-progress { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.ord-bar {
  flex: 1 1 160px;
  max-width: 320px;
  height: 8px;
  border-radius: 999px;
  background: #fecaca;
  overflow: hidden;
}
.ord-bar span { display: block; height: 100%; background: #16a34a; border-radius: 999px; }
.ord-text { font-size: 0.8rem; font-weight: 700; }
.ord-progress.none .ord-text    { color: #b91c1c; }
.ord-progress.partial .ord-text { color: #854d0e; }
.ord-progress.full .ord-text    { color: #15803d; }
.bop-card .ord-progress { margin-top: 0; }
.bop-card .ord-text { font-size: 0.7rem; font-weight: 600; }

table.purchase-sheet tr.ord-yes td { background: #f0fdf4; }
table.purchase-sheet tr.ord-no td  { background: #fef2f2; }
table.purchase-sheet tr.ord-yes td:first-child { box-shadow: inset 4px 0 0 #16a34a; }
table.purchase-sheet tr.ord-no td:first-child  { box-shadow: inset 4px 0 0 #dc2626; }
table.compare-sheet tr.ord-yes td.q-approved { background: #bbf7d0; }
table.compare-sheet tr.ord-yes td.q-dim { color: #cbd5e1; }
table.form-table tr.ord-yes td { background: #f0fdf4; }

.ord-po { white-space: nowrap; }
.btn.ord-link { color: #15803d; font-weight: 700; padding: 2px 6px; }
.ord-none-tag { color: #b91c1c; font-weight: 700; font-size: 0.78rem; }
.ord-tag { display: block; color: #15803d; font-weight: 700; font-size: 0.72rem; }
.ord-list { margin-bottom: 22px; }
.ord-list .po-banner { margin-bottom: 8px; }

/* ---------- Purchase: BOP and BOM books ---------- */
.purchase-cats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 4px 0 16px;
}
.purchase-cat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.purchase-cat:hover { border-color: #c7d2fe; }
.purchase-cat.active.cat-bop { border-color: #2563eb; background: #eff6ff; }
.purchase-cat.active.cat-bom { border-color: #7c3aed; background: #f5f3ff; }
.purchase-cat.active.cat-capex { border-color: #0d9488; background: #f0fdfa; }
.purchase-cat-head { display: flex; align-items: center; gap: 8px; }
.purchase-cat-head strong { font-size: 1.02rem; }
.purchase-cat-icon { font-size: 1.3rem; }
.purchase-cat-sub { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.purchase-cat-stats { font-size: 0.8rem; font-weight: 700; }
.cat-badge {
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 6px;
  padding: 2px 8px;
  letter-spacing: 0.04em;
}
.cat-badge.cat-bop { background: #dbeafe; color: #1d4ed8; }
.cat-badge.cat-bom { background: #ede9fe; color: #6d28d9; }
.cat-badge.cat-capex { background: #ccfbf1; color: #0f766e; }

/* Quotation: HSN code for every line at once, or per line. */
.hsn-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.hsn-bar .hsn-label { font-size: 0.8rem; font-weight: 700; }
.hsn-bar input { width: 130px; }
.hsn-bar .sub { font-size: 0.78rem; color: var(--muted); }
table.quote-rates input.hsn-in { width: 92px; }

/* BOM quotation: tick lines, Club selected, one merged amount cell. */
.club-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  background: #faf5ff;
}
.club-bar .sub { font-size: 0.78rem; color: var(--muted); flex: 1 1 260px; }
table.quote-rates th.club-col, table.quote-rates td.club-col { width: 30px; text-align: center; }
table.quote-rates input[type="checkbox"] { width: 17px; height: 17px; }
table.quote-rates tr.lot-member td { background: #faf5ff; }
table.quote-rates tr.lot-member td:first-child { box-shadow: inset 4px 0 0 #7c3aed; }
table.quote-rates tr.lot-first td { border-top: 2px solid #c4b5fd; }
table.quote-rates .lot-mark { color: #7c3aed; }
table.quote-rates td.lot-cell {
  vertical-align: middle;
  background: #f3e8ff;
  border-left: 2px solid #c4b5fd;
  padding: 8px;
  min-width: 200px;
}
table.quote-rates td.lot-cell input { display: block; width: 100%; margin-bottom: 6px; }
table.quote-rates td.lot-cell input.lot-name { font-weight: 700; }
table.quote-rates td.lot-cell input[type="number"] { font-size: 1rem; font-weight: 700; }
table.quote-rates .lot-label { display: block; font-size: 0.72rem; color: #6d28d9; font-weight: 700; margin-bottom: 3px; }

/* Clubbed lots: several BOM lines, one amount. */
.lot-box { margin: 10px 0 14px; }
.lot-box > .btn { margin-bottom: 8px; }
.lot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid #ddd6fe;
  border-left: 5px solid #7c3aed;
  border-radius: 8px;
  background: #faf5ff;
}
.lot-row.ord-yes { border-color: #bbf7d0; border-left-color: #16a34a; background: #f0fdf4; }
.lot-row input[type="text"] { width: 150px; }
.lot-row input[type="number"] { width: 140px; }
.lot-parts { font-size: 0.78rem; color: var(--muted); flex: 1 1 240px; }
table.compare-sheet td.q-lot { color: #6d28d9; font-weight: 700; }
table.compare-sheet td.q-lot small { display: block; font-weight: 400; }
table.ord-pick tr.ord-lot td { background: #faf5ff; }

.ord-pickbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ord-pickbar .sub { font-size: 0.8rem; color: var(--muted); margin-left: auto; }
table.ord-pick tbody tr { cursor: pointer; }
table.ord-pick tbody tr.ord-unpriced { cursor: default; color: #94a3b8; }
table.ord-pick input[type="checkbox"] { width: 17px; height: 17px; }

/* Forms inside the purchase modals. */
.modal.modal-wide { width: min(1080px, 100%); }
.form-section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 6px 0 8px; }
.form-section-head h4 { margin: 0; font-size: 0.92rem; }
.form-section-head span { font-size: 0.78rem; color: var(--muted); }
.form-table-wrap { overflow-x: auto; margin-bottom: 10px; }
table.form-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 720px; }
table.form-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 4px 4px 6px;
  border-bottom: 1px solid var(--border);
}
table.form-table th.num, table.form-table td.num { text-align: right; white-space: nowrap; }
table.form-table td { padding: 4px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.form-table td.sno { color: var(--muted); font-weight: 600; width: 28px; }
table.form-table input, table.form-table select {
  width: 100%;
  min-width: 70px;
  padding: 7px 8px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
table.form-table input:focus, table.form-table select:focus { outline: none; border-color: var(--primary); }

.quote-totals, .approve-summary {
  margin: 4px 0 12px auto;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
}
.approve-summary { max-width: none; margin: 0 0 14px; }
.quote-totals div, .approve-summary div { display: flex; justify-content: space-between; gap: 16px; }
.quote-totals span, .approve-summary span { color: var(--muted); }
.quote-totals .grand, .approve-summary .grand {
  border-top: 2px solid var(--border);
  padding-top: 6px;
  font-size: 1rem;
}
.quote-totals .grand span, .approve-summary .grand span { color: var(--text); font-weight: 700; }
.quote-totals p.muted { margin: 2px 0 0; color: var(--warn); font-size: 0.78rem; text-align: right; }

.po-preview { border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 12px; overflow-x: auto; }
.po-preview .po-sheet { min-width: 640px; }

/* Unit / type / project pickers: plain, so they do not compete with a status. */
.cell-select {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  padding: 5px 4px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
}
.cell-select:hover:enabled { border-color: var(--border); background: #fff; }
.cell-select:focus { outline: 2px solid var(--primary); outline-offset: -1px; background: #fff; }
.cell-select:disabled { cursor: default; color: var(--muted); }

/* A bill that is past its due date and still owed. */
input.cell-date.date-overdue {
  background: #fee2e2;
  color: #991b1b;
  font-weight: 700;
}

/* ---------- Access grants (user form) ---------- */
.perm-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin: 0 0 16px;
  background: #fbfcfd;
}
.perm-box.hidden { display: none !important; }
.perm-box legend {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0 6px;
  color: var(--text);
}
.perm-hint { margin: 0 0 12px; font-size: 0.8rem; color: var(--muted); line-height: 1.55; }

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}
.perm-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.perm-item:hover { border-color: #cbd5e1; background: #f8fafc; }
.perm-item input { margin-top: 2px; flex-shrink: 0; }
.perm-item span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.perm-item strong { font-size: 0.86rem; font-weight: 600; }
.perm-item small { font-size: 0.74rem; color: var(--muted); line-height: 1.4; }
/* A ticked area reads as held at a glance. */
.perm-item:has(input:checked) { border-color: var(--primary); background: #fff5f6; }

/* ---------- What a user holds, on their card ---------- */
.uc-access { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.uc-perm {
  font-size: 0.7rem;
  font-weight: 600;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 5px;
  padding: 2px 8px;
}
.uc-all  { font-size: 0.74rem; color: var(--done); font-weight: 600; }
.uc-none { font-size: 0.74rem; color: var(--muted); font-style: italic; }

/* ---------- Activity recorder ---------- */
.activity-feed { display: flex; flex-direction: column; gap: 6px; }

.act-day {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 16px 2px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.act-day:first-child { padding-top: 2px; }

.act-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
}
.act-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.75rem;
  flex-shrink: 0;
}
.act-main { min-width: 0; }
.act-line { font-size: 0.89rem; line-height: 1.45; word-break: break-word; }
.act-line b { color: var(--primary); font-weight: 600; }
.act-detail {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 3px;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}
.act-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}
.act-meta span { background: #f1f5f9; border-radius: 5px; padding: 1px 7px; }
.act-meta .act-area { background: #eef2ff; color: #3730a3; font-weight: 600; }
.act-when {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

@media (max-width: 640px) {
  .act-row { grid-template-columns: auto 1fr; }
  .act-when { grid-column: 2; padding-top: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1320px) {
  /* Give the tab bar its room back before the logo has to go. */
  .brand p { display: none; }
}
@media (max-width: 1180px) {
  .tab-bar { justify-content: flex-start; }
  .brand-rule, .brand-text { display: none; }
}
@media (max-width: 980px) {
  header.app-header { flex-wrap: wrap; }
  .tab-bar { order: 3; width: 100%; overflow-x: auto; }
  .brand-rule, .brand-text { display: revert; }
  .brand p { display: none; }
}

@media print {
  .tab-bar, .login-screen, .boot-screen, .portfolio,
  .readonly-banner, .user-menu { display: none !important; }

  /* Brand the printed tracking sheet / PDF. */
  .print-logo {
    display: block;
    height: 13mm;
    width: auto;
    margin-bottom: 3mm;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* =============================================================================
 * Quick stock entry (entry.html)
 *
 * A one-card page used at the rack, often on a phone, so the card is narrow and
 * the controls are finger-sized rather than table-sized.
 * ========================================================================== */
a.btn { text-decoration: none; }

.entry-main { max-width: 520px; }

.entry-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.entry-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.entry-card .field input,
.entry-card .field select { padding: 11px 12px; font-size: 0.95rem; }

.entry-card .field-row .field { min-width: 120px; }

.entry-card #entry-save { margin-top: 6px; }

/* ---- Session receipt ---- */
.entry-recent { margin-top: 22px; }
.entry-recent.hidden { display: none !important; }

.entry-recent h2 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.entry-log { list-style: none; margin: 0; padding: 0; }

.entry-log li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.entry-log strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.entry-log .in  { color: var(--done);   font-weight: 700; }
.entry-log .out { color: var(--danger); font-weight: 700; }
.entry-log .unit { color: var(--muted); font-size: 0.78rem; }
.entry-log .now {
  color: var(--muted);
  font-size: 0.78rem;
  border-left: 1px solid var(--border);
  padding-left: 8px;
}

/* Only ever visible in the print stylesheet above. */
.print-logo { display: none; }

/* ---------- Challan tab ---------- */
.challan-kind {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 6px;
  padding: 2px 8px;
}
.challan-kind.kind-outward { background: #ffedd5; color: #c2410c; }
.challan-kind.kind-inward  { background: #dbeafe; color: #1d4ed8; }
table.purchase-sheet tr.challan-cancelled td { color: #94a3b8; text-decoration: line-through; }
table.purchase-sheet tr.challan-cancelled td .store-pill { text-decoration: none; }

/* ---------- Renewal notice (js/billing.js) ---------- */
/* Above everything else, including the boot screen (200). */
.billing-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.55);
}
/* Locked: opaque, so the stale screen behind it cannot be read or used. */
.billing-backdrop.locked { background: var(--bg); }
.billing-card {
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 24px;
  background: var(--card);
  border-radius: 14px;
  border-top: 5px solid var(--warn);
  box-shadow: var(--shadow-lg);
}
.billing-backdrop.locked .billing-card { border-top-color: var(--danger); }
.billing-card h2 { margin: 0 0 10px; font-size: 1.2rem; line-height: 1.3; }
.billing-card p { margin: 0 0 12px; }
.billing-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  margin: 0 0 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
}
.billing-facts dt { color: var(--muted); }
.billing-facts dd { margin: 0; font-weight: 600; text-align: right; }
.billing-error { color: var(--danger); font-size: 0.9rem; }
.billing-actions { display: flex; flex-direction: column; gap: 8px; }
.billing-note { margin: 12px 0 0 !important; color: var(--muted); font-size: 0.8rem; }
.billing-card .billing-tax { margin: 0 0 16px !important; color: var(--text); font-weight: 600; }
.billing-facts { margin-bottom: 8px; }

/* ---------- Receipts (receipt.html) ---------- */
a.um-item { display: block; color: inherit; text-decoration: none; }
a.um-item[hidden] { display: none; }
.receipt-wrap { width: min(720px, 100%); margin: 0 auto; padding: 24px 16px; }
.receipt-msg { margin: 0 0 16px; }
.receipt-list-title { margin: 0 0 16px; font-size: 1.4rem; }
.receipt-paid {
  margin: 0 0 16px;
  padding: 12px 16px;
  color: #14532d;
  background: #dcfce7;
  border-radius: var(--radius);
  font-weight: 600;
}
.receipt-paper {
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.receipt-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--text);
}
.receipt-head h1 { margin: 0; font-size: 1.4rem; }
.receipt-seller { font-size: 1.1rem; }
.receipt-line { color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.receipt-meta { width: 100%; margin-bottom: 20px; border-collapse: collapse; }
.receipt-meta th { width: 45%; padding: 3px 12px 3px 0; color: var(--muted); font-weight: 400; text-align: left; }
.receipt-meta td { padding: 3px 0; font-weight: 600; overflow-wrap: anywhere; }
.receipt-items { width: 100%; background: var(--card); border-collapse: collapse; }
.receipt-items th, .receipt-items td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.receipt-items th { background: var(--bg); font-size: 0.875rem; }
.receipt-items .receipt-num { text-align: right; white-space: nowrap; }
.receipt-total td { font-weight: 700; border-bottom: 2px solid var(--text); }
.receipt-tax {
  margin-top: 20px;
  padding: 12px 16px;
  background: #fef3c7;
  border: 1px solid #d97706;
  border-radius: var(--radius);
}
.receipt-tax p { margin: 4px 0 0; }
.receipt-foot { margin: 16px 0 0; color: var(--muted); font-size: 0.8rem; text-align: center; }
.receipt-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.receipt-actions .btn { text-decoration: none; }
@media print {
  body.receipt-page { background: #fff; }
  .receipt-page .no-print { display: none !important; }
  .receipt-paper { padding: 0; border: 0; }
  .receipt-tax, .receipt-items th {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ---------- Renewal key entry (js/billing.js) ---------- */
.billing-how { margin: 4px 0 10px !important; font-size: 0.9rem; }
.billing-keyform { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.billing-key-input {
  width: 100%;
  padding: 11px 12px;
  font-size: 1rem;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.billing-key-input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.billing-info { color: var(--text); font-size: 0.9rem; }

/* ---------- Fee tab (owner only; app.js renderFee) ---------- */
.fee-wrap { width: min(640px, 100%); margin: 0 auto; padding: 24px 16px; }
.fee-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
}
.fee-card h2 { margin: 0 0 4px; font-size: 1.2rem; }
.fee-card .fee-sub { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }
.fee-status {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.fee-status dt { color: var(--muted); }
.fee-status dd { margin: 0; font-weight: 600; text-align: right; }
.fee-field { margin-bottom: 14px; }
.fee-field label { display: block; font-weight: 600; margin-bottom: 4px; }
.fee-field .hint { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 3px; font-weight: 400; }
.fee-field input, .fee-field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.fee-row { display: flex; gap: 12px; flex-wrap: wrap; }
.fee-row .fee-field { flex: 1 1 180px; }
.fee-check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 0.9rem; }
.fee-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.fee-msg { margin: 10px 0 0; font-size: 0.9rem; }
.fee-msg.ok { color: var(--done); }
.fee-msg.err { color: var(--danger); }
.fee-keybox { padding: 14px; background: #fff7ed; border: 1px solid var(--under); border-radius: var(--radius); margin-bottom: 14px; }
