/* ==========================================================================
   ROSTEREM — Sleek Owner ERP & Customer Portal Styles
   Desktop: Left vertical sidebar tabs | Mobile: Bottom app icon bar
   Card-first layout (ZERO cramped horizontal tables)
   ========================================================================== */

.portal-shell {
  display: none;
  min-height: 100vh;
  background: var(--tint);
  color: var(--ink);
}

.portal-shell.active {
  display: flex;
}

/* Desktop Left Sidebar */
.erp-sidebar {
  width: 252px;
  flex-shrink: 0;
  background: var(--ink);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 1.35rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow-y: auto;
}

.erp-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.25rem 0.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  margin-bottom: 1rem;
}

.erp-sidebar-brand img {
  width: 28px;
  height: 24px;
}

.erp-brand-title {
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1.1;
}

.erp-brand-sub {
  font-size: 0.68rem;
  color: var(--mint);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.erp-nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.erp-tab-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.72rem;
  padding: 0.7rem 0.85rem;
  border-radius: 11px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  transition: background 0.2s ease, color 0.2s ease;
}

.erp-tab-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.erp-tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.erp-tab-btn.active {
  background: var(--green);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(28, 124, 84, 0.35);
}

.erp-tab-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.48rem;
  border-radius: 999px;
}

.erp-sidebar-foot {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.erp-user-pill {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 0.35rem;
}

.erp-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.erp-user-meta {
  min-width: 0;
}

.erp-user-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.erp-user-email {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.erp-foot-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.58rem 0.8rem;
  border-radius: 9px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.erp-foot-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

/* Main ERP Content Area */
.erp-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.erp-topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.erp-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.erp-mobile-logo {
  display: none;
  width: 24px;
  height: 22px;
}

.erp-page-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.erp-page-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.erp-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.erp-content {
  padding: 1.6rem 1.75rem 3rem;
  max-width: 1180px;
  width: 100%;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kpi-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.kpi-delta {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--green);
}

/* Filter / Toolbar Bar */
.erp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}

.erp-search-input {
  flex: 1;
  min-width: 210px;
  max-width: 340px;
  padding: 0.58rem 0.9rem;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.84rem;
  color: var(--ink);
}

.erp-search-input:focus {
  outline: none;
  border-color: var(--green);
}

.erp-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-pill {
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--line);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
  transition: all 0.2s ease;
}

.filter-pill.active,
.filter-pill:hover {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

/* Card-First Grids (NO cramped horizontal tables) */
.erp-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.erp-cards-grid.three-col {
  grid-template-columns: repeat(3, 1fr);
}

.erp-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.erp-card:hover {
  border-color: rgba(28, 124, 84, 0.35);
  box-shadow: var(--shadow-md);
}

.erp-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.erp-card-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
}

.erp-card-sub {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.24rem 0.62rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-active, .status-paid, .status-completed, .status-resolved {
  background: var(--mint-soft);
  color: var(--green);
}

.status-trial, .status-scheduled, .status-inprogress {
  background: #eff6ff;
  color: #1d4ed8;
}

.status-open, .status-pending, .status-warning {
  background: #fef3c7;
  color: #b45309;
}

.erp-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem 0.8rem;
  padding: 0.75rem;
  border-radius: 11px;
  background: var(--tint);
}

.erp-meta-item {
  display: flex;
  flex-direction: column;
}

.erp-meta-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.erp-meta-val {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}

.erp-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.erp-mini-btn {
  padding: 0.42rem 0.78rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--tint);
  color: var(--ink);
  border: 1px solid var(--line);
  transition: all 0.2s ease;
}

.erp-mini-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.erp-mini-btn.primary {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
}

.erp-mini-btn.primary:hover {
  background: var(--green-hover);
  color: #ffffff;
}

/* Split Panel for Overview */
.erp-split {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.15rem;
}

.erp-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.erp-panel-title {
  font-size: 0.96rem;
  font-weight: 800;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.activity-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.activity-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.72rem 0.85rem;
  border-radius: 11px;
  background: var(--tint);
}

/* Ticket Reply Box */
.ticket-reply-box {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.ticket-reply-box input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  font-family: inherit;
  font-size: 0.8rem;
}

/* Progress Bar */
.meter-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-top: 4px;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--green);
}

/* Mobile ERP Bottom Icon Navigation (Same style as main website!) */
.erp-mobile-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 160;
  background: rgba(11, 24, 17, 0.97);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.45rem 0.25rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  align-items: center;
}

.erp-mobile-nav-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.25rem 0.1rem;
}

.erp-mobile-nav-btn svg {
  width: 20px;
  height: 20px;
}

.erp-mobile-nav-btn.active {
  color: var(--mint);
}

/* Responsive ERP */
@media (max-width: 1080px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .erp-split,
  .erp-cards-grid,
  .erp-cards-grid.three-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .erp-sidebar {
    display: none;
  }

  .erp-mobile-logo {
    display: block;
  }

  .erp-mobile-nav {
    display: flex;
  }

  .erp-topbar {
    padding: 0.85rem 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .erp-topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .erp-page-title {
    font-size: 1.05rem;
  }

  .erp-page-sub {
    font-size: 0.74rem;
  }

  .erp-content {
    padding: 1rem 1rem calc(5.8rem + env(safe-area-inset-bottom, 0px));
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem;
  }

  .kpi-card {
    padding: 0.9rem;
  }

  .kpi-value {
    font-size: 1.35rem;
  }
}
