/* ERP workstream styles. Area files are imported so parallel screen work never collides. */
@import url('erp-pos.css');
@import url('erp-inv.css');
@import url('erp-ops.css');
@import url('erp-sales.css');

/* ── shared ERP primitives (prefix erp-) */
.erp-num, .tbl td.num, .erp-stat-value { font-variant-numeric: tabular-nums; }
.erp-prod { display: flex; flex-direction: column; min-width: 0; }
.erp-prod-name { display: flex; align-items: center; gap: 6px; font-weight: 600; flex-wrap: wrap; }
.erp-prod-name .badge { height: 18px; padding: 0 6px; font-size: 10.5px; }
.erp-req { color: var(--danger); }
.erp-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.erp-form .erp-full { grid-column: 1 / -1; }
@media (max-width: 700px) { .erp-form { grid-template-columns: 1fr; } }

.erp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; margin-bottom: 14px; }
.erp-stat { padding: 12px 16px; border-right: 1px solid var(--border); min-width: 0; position: relative; }
.erp-stat:last-child { border-right: none; }
.erp-stat.clickable { cursor: pointer; transition: background var(--dur); }
.erp-stat.clickable:hover { background: var(--surface-2); }
.erp-stat-label { font-size: 11.5px; color: var(--text-2); font-weight: 600; display: flex; gap: 6px; align-items: center; text-transform: uppercase; letter-spacing: 0.04em; }
.erp-stat-value { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; line-height: 1.15; }
.erp-stat-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.erp-stat.tone-danger .erp-stat-value { color: var(--danger); }
.erp-stat.tone-warn .erp-stat-value { color: #b45309; }
.erp-stat.tone-success .erp-stat-value { color: var(--success); }
.erp-stat.tone-brand .erp-stat-value { color: var(--brand); }
[data-theme='dark'] .erp-stat.tone-warn .erp-stat-value { color: #fcd34d; }

.erp-pick { max-width: 880px; }
.erp-branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.erp-branch-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; transition: border-color var(--dur), box-shadow var(--dur), transform 80ms; }
.erp-branch-tile:hover { border-color: var(--brand); box-shadow: var(--shadow-2); }
.erp-branch-tile .erp-branch-id { font-size: 11px; font-weight: 700; color: var(--brand); background: var(--brand-50); border-radius: 6px; padding: 1px 6px; }
.erp-branch-tile .subtle { font-size: 11.5px; }
.erp-phase2 { color: var(--text-3); font-weight: 600; }
.erp-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.erp-toolbar .select { height: 30px; font-size: 12.5px; }
.erp-mono { font-family: var(--mono); font-size: 12px; }
.erp-muted { color: var(--text-3); }
.erp-section-title { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; margin: 14px 0 8px; }
.erp-line-items { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.erp-line-items th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.erp-line-items td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.erp-line-items .num { text-align: right; font-variant-numeric: tabular-nums; }
.erp-line-items input.input { height: 30px; width: 100%; }
.erp-pipeline { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.erp-pipe { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; text-align: left; transition: border-color var(--dur), background var(--dur); }
.erp-pipe:hover, .erp-pipe.active { border-color: var(--brand); background: var(--brand-50); }
.erp-pipe b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.erp-pipe span { font-size: 11.5px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
@media (max-width: 900px) { .erp-pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── printable documents (invoice, registers) */
.erp-doc { background: #fff; color: #111; font-size: 12px; line-height: 1.35; }
.erp-print-host { display: none; }
@media print {
  body.erp-printing > *:not(.erp-print-host) { display: none !important; }
  body.erp-printing .erp-print-host { display: block !important; }
  body.erp-printing { background: #fff !important; }
}
.callout[hidden] { display: none !important; }

/* ── responsive & touch (shared by every ERP screen) */
.screen { min-width: 0; max-width: 100%; }
.dt, .table-wrap { max-width: 100%; }
.erp-toolbar > *, .page-actions > * { min-width: 0; }
@media (max-width: 900px) {
  .erp-stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .erp-stat { border-bottom: 1px solid var(--border); }
  .screen .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .screen .tab { min-height: 40px; }
  .screen .btn:not(.sm), .screen .select, .screen .input,
  .modal .btn, .modal .input, .modal .select, .drawer .btn, .drawer .input, .drawer .select { min-height: 40px; }
  .screen .btn.sm, .drawer .btn.sm, .modal .btn.sm, .screen .chip { min-height: 36px; }
  .table-toolbar .search-input { flex: 1 1 100%; min-width: 0; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .erp-branch-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 600px) {
  .erp-form { grid-template-columns: 1fr; }
  .erp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .erp-stat-value { font-size: 17px; }
  .erp-pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer { width: 100vw; border-left: none; }
  .modal { width: 100vw; max-height: 100dvh; height: auto; border-radius: 16px 16px 0 0; top: auto; bottom: 0; left: 0; transform: translateY(12px); }
  .modal.show { transform: none; }
  .drawer-f, .modal-f { flex-wrap: wrap; }
  .drawer-f .btn, .modal-f .btn { flex: 1 1 auto; }
  .page-head h1 { font-size: 19px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 6px; }
}
