/* TGEM Manager — Custom Styles */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

:root {
  --font-display: 'Sora', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --sidebar-width: 256px;
  --topbar-height: 64px;
  --color-primary: #8C1F2E;
  --color-primary-dark: #6E1823;
  --color-sidebar-bg: #8F1D2C;
  --color-sidebar-text: #CFAAB1;
  --color-sidebar-active: #F8F5F5;
  --color-sidebar-hover: #751421;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background-color: #F8FAFC;
  color: #1E293B;
}

h1, h2, h3, h4, h5, h6, .font-display {
  font-family: var(--font-display);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;   /* prevent accordion sub-items from creating h-scroll */
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  margin: 1px 8px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.sidebar-link:hover {
  background-color: #751421;
  color: #F8F5F5;
}

.sidebar-link.active {
  background-color: #A82438;
  color: #F8F5F5;
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 #F5C6CE;
}

.sidebar-group-label {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #D8B8BE;
  padding: 14px 24px 4px;
}

/* Top-level Dashboard link — matches root section prominence */
.sidebar-root-link {
  font-weight: 700;
  font-size: 0.95rem;
  color: #F8F5F5 !important;
}
.sidebar-root-link:hover { background-color: #751421 !important; color: #F8F5F5 !important; }
.sidebar-root-link.active { background-color: #A82438 !important; color: #F8F5F5 !important; box-shadow: inset 3px 0 0 0 #F5C6CE !important; }

/* Top bar */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid #E2E8F0;
  z-index: 40;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

.page-body {
  padding: 24px;
  max-width: 1600px;
}

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 20px;
}

/* KPI Tiles */
.kpi-tile {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #E8EDF5;
  border-left: 4px solid #CBD5E1;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
  transition: box-shadow .2s ease, transform .2s ease;
}
.kpi-tile:hover {
  box-shadow: 0 6px 20px rgba(15,23,42,.09);
  transform: translateY(-2px);
}

/* Color accent variants */
.kpi-tile--slate   { border-left-color: #94A3B8; }
.kpi-tile--indigo  { border-left-color: #6366F1; }
.kpi-tile--emerald { border-left-color: #10B981; }
.kpi-tile--amber   { border-left-color: #F59E0B; }
.kpi-tile--rose    { border-left-color: #F43F5E; }
.kpi-tile--blue    { border-left-color: #3B82F6; }
.kpi-tile--tgem    { border-left-color: #8C1F2E; }

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 700;
  color: #0F172A;
  line-height: 1;
}

.kpi-label {
  font-size: 0.72rem;
  color: #64748B;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Salesforce-style chevron path – hover state for future stages */
.sf-chevron-future:hover {
  background: #d1d5db !important;
  color: #374151 !important;
}

/* Badges / Status Pills */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead th {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #64748B;
  padding: 10px 16px;
  border-bottom: 1px solid #E2E8F0;
  text-align: left;
  white-space: nowrap;
  background: #F8FAFC;
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background-color: #F8FAFC;
}

/* Forms */
.form-input {
  width: 100%;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 12px;
  padding-right: 12px;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: #1E293B;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: #8C1F2E;
  box-shadow: 0 0 0 3px rgba(140, 31, 46, 0.12);
}

/* Tailwind padding utilities on .form-input — two-class specificity beats
   both the .form-input base rule and the Tailwind single-class rule,
   so these always win regardless of stylesheet load order. */
.form-input.pl-8  { padding-left:  2rem; }
.form-input.pl-9  { padding-left:  2.25rem; }
.form-input.pl-10 { padding-left:  2.5rem; }
.form-input.pr-8  { padding-right: 2rem; }
.form-input.pr-9  { padding-right: 2.25rem; }
.form-input.pr-10 { padding-right: 2.5rem; }
.form-input.pr-14 { padding-right: 3.5rem; }

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
  display: block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: #8C1F2E;
  color: white;
}
.btn-primary:hover { background-color: #6E1823; color: white; }

.btn-secondary {
  background-color: white;
  color: #374151;
  border: 1px solid #D1D5DB;
}
.btn-secondary:hover { background-color: #F9FAFB; }

.btn-danger {
  background-color: #EF4444;
  color: white;
}
.btn-danger:hover { background-color: #DC2626; color: white; }

.btn-warning {
  background-color: #FEF3C7;
  color: #92400E;
  border-color: #FCD34D;
}
.btn-warning:hover { background-color: #FDE68A; color: #78350F; }

.btn-success {
  background-color: #D1FAE5;
  color: #065F46;
  border-color: #6EE7B7;
}
.btn-success:hover { background-color: #A7F3D0; color: #064E3B; }

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8125rem;
}

/* Tabs */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid #E2E8F0;
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748B;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.tab-btn:hover { color: #8C1F2E; }
.tab-btn.active {
  color: #8C1F2E;
  border-bottom-color: #8C1F2E;
  font-weight: 600;
}

/* Progress Bar */
.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: #E2E8F0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8C1F2E, #C94054);
  transition: width 0.5s ease;
}

/* Gantt Chart */
.gantt-container {
  overflow-x: auto;
}

.gantt-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #F1F5F9;
  min-height: 40px;
}

.gantt-label {
  min-width: 200px;
  max-width: 200px;
  padding: 8px 12px;
  font-size: 0.8125rem;
  border-right: 1px solid #E2E8F0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gantt-timeline {
  flex: 1;
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
}

.gantt-bar {
  position: absolute;
  height: 24px;
  border-radius: 4px;
  background: #8C1F2E;
  opacity: 0.85;
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-size: 0.7rem;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.gantt-bar:hover { opacity: 1; }

/* ─── Kanban Board ─────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 20px;
  align-items: flex-start;
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 transparent;
}
.kanban-board::-webkit-scrollbar { height: 6px; }
.kanban-board::-webkit-scrollbar-track { background: transparent; }
.kanban-board::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }

/* Stage color tokens */
.kanban-col[data-stage="lead"]        { --sc: #64748B; }
.kanban-col[data-stage="qualified"]   { --sc: #0EA5E9; }
.kanban-col[data-stage="proposal"]    { --sc: #6366F1; }
.kanban-col[data-stage="negotiation"] { --sc: #8B5CF6; }
.kanban-col[data-stage="won"]         { --sc: #10B981; }
.kanban-col[data-stage="on_hold"]     { --sc: #F59E0B; }
.kanban-col[data-stage="lost"],
.kanban-col[data-stage="cancelled"]   { --sc: #EF4444; }

/* Column shell */
.kanban-col,
.kanban-column {
  flex: 1 1 0;
  min-width: 162px;
  max-width: 285px;
  background: #F1F5F9;
  border-radius: 12px;
  border: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 210px);
}

/* Column header */
.kanban-col-header,
.kanban-column-header {
  padding: 11px 12px 9px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-top: 3px solid var(--sc, #94A3B8);
  border-bottom: 1px solid #E2E8F0;
  border-radius: 10px 10px 0 0;
  background: white;
  flex-shrink: 0;
}

/* Column body — scrollable */
.kanban-col-body {
  padding: 8px;
  min-height: 80px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #E2E8F0 transparent;
  transition: background 0.12s;
}
.kanban-col-body::-webkit-scrollbar { width: 3px; }
.kanban-col-body::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 2px; }

.kanban-col-body.drag-over {
  background: rgba(99,102,241,0.06);
  outline: 2px dashed rgba(99,102,241,0.3);
  outline-offset: -4px;
  border-radius: 8px;
}
.kanban-col-body.ring-2 { background: rgba(99,102,241,0.06); border-radius: 8px; }

/* Cards */
.kanban-card {
  background: white;
  border-radius: 8px;
  padding: 10px 11px 9px;
  margin-bottom: 6px;
  border: 1px solid #E8EEF4;
  border-left: 3px solid var(--sc, #94A3B8);
  cursor: grab;
  transition: box-shadow 0.14s, transform 0.12s;
  box-shadow: 0 1px 2px rgba(15,23,42,0.05);
  user-select: none;
}
.kanban-card:hover {
  box-shadow: 0 5px 16px rgba(15,23,42,0.1);
  transform: translateY(-2px);
}
.kanban-card:active,
.kanban-card.dragging,
.kanban-card.opacity-40 {
  opacity: 0.45;
  transform: scale(0.97) rotate(0.8deg);
  box-shadow: 0 10px 28px rgba(15,23,42,0.14);
  cursor: grabbing;
}

/* Probability progress bar */
.kanban-prob-bar {
  height: 3px;
  border-radius: 2px;
  background: #E2E8F0;
  overflow: hidden;
  margin-top: 7px;
}
.kanban-prob-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--sc, #6366F1);
}

/* btn-ghost */
.btn-ghost {
  background: transparent;
  color: #64748B;
  border: 1px solid transparent;
}
.btn-ghost:hover { background: #F1F5F9; color: #334155; }

/* Alerts/Messages */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.alert-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #94A3B8;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: #94A3B8;
}

.breadcrumb a {
  color: #64748B;
  text-decoration: none;
}
.breadcrumb a:hover { color: #8C1F2E; text-decoration: underline; }

/* Utilities */
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-overdue { color: #EF4444; }
.text-warning { color: #F59E0B; }
.text-success { color: #10B981; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
}

/* ── Sidebar scrollbar — thin, discreet, burgundy-matching ── */
.sidebar-nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); }

/* Collapsible section header button */
.sidebar-section-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 16px);
  margin: 2px 8px 0;
  padding: 9px 12px 5px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #D8B8BE;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.sidebar-section-btn:hover { color: #F8F5F5; background: #751421; }
.sidebar-section-btn--open { background: #7A1826; color: #F8F5F5; }

/* Sub-label inside a collapsible (e.g. "ORDERS" within Purchasing) */
.sidebar-sub-label {
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  padding: 10px 14px 2px 14px;
  margin-top: 2px;
}

/* ── Bulk Import Modal (shared across all document views) ── */
.bi-modal-backdrop {
  position:fixed;inset:0;background:rgba(15,23,42,.55);backdrop-filter:blur(3px);
  z-index:60;display:flex;align-items:flex-start;justify-content:center;
  padding:24px 16px;overflow-y:auto;
  opacity:0;transition:opacity .2s ease;pointer-events:none;
}
.bi-modal-backdrop.show { opacity:1;pointer-events:all; }
.bi-modal-panel {
  background:white;border-radius:20px;box-shadow:0 25px 60px rgba(0,0,0,.3);
  width:100%;max-width:1100px;display:flex;flex-direction:column;
  transform:translateY(20px) scale(.98);transition:transform .22s ease,opacity .22s ease;opacity:0;
}
.bi-modal-backdrop.show .bi-modal-panel { transform:none;opacity:1; }
.bi-modal-hdr {
  padding:22px 28px 18px;border-radius:20px 20px 0 0;
  background:linear-gradient(135deg,#8C1F2E 0%,#5A1220 100%);color:white;flex-shrink:0;
}
.bi-modal-body { padding:20px 28px;overflow-y:auto;max-height:70vh; }
.bi-modal-ftr { padding:14px 28px;border-top:1px solid #f1f5f9;display:flex;gap:10px;justify-content:flex-end;flex-shrink:0; }
.bi-drop { border:2px dashed #CBD5E1;border-radius:14px;padding:36px 24px;text-align:center;cursor:pointer;transition:all .15s; }
.bi-drop.drag-over { border-color:#8C1F2E;background:#FFF5F6; }
.bi-drop:hover { border-color:#94A3B8; }

/* ── Button loading state ─────────────────────────────────────────────────── */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
  color: white;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── Copy button ──────────────────────────────────────────────────────────── */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  color: #94a3b8;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  flex-shrink: 0;
}
.copy-btn:hover { background: #f1f5f9; color: #475569; }

/* ── Modal pop animation ─────────────────────────────────────────────────── */
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.93) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.animate-pop { animation: pop-in 0.18s ease-out forwards; }

/* ── Chart empty overlay ─────────────────────────────────────────────────── */
.chart-empty-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #94a3b8;
  pointer-events: none;
}

/* ── Required field indicator ────────────────────────────────────────────── */
label.form-label.required::after,
.form-label[data-required]::after {
  content: ' *';
  color: #dc2626;
  font-size: 0.75rem;
}

/* ── Monetary amount display ────────────────────────────────────────────────
   Use .amount on any element rendering a monetary value (fr_number / fr_currency).
   Overrides grey text with a professional dark-blue and a slight size boost.
   Always combine with the existing layout class; e.g.:
       <span class="amount">{{ val|fr_number:0 }}</span>
──────────────────────────────────────────────────────────────────────────── */
.amount {
  color: #1e3a8a;   /* blue-900 — deep navy, readable on white */
  font-weight: 700;
}

/* Kanban column sub-total — now rendered inside the header */
.kanban-col-total {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--sc, #334155);
  letter-spacing: -0.01em;
  padding: 0;
}

/* Kanban card amount */
.kanban-card-amount {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e3a8a;
  letter-spacing: -0.02em;
}

/* ── Kanban mobile column sizing ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .kanban-board { padding-bottom: 12px; gap: 8px; }
  .kanban-col, .kanban-column {
    flex: 0 0 270px;
    min-width: 270px;
    max-width: 270px;
    max-height: calc(100vh - 260px);
  }
}

/* Calendar horizontal scroll on mobile */
@media (max-width: 768px) {
  .calendar-scroll-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .calendar-scroll-wrap > div { min-width: 560px; }
}

/* ── Mobile / Responsive utilities ───────────────────────────────────────── */

/* Horizontal-scroll wrapper for wide tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-responsive .data-table {
  min-width: 600px;
}

/* Mobile card that replaces a table row */
.mob-card {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 14px 16px;
  transition: box-shadow .15s;
}
.mob-card:active { box-shadow: 0 0 0 2px #c7d2fe; }

.mob-card-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.8125rem;
}
.mob-card-label {
  flex-shrink: 0;
  width: 88px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #94a3b8;
}

@media (max-width: 1024px) {
  .page-body  { padding: 14px; }
  .card-body  { padding: 14px; }
  .card-header { padding: 12px 14px; }
  .kpi-tile   { padding: 14px; }
  .kpi-value  { font-size: 1.5rem; }
}

@media (max-width: 640px) {
  .page-body  { padding: 10px; }
  .card-body  { padding: 12px; }
  .btn-sm { min-height: 40px; padding-top: 9px; padding-bottom: 9px; }
  .form-input { min-height: 44px; }
  .badge { padding: 3px 10px; }
}

/* Kanban: horizontal scroll on mobile, normal grid on desktop */
.kanban-scroll-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}
.kanban-columns-flex {
  display: flex;
  gap: 12px;
  min-width: max-content;
}
@media (min-width: 1024px) {
  .kanban-scroll-container { overflow-x: visible; padding-bottom: 0; }
  .kanban-columns-flex { min-width: 0; display: grid; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PROJECTS MODULE — Mobile Adaptations
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Module nav: compact on mobile ──────────────────────────────────────── */
@media (max-width: 768px) {
  .mod-btn {
    min-width: 70px;
    padding: 7px 7px 8px;
    font-size: 11px;
    gap: 3px;
    flex: 0 0 auto;        /* don't stretch, let the bar scroll */
  }
  .mod-btn svg { width: 13px; height: 13px; }
  .mod-pill   { font-size: 9px; padding: 1px 4px; }
  .mod-sub-btn { padding: 4px 9px; font-size: 11px; }
  .mod-sub-btn svg { width: 11px; height: 11px; }
  .mod-nav-sub { padding: 5px 8px; gap: 2px; }
  .mod-sub-sep { margin: 0 1px; }
}

/* ── Project hero header ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Slightly smaller project name on very small screens */
  .proj-hero h1.font-display { font-size: 1.2rem; }
  /* Hero meta chips: tighter gap */
  .proj-hero .proj-meta-chip { font-size: 11px; gap: 3px; }
  /* KPI tile values compact */
  .kpi-tile .text-xl { font-size: 1.15rem; }
  /* Progress cards compact */
  .proj-hero-bar { width: 4px; }
}

/* ── Mobile project card (project list view) ────────────────────────────── */
.proj-mob-card {
  background: white;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(15,23,42,.06);
  overflow: hidden;
  transition: box-shadow .18s, transform .15s;
}
.proj-mob-card:active {
  box-shadow: 0 4px 18px rgba(140,31,46,.18);
  transform: translateY(-1px);
}
.proj-mob-card-bar {
  height: 3px;
  background: linear-gradient(90deg, #8C1F2E 0%, #C94054 100%);
}
.proj-mob-card-body { padding: 13px 15px 10px; }
.proj-mob-card-meta {
  display: flex; align-items: center; gap: 5px;
  font-size: .72rem; color: #64748b; margin-bottom: 5px;
}
.proj-mob-card-name {
  font-size: .9rem; font-weight: 700; color: #0f172a;
  line-height: 1.35; margin-bottom: 8px;
}
.proj-mob-card-row {
  display: flex; align-items: center; gap: 5px;
  font-size: .75rem; color: #475569; margin-bottom: 3px;
}
.proj-mob-card-progress {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
}
.proj-mob-card-prog-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
}
.proj-mob-card-prog-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; min-width: 56px; }
.proj-mob-card-prog-bar { flex: 1; height: 5px; background: #f1f5f9; border-radius: 99px; overflow: hidden; }
.proj-mob-card-prog-val { font-size: .72rem; font-weight: 800; min-width: 28px; text-align: right; }
.proj-mob-card-footer {
  display: flex; gap: 6px; padding: 8px 10px 10px;
  background: #f8fafc; border-top: 1px solid #f1f5f9;
}

/* ── Detail-tab mobile table rows (card fallback) ───────────────────────── */
.proj-row-card {
  border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 11px 13px; margin-bottom: 7px;
  background: white;
}
.proj-row-card-title { font-size: .85rem; font-weight: 600; color: #1e293b; margin-bottom: 5px; }
.proj-row-card-meta  { font-size: .75rem; color: #64748b; display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 4px; }
.proj-row-card-meta-item { display: flex; align-items: center; gap: 4px; }
.proj-row-card-meta-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAVIGATION BAR
   ═══════════════════════════════════════════════════════════════════════════ */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: stretch;
  z-index: 45;
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(56px + constant(safe-area-inset-bottom));
  height: calc(56px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 -1px 0 #e2e8f0, 0 -4px 12px rgba(0,0,0,.06);
}
@media (min-width: 1024px) {
  .mobile-bottom-nav { display: none !important; }
}

.mob-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0 4px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mob-nav-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.mob-nav-item span { line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mob-nav-item.active { color: #8C1F2E; }
.mob-nav-item.active svg { stroke: #8C1F2E; }
.mob-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: #8C1F2E;
}
.mob-nav-item:active { background: rgba(140,31,46,.05); border-radius: 10px; }

/* ── Main content: clear bottom nav ── */
@media (max-width: 1023px) {
  .main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE TOPBAR
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 639px) {
  .topbar { padding: 0 12px; gap: 8px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE HEADER PATTERN (used in many views)
   ═══════════════════════════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  font-family: var(--font-display);
}
.page-subtitle {
  font-size: 0.8125rem;
  color: #64748b;
  margin-top: 2px;
}
@media (max-width: 640px) {
  .page-title { font-size: 1.2rem; }
  .page-header { margin-bottom: 1rem; }
  .page-header .flex.items-center.gap-2 { flex-wrap: wrap; gap: 8px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE FILTER BARS
   Fixes fixed-width flex-none children in card filter forms on mobile
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .card form .flex.flex-wrap > .flex-none,
  .card > form > .flex.flex-wrap > .flex-none,
  form.flex.flex-wrap > .flex-none,
  form.flex.flex-wrap > div.flex-none {
    flex: 1 1 calc(50% - 6px) !important;
    width: auto !important;
    min-width: 110px;
  }
  .card form .flex.flex-wrap > .flex-1,
  .card form .flex.flex-wrap > [class*="min-w-"],
  form.flex.flex-wrap > .flex-1,
  form.flex.flex-wrap > [class*="min-w-"] {
    flex: 1 1 100% !important;
    min-width: 0 !important;
    width: 100% !important;
  }
  .card form .flex.flex-wrap > label.flex-none { flex: 0 0 auto !important; }
  .card form .flex.flex-wrap > a.btn.flex-none,
  .card form .flex.flex-wrap > a.btn-ghost,
  form.flex.flex-wrap > a.btn,
  form.flex.flex-wrap > button.btn,
  form.flex.flex-wrap > input[type="checkbox"],
  form.flex.flex-wrap > .flex.items-center.gap-2 {
    flex: 0 0 auto !important;
    width: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOUCH TARGETS — 44px minimum (WCAG 2.5.5)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .btn:not(.btn-sm):not(.btn-xs) { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
  .tab-btn { padding: 12px 14px; font-size: 0.8125rem; }
  /* Sidebar toggle — bigger hit area */
  #sidebar-toggle { padding: 10px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE FORM GRID IMPROVEMENTS
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* Stack 3+ column grids to 1 col if no responsive prefix used */
  .grid.grid-cols-3:not([class*="sm:grid-cols"]):not([class*="md:grid-cols"]),
  .grid.grid-cols-4:not([class*="sm:grid-cols"]):not([class*="md:grid-cols"]) {
    grid-template-columns: 1fr !important;
  }
  /* Modal sizing */
  .bg-white.rounded-2xl.shadow-2xl.w-full { margin: 8px; width: calc(100% - 16px) !important; }
  /* Bulk import modal */
  .bi-modal-body { padding: 14px 16px; max-height: 50vh; }
  .bi-modal-hdr { padding: 16px 16px 12px; }
  .bi-modal-ftr { padding: 10px 16px; flex-wrap: wrap; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   COLUMN HIDE/SHOW HELPERS FOR MOBILE TABLES
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .mob-hide { display: none !important; }
}
@media (min-width: 641px) {
  .mob-only { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SCROLL HINT for wide tables
   ═══════════════════════════════════════════════════════════════════════════ */
.mob-scroll-hint {
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: #94a3b8;
  margin-bottom: 6px;
  padding: 0 2px;
}
@media (max-width: 768px) {
  .mob-scroll-hint { display: flex; }
  .mob-scroll-hint svg { width: 14px; height: 14px; animation: mob-nudge 1.6s ease-in-out infinite; }
}
@keyframes mob-nudge {
  0%, 100% { transform: translateX(0); opacity: 0.5; }
  50%       { transform: translateX(5px); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   BILLING MATRIX — force horizontal scroll on all screen sizes
   (already has overflow-x-auto but add touch momentum)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .billing-matrix-wrap,
  [data-matrix-scroll] { -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR SWIPE EDGE (touch target to open sidebar)
   ═══════════════════════════════════════════════════════════════════════════ */
#sidebar-swipe-edge {
  position: fixed;
  top: 64px;
  left: 0;
  width: 16px;
  bottom: calc(56px + env(safe-area-inset-bottom));
  z-index: 30;
  display: none;
}
@media (max-width: 1023px) {
  #sidebar-swipe-edge { display: block; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOVER-REVEAL ACTIONS — touch devices have no hover, so always show
   group-hover:opacity-* elements (action buttons, "Open" links, etc.)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (hover: none) {
  .group-hover\:opacity-100,
  .group-hover\:opacity-0 {
    opacity: 1 !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   GANTT PANELS — shrink fixed height to make room for the bottom nav bar
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  .gantt-panel { height: calc(100vh - 230px - 56px - env(safe-area-inset-bottom)) !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DOCUMENT PERMISSIONS — stack folder tree above ACL panel on mobile
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .perm-panel { flex-direction: column; height: auto !important; min-height: 0 !important; }
  .perm-tree { width: 100% !important; max-height: 260px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ORG CHART — shrink fixed height to make room for the bottom nav bar
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  .orgchart-page { height: calc(100vh - 64px - 56px - env(safe-area-inset-bottom)) !important; }
}

/* ══════════════════════════════════════════════════════════════
   GLOBAL PRINT STYLES
   ══════════════════════════════════════════════════════════════ */
@media screen {
  .print-only { display: none !important; }
}
@media print {
  /* Hide chrome */
  #sidebar, header, .breadcrumbs-bar, .no-print,
  .alert, .alert-auto-dismiss { display: none !important; }

  /* Main content fills page */
  body  { background: #fff !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; width: 100% !important; }
  .page-body    { padding: 6mm !important; }

  /* Reveal print-only elements */
  .print-only   { display: block !important; }
  .print-flex   { display: flex  !important; }

  /* Force colour printing */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* ── Print document header ────────────────────────────────── */
  .print-doc-header {
    display: flex !important;
    align-items: flex-start;
    gap: 12mm;
    border-bottom: 2.5pt solid #8C1F2E;
    padding-bottom: 4mm;
    margin-bottom: 5mm;
  }
  .print-logo { height: 16mm; width: auto; object-fit: contain; }
  .print-company { display: flex; flex-direction: column; }
  .print-company strong { font-size: 13pt; font-weight: 700; color: #8C1F2E; }
  .print-company span   { font-size: 7.5pt; color: #475569; }
  .print-meta { flex: 1; }
  .print-meta h1 { font-size: 12pt; font-weight: 700; color: #1e3a5f; margin: 0 0 2mm; }
  .print-meta table { border-collapse: collapse; font-size: 8pt; }
  .print-meta th { text-align: left; color: #64748b; font-weight: 600; padding-right: 3mm; white-space: nowrap; }
  .print-meta td { color: #1e293b; }
  .print-date-col { text-align: right; font-size: 7.5pt; color: #475569; white-space: nowrap; }
  .print-date-col strong { display: block; font-size: 10pt; color: #1e293b; }

  /* ── Signature block ──────────────────────────────────────── */
  .print-signatures {
    display: flex !important;
    gap: 10mm;
    margin-top: 10mm;
    border-top: 1.5pt solid #cbd5e1;
    padding-top: 6mm;
    page-break-inside: avoid;
  }
  .print-sig-col { flex: 1; font-size: 9pt; }
  .print-sig-col .sig-party { font-weight: 700; font-size: 10pt; color: #1e3a5f; margin-bottom: 3mm; }
  .print-sig-col .sig-field { margin-bottom: 8mm; }
  .print-sig-col .sig-label { font-size: 8pt; color: #64748b; margin-bottom: 1mm; }
  .print-sig-col .sig-underline {
    border-bottom: 1pt solid #94a3b8;
    height: 6mm;
    margin-top: 1mm;
  }
  .print-sig-col .sig-area {
    border-bottom: 1pt solid #94a3b8;
    height: 18mm;
    margin-top: 1mm;
  }
}

/* =============================================================================
   ERP-STYLE GROUP / DETAIL TABLE (shared)
   Pure, light, dense - inspired by SAP ALV / Sage grids.
   Used by Orders & Deliveries, Catalogue, Budget & Objectives.
   ============================================================================= */
.erp-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }

.erp-table thead th {
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #64748B;
  padding: 9px 10px;
  border-bottom: 2px solid #E2E8F0;
  text-align: left;
  white-space: nowrap;
  background: #F8FAFC;
}
.erp-table thead th.ta-l  { text-align: left; }
.erp-table thead th.ta-r  { text-align: right; }
.erp-table thead th.ta-c  { text-align: center; }
.erp-table tbody td.ta-r  { text-align: right; }
.erp-table tbody td.ta-c  { text-align: center; }
.erp-table tfoot td.ta-r  { text-align: right; }
.erp-table tfoot td.ta-c  { text-align: center; }

.erp-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
  white-space: nowrap;
}
.erp-table tbody tr.item-row:hover { background: #F8FAFC; }
.erp-table tbody tr.item-row.row-late { background: #FEF6F5; }
.erp-table tbody tr.item-row.row-late:hover { background: #FCEAE8; }

/* -- Group bar (full-width colored band, SAP-ALV style) -------------------- */
.grp-row td { padding: 0 !important; border-bottom: 1px solid #E2E8F0; }
.grp-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px 10px 12px;
  cursor: pointer;
  border-left: 4px solid transparent;
  transition: background .12s ease;
}
.grp-chevron {
  display: inline-flex;
  flex-shrink: 0;
  color: #94A3B8;
  transition: transform .15s ease;
}
.grp-chevron.open { transform: rotate(90deg); }

.grp-supplier { font-weight: 700; font-size: 0.86rem; color: #0F172A; white-space: nowrap; }
.grp-po { font-family: ui-monospace, monospace; font-size: 0.74rem; color: #64748B; white-space: nowrap; }
.grp-projects { font-size: 0.7rem; font-weight: 700; letter-spacing: .03em; color: #94A3B8; white-space: nowrap; }
.grp-meta { font-size: 0.72rem; color: #94A3B8; white-space: nowrap; }
.grp-spacer { flex: 1 1 auto; }
.grp-qty { font-size: 0.72rem; text-align: right; line-height: 1.4; white-space: nowrap; flex-shrink: 0; }
.grp-qty .num { font-weight: 700; color: #334155; }
.grp-amount { font-weight: 700; font-size: 0.92rem; color: #1e3a8a; white-space: nowrap; min-width: 100px; text-align: right; flex-shrink: 0; }
.grp-progress { display: flex; align-items: center; gap: 6px; width: 110px; flex-shrink: 0; }
.grp-progress-bar { flex: 1; height: 5px; border-radius: 99px; background: rgba(15,23,42,.08); overflow: hidden; }
.grp-progress-fill { height: 100%; border-radius: 99px; }
.grp-progress-pct { font-size: 0.72rem; font-weight: 700; width: 34px; text-align: right; flex-shrink: 0; }
.grp-action { flex-shrink: 0; }

/* -- Status tints (light backgrounds, colored accent bar) ------------------ */
.grp-complete .grp-bar { background: #ECFDF5; border-left-color: #10B981; }
.grp-complete .grp-bar:hover { background: #D1FAE5; }
.grp-complete .grp-progress-fill { background: #10B981; }
.grp-complete .grp-progress-pct { color: #059669; }

.grp-delayed .grp-bar { background: #FEF2F2; border-left-color: #EF4444; }
.grp-delayed .grp-bar:hover { background: #FEE2E2; }
.grp-delayed .grp-progress-fill { background: #EF4444; }
.grp-delayed .grp-progress-pct { color: #DC2626; }

.grp-partial .grp-bar { background: #EFF6FF; border-left-color: #3B82F6; }
.grp-partial .grp-bar:hover { background: #DBEAFE; }
.grp-partial .grp-progress-fill { background: #3B82F6; }
.grp-partial .grp-progress-pct { color: #2563EB; }

.grp-pending .grp-bar { background: #F8FAFC; border-left-color: #94A3B8; }
.grp-pending .grp-bar:hover { background: #F1F5F9; }
.grp-pending .grp-progress-fill { background: #94A3B8; }
.grp-pending .grp-progress-pct { color: #64748B; }

.grp-delivery .grp-bar { background: #F0F9FF; border-left-color: #0EA5E9; }
.grp-delivery .grp-bar:hover { background: #E0F2FE; }

/* -- Item-row progress bar -------------------------------------------------- */
.item-progress { display: flex; align-items: center; gap: 6px; width: 96px; }
.item-progress-bar { flex: 1; height: 5px; border-radius: 99px; background: #E2E8F0; overflow: hidden; }
.item-progress-fill { height: 100%; border-radius: 99px; }
.item-progress-pct { font-size: 0.7rem; font-weight: 700; width: 30px; text-align: right; }

/* -- Indent guide for detail rows ------------------------------------------- */
.item-indent { color: #E2E8F0; text-align: center; width: 22px; }

/* -- Quick project picker chips --------------------------------------------- */
.proj-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px;
  border: 1px solid #E2E8F0; background: white;
  font-size: 0.8125rem; font-weight: 600; color: #334155;
  text-decoration: none; transition: all .12s ease;
}
.proj-chip:hover { border-color: #C94054; color: #8C1F2E; background: #FDF4F5; }
.proj-chip .code { font-family: ui-monospace, monospace; font-size: 0.72rem; color: #94A3B8; }

/* -- Project select prominence ----------------------------------------------- */
.project-select-wrap { position: relative; }
.project-select-wrap select { font-weight: 700; }
.project-select-wrap select:invalid { color: #94A3B8; font-weight: 500; }

/* -- Sub-navigation tabs (catalogue / budget / categories) ------------------- */
.subnav {
  display: flex; gap: 2px; margin-bottom: 18px;
  padding: 4px; background: #F1F5F9; border: 1px solid #E7ECF2;
  border-radius: 12px; overflow-x: auto;
  scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; font-size: 0.8125rem; font-weight: 600;
  color: #64748B; text-decoration: none; white-space: nowrap;
  border-radius: 8px;
  transition: color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.subnav a svg { width: 14px; height: 14px; flex-shrink: 0; opacity: .65; transition: opacity .15s ease; }
.subnav a:hover { color: #334155; background: rgba(255,255,255,.7); }
.subnav a:hover svg { opacity: .9; }
.subnav a.active {
  color: #8C1F2E; background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.08), 0 0 0 1px #F1D9DC;
}
.subnav a.active svg { opacity: 1; }

/* -- Category quick-assign select ------------------------------------------- */
.quick-assign-select {
  font-size: 0.75rem; padding: 3px 6px; border-radius: 6px;
  border: 1px solid #E2E8F0; background: #F8FAFC; color: #334155;
  max-width: 220px;
}
.quick-assign-select:focus { outline: 2px solid #8C1F2E33; border-color: #8C1F2E; }

/* -- Editable budget/objective inputs --------------------------------------- */
.budget-input {
  width: 120px; text-align: right; font-size: 0.8125rem;
  padding: 4px 6px; border: 1px solid #E2E8F0; border-radius: 6px;
  font-family: ui-monospace, monospace;
}
.budget-input:focus { outline: 2px solid #8C1F2E33; border-color: #8C1F2E; }

.grp-uncategorized .grp-bar { background: #FFFBEB; border-left-color: #F59E0B; }
.grp-uncategorized .grp-bar:hover { background: #FEF3C7; }
.grp-uncategorized .grp-progress-fill { background: #F59E0B; }
.grp-uncategorized .grp-progress-pct { color: #B45309; }
