/* ────────────────────────────────────────────────────────────────
   Marvit Portal — ERP edition
   Inspired by classic enterprise dashboards: dense, structured,
   data-first. Modernized with flat surfaces and soft shadows.

   Brand color (logo dark forest):  #0d4a2b
   Brand color (logo emerald):      #1ea951
   ERP accent (status / alert bar): #c0392b   (red)
   Background:                       #f3f4f6 (cool gray)
   Panel:                            #ffffff
   Border:                           #d6d8dc
   Text primary:                     #1f2937
   Text secondary:                   #5b6470
   Subtle hover:                     #f5f6f8
   Striped row:                      #fafbfc
   ──────────────────────────────────────────────────────────────── */

:root {
  /* Brand still available for the logo / "lab" identity */
  --brand-dark:   #0d4a2b;
  --brand-green:  #1ea951;
  --brand-bright: #3edc6d;

  /* ERP palette */
  --erp-bg:        #f3f4f6;
  --erp-panel:     #ffffff;
  --erp-border:    #d6d8dc;
  --erp-border-2:  #c8ccd3;
  --erp-hover:     #f5f6f8;
  --erp-stripe:    #fafbfc;
  --erp-text:      #1f2937;
  --erp-text-2:    #5b6470;
  --erp-text-3:    #8b94a3;
  --erp-accent:    #c0392b;
  --erp-accent-2:  #a83227;
  --erp-link:      #1565c0;
  --erp-link-hov:  #0d47a1;

  /* Status dot colors */
  --st-green:  #2e8b57;
  --st-yellow: #d6a806;
  --st-red:    #c0392b;
  --st-blue:   #1565c0;
  --st-gray:   #8b94a3;
}

/* ───── Base ─────────────────────────────────────────────── */

html, body {
  background: var(--erp-bg);
  color: var(--erp-text);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, Helvetica, sans-serif;
  /* Desktop default — overridden under 900px to keep mobile dense. */
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 900px) {
  html, body { font-size: 15px; line-height: 1.45; }
}

/* Override Tailwind's stone-50 and emerald gradients on body */
body.bg-stone-50 { background: var(--erp-bg) !important; }

/* ───── Top nav bar ───────────────────────────────────────── */

.erp-topbar {
  background: linear-gradient(180deg, #ffffff 0%, #f0f2f5 100%);
  border-bottom: 1px solid var(--erp-border);
  height: 56px;
  display: flex;
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.erp-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-right: 1px solid var(--erp-border);
  background: linear-gradient(180deg, #ffffff 0%, #f7f8fa 100%);
}
.erp-topbar-brand img { height: 28px; width: auto; }
.erp-topbar-brand .erp-app-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--brand-dark);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.erp-tabs {
  display: flex;
  align-items: stretch;
  /* Auto-margins on a flex item push siblings to the edges and center the
     tabs against the topbar. `min-width: 0` lets the container shrink under
     overflow so tabs can scroll horizontally if there are too many. */
  margin: 0 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.erp-tabs::-webkit-scrollbar { height: 4px; }
.erp-tabs::-webkit-scrollbar-thumb { background: #cdd2da; }

.erp-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--erp-text);
  text-decoration: none;
  border-right: 1px solid #e5e7eb;
  white-space: nowrap;
  transition: background 0.08s ease;
  position: relative;
  flex-shrink: 0;  /* never compress individual tabs — overflow-x handles it */
}
.erp-tab svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.65; }
.erp-tab:hover { background: var(--erp-hover); color: var(--brand-dark); }
.erp-tab:hover svg { opacity: 1; }
.erp-tab.is-active {
  background: #ffffff;
  color: var(--erp-accent);
  font-weight: 600;
}
.erp-tab.is-active svg { opacity: 1; color: var(--erp-accent); }
.erp-tab.is-active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 3px;
  background: var(--erp-accent);
}

.erp-topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-left: 1px solid var(--erp-border);
  background: linear-gradient(180deg, #ffffff 0%, #f7f8fa 100%);
  font-size: 14px;
}
.erp-topbar-user .erp-user-name {
  font-weight: 600;
  color: var(--erp-text);
}
.erp-topbar-user .erp-user-role {
  color: var(--erp-text-2);
  font-size: 12.5px;
}
.erp-topbar-user a {
  color: var(--erp-text-2);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 3px;
}
.erp-topbar-user a:hover { background: var(--erp-hover); color: var(--erp-accent); }

.erp-mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  border-right: 1px solid var(--erp-border);
  background: transparent;
  cursor: pointer;
  color: var(--erp-text);
}

@media (max-width: 900px) {
  .erp-topbar {
    height: 52px;
  }
  .erp-topbar-brand { padding: 0 12px; gap: 8px; }
  .erp-topbar-brand img { height: 24px; }
  .erp-topbar-brand .erp-app-name { font-size: 15px; }
  .erp-mobile-menu-btn { display: flex; width: 48px; }
  .erp-tabs {
    position: fixed;
    top: 52px; left: 0; right: 0; bottom: 0;
    flex: none;
    max-width: none;
    background: #fff;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    border-top: 1px solid var(--erp-border);
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    z-index: 40;
  }
  .erp-tabs.is-open { transform: translateX(0); }
  .erp-tab {
    border-right: 0;
    border-bottom: 1px solid #eef0f3;
    height: 48px;
    padding: 0 18px;
    font-size: 16px;
  }
  .erp-tab svg { width: 16px; height: 16px; }
  .erp-tab.is-active::after { display: none; }
  .erp-tab.is-active { border-left: 3px solid var(--erp-accent); padding-left: 15px; }
  .erp-topbar-user {
    padding: 0 10px;
    margin-left: auto;
  }
  .erp-topbar-user .erp-user-meta { display: none; }
  .erp-topbar-user a { padding: 8px; }
}

@media (max-width: 480px) {
  .erp-topbar-brand .erp-app-name { display: none; }
}

/* ───── Layout shell (sidebar removed — top nav only) ─────── */

.erp-main {
  display: block;
  padding: 16px 20px;
  max-width: 1400px;
  margin: 0 auto;
}
.erp-main-full { padding: 16px 20px; }

@media (max-width: 1024px) {
  .erp-main, .erp-main-full { padding: 12px 12px 24px; }
  .erp-page-title h1 { font-size: 18.5px; }
  .erp-page-title { padding-bottom: 8px; margin-bottom: 10px; }
}

@media (max-width: 600px) {
  .erp-main, .erp-main-full { padding: 10px 10px 20px; }
  .erp-page-title { flex-direction: column; align-items: flex-start; gap: 8px; }
  .erp-page-title > div:last-child { width: 100%; flex-wrap: wrap; }
  .erp-breadcrumb { font-size: 12.5px; margin-bottom: 4px; }
}

/* ───── Page-level toolbar (replaces left sidebar filters) ───── */

.erp-page-toolbar {
  background: #fff;
  border: 1px solid var(--erp-border);
  border-radius: 4px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 14.5px;
}
.erp-page-toolbar .erp-search {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.erp-page-toolbar .erp-search input {
  width: 100%;
  padding: 5px 8px 5px 28px;
  font-size: 15px;
  border: 1px solid var(--erp-border-2);
  border-radius: 3px;
}
.erp-page-toolbar .erp-divider {
  width: 1px;
  height: 22px;
  background: var(--erp-border);
}

/* Inline filter chips (replaces sidebar filter list) */
.erp-chip-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.erp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 14px;
  color: var(--erp-text);
  border: 1px solid var(--erp-border-2);
  background: #fff;
  border-radius: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.erp-chip:hover { background: var(--erp-hover); }
.erp-chip.is-active {
  background: var(--erp-accent);
  border-color: var(--erp-accent);
  color: #fff;
}
.erp-chip.is-active .erp-chip-count { color: #fff; opacity: 0.85; }
.erp-chip-count {
  font-size: 12.5px;
  color: var(--erp-text-3);
  font-variant-numeric: tabular-nums;
}
.erp-chip .erp-dot {
  width: 7px; height: 7px; margin-right: 0;
}

.erp-page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--erp-border);
}
.erp-page-title h1 {
  font-size: 20.5px;
  font-weight: 600;
  color: var(--erp-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.erp-page-title .erp-count {
  font-weight: 400;
  color: var(--erp-text-2);
  font-size: 15px;
}
.erp-breadcrumb {
  font-size: 14px;
  color: var(--erp-text-2);
  margin-bottom: 6px;
}
.erp-breadcrumb a { color: var(--erp-link); text-decoration: none; }
.erp-breadcrumb a:hover { text-decoration: underline; }

/* ───── Sidebar widgets ──────────────────────────────────── */

.erp-side-section {
  padding: 12px 14px;
  border-bottom: 1px solid #e9ebef;
}
.erp-side-label {
  text-transform: uppercase;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--erp-text-2);
  margin-bottom: 6px;
  font-weight: 600;
}
.erp-search {
  position: relative;
}
.erp-search input {
  width: 100%;
  padding: 6px 8px 6px 28px;
  font-size: 15px;
  border: 1px solid var(--erp-border-2);
  border-radius: 3px;
  background: #fff;
  color: var(--erp-text);
}
.erp-search input:focus {
  outline: none;
  border-color: var(--erp-accent);
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.12);
}
.erp-search svg {
  position: absolute;
  left: 8px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--erp-text-3);
}

.erp-filter-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.erp-filter-list li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  margin: 1px 0;
  font-size: 14.5px;
  color: var(--erp-text);
  text-decoration: none;
  border-radius: 3px;
  border-left: 3px solid transparent;
}
.erp-filter-list li a:hover {
  background: var(--erp-hover);
}
.erp-filter-list li a.is-active {
  background: #fef2f0;
  color: var(--erp-accent);
  border-left-color: var(--erp-accent);
  font-weight: 600;
}
.erp-filter-list li a .erp-count {
  font-size: 12.5px;
  color: var(--erp-text-3);
  font-variant-numeric: tabular-nums;
}
.erp-filter-list li a.is-active .erp-count { color: var(--erp-accent); }

/* Mini calendar */
.erp-calendar {
  font-size: 12.5px;
  color: var(--erp-text);
}
.erp-calendar table { width: 100%; border-collapse: collapse; }
.erp-calendar th {
  font-weight: 500;
  color: var(--erp-text-3);
  font-size: 11.5px;
  padding: 3px 0;
  text-align: center;
}
.erp-calendar td {
  padding: 3px 0;
  text-align: center;
  cursor: default;
  border-radius: 2px;
  font-variant-numeric: tabular-nums;
}
.erp-calendar td.is-other { color: var(--erp-text-3); }
.erp-calendar td.is-today {
  background: var(--erp-accent);
  color: #fff;
  font-weight: 700;
}
.erp-calendar td.has-event {
  position: relative;
  font-weight: 600;
}
.erp-calendar td.has-event::after {
  content: '';
  position: absolute;
  bottom: 2px; left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--erp-accent);
}
.erp-calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}

/* ───── Panels & cards ──────────────────────────────────── */

.erp-panel {
  background: var(--erp-panel);
  border: 1px solid var(--erp-border);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
  margin-bottom: 14px;
}
.erp-panel-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--erp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: linear-gradient(180deg, #fafbfc 0%, #f3f4f6 100%);
}
.erp-panel-head h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.erp-panel-head h2 .erp-accent-bar {
  display: inline-block;
  width: 3px; height: 14px;
  background: var(--erp-accent);
  border-radius: 1px;
}
.erp-panel-body { padding: 14px; }
.erp-panel-body.is-flush { padding: 0; }

/* Toolbar inside panel */
.erp-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: #fafbfc;
  border-bottom: 1px solid var(--erp-border);
  font-size: 14.5px;
}
.erp-toolbar .erp-divider {
  width: 1px; height: 18px; background: var(--erp-border); margin: 0 4px;
}

/* ───── Buttons ─────────────────────────────────────────── */

.erp-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 14.5px;
  font-weight: 500;
  border: 1px solid var(--erp-border-2);
  background: linear-gradient(180deg, #ffffff 0%, #f1f3f6 100%);
  color: var(--erp-text);
  border-radius: 3px;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.6;
  font-family: inherit;
  white-space: nowrap;
}
.erp-btn:hover {
  background: linear-gradient(180deg, #ffffff 0%, #e7eaef 100%);
  border-color: #b6bbc4;
}
.erp-btn:active {
  background: #e7eaef;
}
.erp-btn svg { width: 13px; height: 13px; }

.erp-btn-primary {
  background: linear-gradient(180deg, var(--erp-accent) 0%, var(--erp-accent-2) 100%);
  border-color: var(--erp-accent-2);
  color: #fff;
}
.erp-btn-primary:hover {
  background: linear-gradient(180deg, #d44637 0%, var(--erp-accent-2) 100%);
  border-color: var(--erp-accent-2);
  color: #fff;
}

.erp-btn-success {
  background: linear-gradient(180deg, #2e8b57 0%, #246b43 100%);
  border-color: #246b43;
  color: #fff;
}
.erp-btn-success:hover { background: linear-gradient(180deg, #36a468 0%, #246b43 100%); color: #fff; }

.erp-btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--erp-link);
  padding: 2px 6px;
  font-weight: normal;
}
.erp-btn-ghost:hover { background: var(--erp-hover); color: var(--erp-link-hov); }

/* Compact icon button (e.g. +/− stock) */
.erp-iconbtn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--erp-border-2);
  background: #fff;
  color: var(--erp-text);
  border-radius: 3px;
  font-size: 15px;
  cursor: pointer;
  padding: 0;
}
.erp-iconbtn:hover { background: var(--erp-hover); border-color: #b6bbc4; }

/* ───── Forms ───────────────────────────────────────────── */

.erp-input,
.erp-select,
.erp-textarea {
  width: 100%;
  padding: 5px 8px;
  font-size: 15px;
  border: 1px solid var(--erp-border-2);
  border-radius: 3px;
  background: #fff;
  color: var(--erp-text);
  font-family: inherit;
  line-height: 1.4;
}
.erp-input:focus,
.erp-select:focus,
.erp-textarea:focus {
  outline: none;
  border-color: var(--erp-accent);
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.12);
}
.erp-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 4.5L6 7.5 9 4.5' stroke='%235b6470' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
}
.erp-label {
  display: block;
  font-size: 12.5px;
  color: var(--erp-text-2);
  margin-bottom: 3px;
  font-weight: 600;
}

.erp-form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.erp-form-row > * { flex: 1; min-width: 140px; }

/* ───── Data tables ─────────────────────────────────────── */

.erp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  color: var(--erp-text);
}
.erp-table thead th {
  background: linear-gradient(180deg, #f7f8fa 0%, #ebedf0 100%);
  border-bottom: 1px solid var(--erp-border-2);
  border-top: 1px solid var(--erp-border);
  padding: 7px 12px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  color: var(--erp-text-2);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.erp-table thead th.is-num { text-align: right; }
.erp-table thead th.is-sortable { cursor: pointer; user-select: none; }
.erp-table thead th.is-sortable:hover { background: linear-gradient(180deg, #eef0f3 0%, #dee1e6 100%); }
.erp-table thead th.is-sortable::after {
  content: '⇅';
  margin-left: 4px;
  color: var(--erp-text-3);
  font-size: 11.5px;
}
.erp-table tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid #eef0f3;
  vertical-align: middle;
}
.erp-table tbody td.is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'Consolas', 'SF Mono', Menlo, monospace;
  font-size: 14px;
}
.erp-table tbody tr:nth-child(even) td { background: var(--erp-stripe); }
.erp-table tbody tr:hover td { background: #fff8f5; }
.erp-table tbody tr.is-clickable { cursor: pointer; }
.erp-table tbody tr.is-clickable:hover td { background: #fff8f5; }
.erp-table .erp-mono {
  font-family: 'Consolas', 'SF Mono', Menlo, monospace;
  font-size: 14px;
  color: var(--erp-text);
}
.erp-table .erp-meta {
  display: block;
  font-size: 12.5px;
  color: var(--erp-text-3);
  margin-top: 1px;
}
.erp-table .erp-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.erp-table .erp-actions a {
  color: var(--erp-link);
  text-decoration: none;
  font-size: 14px;
}
.erp-table .erp-actions a:hover { text-decoration: underline; color: var(--erp-link-hov); }

/* Empty state row */
.erp-empty-row td {
  text-align: center;
  color: var(--erp-text-3);
  padding: 28px 12px !important;
  font-style: italic;
}

/* ───── Status dots ─────────────────────────────────────── */

.erp-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.erp-dot-green  { background: var(--st-green); }
.erp-dot-yellow { background: var(--st-yellow); }
.erp-dot-red    { background: var(--st-red); }
.erp-dot-blue   { background: var(--st-blue); }
.erp-dot-gray   { background: var(--st-gray); }

.erp-status {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  white-space: nowrap;
}

/* Status pill (for invoice statuses etc.) */
.erp-pill {
  display: inline-block;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 2px;
  border: 1px solid transparent;
  vertical-align: middle;
  line-height: 1.6;
}
.erp-pill-green   { background: #e9f5ee; color: #246b43; border-color: #c5e0d0; }
.erp-pill-blue    { background: #e7f0fa; color: #0d47a1; border-color: #c2d5ee; }
.erp-pill-amber   { background: #fdf3df; color: #8a6d0b; border-color: #ebd7a0; }
.erp-pill-red     { background: #fcebe6; color: #9c2818; border-color: #f0c5b9; }
.erp-pill-gray    { background: #eef0f3; color: #5b6470; border-color: #d6d8dc; }

/* ───── Stat strip ──────────────────────────────────────── */

.erp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
  margin-bottom: 14px;
  border: 1px solid var(--erp-border);
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
}
.erp-stat {
  padding: 10px 14px;
  border-right: 1px solid var(--erp-border);
  position: relative;
}
.erp-stat:last-child { border-right: 0; }
.erp-stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--erp-text-2);
  margin-bottom: 4px;
  font-weight: 600;
}
.erp-stat-value {
  font-size: 23px;
  font-weight: 600;
  color: var(--erp-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.erp-stat-value.is-accent { color: var(--erp-accent); }
.erp-stat-value.is-success { color: #246b43; }
.erp-stat-sub {
  font-size: 12.5px;
  color: var(--erp-text-3);
  margin-top: 3px;
}
.erp-stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 2px;
  background: var(--erp-accent);
  opacity: 0;
}
.erp-stat.is-flagged::before { opacity: 1; }

/* ───── Tabs (sub-page tabs, e.g. invoice filter tabs) ─── */

.erp-subtabs {
  display: flex;
  border-bottom: 1px solid var(--erp-border);
  margin-bottom: 14px;
  overflow-x: auto;
}
.erp-subtab {
  padding: 8px 16px;
  font-size: 14.5px;
  color: var(--erp-text);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.erp-subtab:hover { color: var(--erp-accent); background: var(--erp-hover); }
.erp-subtab.is-active {
  color: var(--erp-accent);
  border-bottom-color: var(--erp-accent);
  font-weight: 600;
}
.erp-subtab .erp-count {
  display: inline-block;
  margin-left: 5px;
  font-size: 12.5px;
  color: var(--erp-text-3);
  font-variant-numeric: tabular-nums;
}

/* ───── Flash messages ──────────────────────────────────── */

.erp-flash {
  padding: 8px 12px;
  border-radius: 3px;
  margin-bottom: 10px;
  font-size: 14.5px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}
.erp-flash-success { background: #e9f5ee; border-color: #c5e0d0; color: #246b43; }
.erp-flash-error   { background: #fcebe6; border-color: #f0c5b9; color: #9c2818; }
.erp-flash svg { flex-shrink: 0; width: 14px; height: 14px; }

/* ───── Mobile sidebar backdrop ─────────────────────────── */

.erp-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 34;
  display: none;
}
.erp-backdrop.is-open { display: block; }

/* ───── Mobile: tables → cards ──────────────────────────── */

@media (max-width: 767px) {
  /* Hide thead, but keep table as block */
  .erp-table thead {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px; width: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    position: absolute;
  }
  .erp-table,
  .erp-table tbody,
  .erp-table tr,
  .erp-table td {
    display: block;
    width: 100%;
  }
  .erp-table tbody tr {
    border: 1px solid var(--erp-border);
    border-radius: 4px;
    background: #fff !important;
    margin-bottom: 8px;
    padding: 10px 12px 8px;
    box-shadow: 0 1px 0 rgba(15,23,42,0.02);
  }
  .erp-table tbody tr:nth-child(even) td { background: transparent !important; }
  .erp-table tbody tr.is-clickable:hover td { background: transparent !important; }
  .erp-table tbody tr.is-clickable { cursor: pointer; }
  .erp-table tbody tr.is-clickable:active {
    background: var(--erp-stripe);
  }

  /* Each cell becomes a label/value row inside the card */
  .erp-table tbody td {
    border: 0 !important;
    padding: 4px 0 !important;
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 10px;
    align-items: baseline;
    text-align: left !important;
    min-height: 22px;
    font-size: 15px;
    line-height: 1.4;
  }
  .erp-table tbody td.is-num {
    text-align: left !important;
  }
  .erp-table tbody td::before {
    content: attr(data-label);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--erp-text-3);
    font-weight: 600;
    white-space: nowrap;
    align-self: center;
  }

  /* Cells that should span the full card width (e.g. top "Case #" header) */
  .erp-table tbody td.erp-stack-full {
    display: block;
    padding-top: 0 !important;
    margin-bottom: 4px;
    border-bottom: 1px solid #eef0f3 !important;
    padding-bottom: 6px !important;
  }
  .erp-table tbody td.erp-stack-full::before {
    display: block;
    margin-bottom: 2px;
  }

  /* Remove the meta inline layout and show on its own line */
  .erp-table tbody td .erp-meta {
    display: block;
    margin-top: 1px;
  }
  /* No labels on cells without data-label */
  .erp-table tbody td:not([data-label])::before { display: none; }
  .erp-table tbody td:not([data-label]) { grid-template-columns: 1fr; }
  /* Suppress empty cells */
  .erp-table tbody td:empty { display: none; }

  /* Make actions a horizontal row of links */
  .erp-table tbody td .erp-actions {
    flex-wrap: wrap;
    gap: 12px;
  }
  .erp-table tbody td .erp-actions a {
    font-size: 15px;
    padding: 4px 0;
  }

  /* Status pill on its own row, avoid wrapping clutter */
  .erp-table tbody td .erp-pill {
    margin-left: 4px;
  }
}

/* ───── Mobile: stat strip ───────────────────────────────── */

@media (max-width: 767px) {
  .erp-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }
  .erp-stat {
    padding: 10px 12px;
    border-right: 1px solid var(--erp-border);
    border-bottom: 1px solid var(--erp-border);
  }
  .erp-stat:nth-child(2n) { border-right: 0; }
  .erp-stat:nth-last-child(-n+2) { border-bottom: 0; }
  /* If odd count: last item full-width */
  .erp-stat:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    border-right: 0;
  }
  .erp-stat-label { font-size: 11px; }
  .erp-stat-value { font-size: 19.5px; }
  .erp-stat-sub { font-size: 12px; }
}

@media (max-width: 380px) {
  .erp-stats { grid-template-columns: 1fr; }
  .erp-stat { border-right: 0 !important; border-bottom: 1px solid var(--erp-border) !important; }
  .erp-stat:last-child { border-bottom: 0 !important; }
}

/* ───── Mobile: panels & toolbars ───────────────────────── */

@media (max-width: 767px) {
  .erp-panel-head {
    padding: 9px 12px;
  }
  .erp-panel-head h2 { font-size: 15px; }
  .erp-panel-body { padding: 12px; }
  .erp-toolbar {
    padding: 8px 10px;
    gap: 8px;
    font-size: 14px;
  }
  .erp-toolbar > *:last-child {
    margin-left: 0 !important;
    width: 100%;
  }
  .erp-subtabs {
    margin-bottom: 10px;
    padding-bottom: 0;
  }
  .erp-subtab {
    padding: 8px 12px;
    font-size: 14.5px;
  }

  .erp-side-section { padding: 12px 14px; }
  .erp-filter-list li a { padding: 8px 10px; font-size: 15px; }

  /* Forms */
  .erp-form-row { gap: 8px; }
  .erp-form-row > * { min-width: 100%; }
  .erp-input, .erp-select, .erp-textarea {
    font-size: 18.5px; /* prevents iOS zoom on focus */
    padding: 8px 10px;
  }
  .erp-search input { font-size: 18.5px; padding: 8px 8px 8px 32px; }
  .erp-btn { padding: 8px 12px; font-size: 15px; }
}

/* Helper utilities used inside ERP layouts */
.erp-link { color: var(--erp-link); text-decoration: none; }
.erp-link:hover { text-decoration: underline; color: var(--erp-link-hov); }
.erp-text-muted { color: var(--erp-text-2); }
.erp-text-dim { color: var(--erp-text-3); }
.erp-mono { font-family: 'Consolas', 'SF Mono', Menlo, monospace; font-size: 14px; }
.erp-text-num { font-variant-numeric: tabular-nums; }

/* Hide elements that were Fraunces-styled in the old build but still in the markup */
.erp-shell [style*="Fraunces"] { font-family: inherit !important; font-weight: 600 !important; }

/* Soft shadow for hovered table rows / buttons in modernized version */
.erp-panel { transition: box-shadow 0.15s ease; }
.erp-panel:hover { box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 2px 6px rgba(15,23,42,0.04); }

/* ───── Mobile nav section inside the drawer ───── */
.erp-mobile-nav-section { display: none; }
@media (max-width: 1024px) {
  .erp-mobile-nav-section { display: block; }
}

/* ───── 3D viewer ───── */
.mp-3d-viewer {
  position: relative;
  width: 100%;
  height: 480px;
  background: var(--erp-bg);
  border: 1px solid var(--erp-border);
  border-radius: 4px;
  overflow: hidden;
  cursor: grab;
}
.mp-3d-viewer:fullscreen { height: 100vh; border-radius: 0; }
.mp-3d-viewer:active { cursor: grabbing; }
.mp-viewer-canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
}
.mp-viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--erp-text-2);
  background: var(--erp-bg);
  z-index: 1;
}
.mp-viewer-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--erp-accent);
  background: #fcebe6;
  padding: 16px;
  text-align: center;
}
.mp-viewer-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 2;
}
.mp-viewer-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--erp-border-2);
  background: rgba(255,255,255,0.9);
  color: var(--erp-text);
  border-radius: 3px;
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.mp-viewer-btn:hover { background: #fff; border-color: var(--erp-accent); color: var(--erp-accent); }

@media (max-width: 600px) {
  .mp-3d-viewer { height: 320px; }
}

/* File row "View 3D" link */
.mp-3d-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--erp-link);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}
.mp-3d-link:hover { text-decoration: underline; color: var(--erp-link-hov); }

/* Inline 3D viewer panel inside file row */
.mp-view3d-panel {
  padding: 0 16px 16px;
  background: linear-gradient(180deg, #fafbfc 0%, #f3f4f6 100%);
  border-top: 1px solid #eef0f3;
}
.mp-view3d-panel .mp-3d-viewer {
  height: 460px;
  margin-top: 12px;
}
@media (max-width: 600px) {
  .mp-view3d-panel { padding: 0 10px 10px; }
  .mp-view3d-panel .mp-3d-viewer { height: 320px; }
}

/* Mobile-only user block at the end of the nav drawer */
.erp-tabs-user-mobile { display: none; }
@media (max-width: 900px) {
  .erp-tabs-user-mobile { display: block; }
}

/* Hide the now-irrelevant mobile-nav-section (was inside the dead sidebar) */
.erp-mobile-nav-section { display: none !important; }

/* Hide the dead backdrop */
.erp-backdrop { display: none !important; }

/* Inside the page toolbar, sidebar-style filter blocks need to be inlined.
   This keeps backward compat with pages that still emit erp-side-section /
   erp-filter-list HTML. */
.erp-page-toolbar .erp-side-section {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  margin: 0;
  flex-wrap: wrap;
}
.erp-page-toolbar .erp-side-label {
  margin: 0 4px 0 0;
  font-size: 11.5px;
  text-transform: uppercase;
  color: var(--erp-text-3);
  font-weight: 600;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.erp-page-toolbar .erp-filter-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}
.erp-page-toolbar .erp-filter-list li { margin: 0; }
.erp-page-toolbar .erp-filter-list li a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 14px;
  border: 1px solid var(--erp-border-2);
  background: #fff;
  border-radius: 14px;
  text-decoration: none;
  color: var(--erp-text);
  border-left: 1px solid var(--erp-border-2);
  white-space: nowrap;
  margin: 0;
}
.erp-page-toolbar .erp-filter-list li a span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.erp-page-toolbar .erp-filter-list li a:hover { background: var(--erp-hover); }
.erp-page-toolbar .erp-filter-list li a.is-active {
  background: var(--erp-accent);
  border-color: var(--erp-accent);
  color: #fff;
}
.erp-page-toolbar .erp-filter-list li a.is-active .erp-count { color: #fff; opacity: 0.85; }
.erp-page-toolbar .erp-search {
  flex: 0 0 auto;
  min-width: 220px;
}
@media (max-width: 700px) {
  .erp-page-toolbar .erp-search { min-width: 100%; }
}
/* Hide calendar widget if it still appears in toolbar context (defensive) */
.erp-page-toolbar .erp-calendar { display: none; }

/* ───── Two-column page layout ─────────────────────────────
   Used on detail pages (single invoice, single case) where a
   compact side panel (status / summary / actions) lives next to
   the main content. Stacks on mobile.
   ──────────────────────────────────────────────────────────── */
.erp-two-col {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 14px;
  align-items: start;
}
.erp-two-col .erp-aside {
  position: sticky;
  top: 70px;
}
.erp-aside .erp-panel {
  margin-bottom: 12px;
}
.erp-aside .erp-side-section {
  border-bottom: 1px solid #eef0f3;
  padding: 12px 14px;
}
.erp-aside .erp-side-section:last-child {
  border-bottom: 0;
}
.erp-aside .erp-side-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--erp-text-2);
  font-weight: 600;
  margin-bottom: 6px;
}

@media (max-width: 1100px) {
  .erp-two-col {
    grid-template-columns: 1fr;
  }
  .erp-two-col .erp-aside {
    position: static;
    order: -1;     /* stick the aside above the main on small screens */
  }
}

/* ───── ERP modal dialog ───────────────────────────────────
   Lightweight modal pattern for confirms / forms. Toggled by
   adding/removing `.is-hidden`. The body scroll-lock is up to JS.
   ──────────────────────────────────────────────────────────── */
.erp-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.erp-modal.is-hidden { display: none; }
.erp-modal-dialog {
  background: var(--erp-panel);
  border: 1px solid var(--erp-border);
  border-radius: 4px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}
.erp-modal-dialog.is-wide { max-width: 560px; }
.erp-modal-head {
  padding: 12px 16px;
  background: linear-gradient(180deg, #fafbfc 0%, #f3f4f6 100%);
  border-bottom: 1px solid var(--erp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.erp-modal-head h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--erp-text);
}
.erp-modal-close {
  background: transparent;
  border: 0;
  padding: 4px 6px;
  color: var(--erp-text-2);
  cursor: pointer;
  font-size: 18.5px;
  line-height: 1;
}
.erp-modal-close:hover { color: var(--erp-accent); }
.erp-modal-body {
  padding: 16px;
}
.erp-modal-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--erp-border);
  background: var(--erp-stripe);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  .erp-modal { padding: 0; align-items: stretch; }
  .erp-modal-dialog { border-radius: 0; max-width: 100%; min-height: 100%; }
}

