/* ================================================================
   IN Invoice System — Premium Frontend Stylesheet v2.0
   PC: Sidebar navigation + data tables (software-style)
   Mobile: Bottom tab-bar + card UI (native app-style)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  --ip-primary:      #6366f1;
  --ip-primary-dk:   #4f46e5;
  --ip-primary-lt:   #e0e7ff;
  --ip-primary-glow: rgba(99,102,241,.15);
  --ip-green:        #22c55e;
  --ip-green-dk:     #16a34a;
  --ip-green-lt:     #dcfce7;
  --ip-red:          #ef4444;
  --ip-red-dk:       #dc2626;
  --ip-red-lt:       #fee2e2;
  --ip-orange:       #f97316;
  --ip-amber:        #f59e0b;
  --ip-amber-lt:     #fef9c3;
  --ip-muted:        #6b7280;
  --ip-muted-lt:     #9ca3af;
  --ip-border:       #e5e7eb;
  --ip-border-dk:    #d1d5db;
  --ip-bg:           #f8fafc;
  --ip-bg-alt:       #f1f5f9;
  --ip-surface:      #ffffff;
  --ip-text:         #111827;
  --ip-text-sm:      #374151;
  --ip-sidebar-bg:   #1e1b4b;
  --ip-sidebar-text: #c7d2fe;
  --ip-sidebar-act:  #6366f1;
  --ip-radius:       12px;
  --ip-radius-sm:    8px;
  --ip-radius-lg:    16px;
  --ip-shadow:       0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.06);
  --ip-shadow-md:    0 4px 12px rgba(0,0,0,.10), 0 8px 32px rgba(0,0,0,.08);
  --ip-shadow-lg:    0 8px 24px rgba(0,0,0,.14), 0 16px 48px rgba(0,0,0,.10);
  --ip-sidebar-w:    240px;
  --ip-bottom-bar-h: 64px;
  --ip-top-bar-h:    56px;
  --ip-trans:        all .18s cubic-bezier(.4,0,.2,1);
}

/* ── Global Reset inside wrapper ───────────────────────────────── */
.in-mgr-wrap *,
.in-portal-wrap * {
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ================================================================
   MANAGER LAYOUT — [in_invoice_manager]
   ================================================================ */

/* ── App Shell ─────────────────────────────────────────────────── */
.in-mgr-shell {
  display: flex;
  min-height: 100vh;
  background: var(--ip-bg);
  position: relative;
  overflow-x: hidden;

  /* ── Full-width breakout: escape the theme's content column ── */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.in-mgr-sidebar {
  width: var(--ip-sidebar-w);
  background: var(--ip-sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0,0,0,.18);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.in-mgr-sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.in-mgr-sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}

.in-mgr-sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.in-mgr-sidebar-logo-title {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
  letter-spacing: -.2px;
}

.in-mgr-sidebar-logo-sub {
  font-size: 11px;
  color: var(--ip-sidebar-text);
  font-weight: 400;
  opacity: .7;
}

.in-mgr-sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.in-mgr-sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(199,210,254,.4);
  padding: 16px 8px 8px;
  display: block;
}

.in-mgr-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--ip-radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ip-sidebar-text);
  text-decoration: none;
  transition: var(--ip-trans);
  margin-bottom: 2px;
  position: relative;
  white-space: nowrap;
}

.in-mgr-nav-link .nav-icon {
  font-size: 17px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.in-mgr-nav-link .nav-label {
  flex: 1;
}

.in-mgr-nav-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.in-mgr-nav-link.active {
  background: var(--ip-primary-glow);
  color: #a5b4fc;
  font-weight: 700;
}

.in-mgr-nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 70%;
  background: #a5b4fc;
  border-radius: 0 3px 3px 0;
}

.in-mgr-sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.in-mgr-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.in-mgr-sidebar-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg,#6366f1,#8b5cf6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.in-mgr-sidebar-uname {
  font-size: 12px;
  font-weight: 600;
  color: #c7d2fe;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.in-mgr-sidebar-urole {
  font-size: 11px;
  color: rgba(199,210,254,.5);
}

/* ── Main Content Area ─────────────────────────────────────────── */
.in-mgr-main {
  flex: 1;
  margin-left: var(--ip-sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar (PC) ──────────────────────────────────────────────── */
.in-mgr-topbar {
  height: var(--ip-top-bar-h);
  background: var(--ip-surface);
  border-bottom: 1px solid var(--ip-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.in-mgr-topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ip-text);
}

.in-mgr-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Content Body ──────────────────────────────────────────────── */
.in-mgr-body {
  flex: 1;
  padding: 28px;
  overflow-x: auto;
}

/* ── Mobile Top Bar ────────────────────────────────────────────── */
.in-mgr-mobile-topbar {
  display: none;
  height: var(--ip-top-bar-h);
  background: var(--ip-sidebar-bg);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.in-mgr-mobile-topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.in-mgr-mobile-topbar-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg,#6366f1,#8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.in-mgr-mobile-topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.in-mgr-mobile-topbar-section {
  font-size: 12px;
  color: #a5b4fc;
  font-weight: 500;
}

/* ── Bottom Tab Bar (Mobile) ───────────────────────────────────── */
.in-mgr-bottom-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--ip-bottom-bar-h);
  background: var(--ip-sidebar-bg);
  z-index: 100;
  border-top: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 -4px 20px rgba(0,0,0,.2);
}

.in-mgr-tabs-inner {
  display: flex;
  height: 100%;
  align-items: stretch;
}

.in-mgr-tab-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: rgba(199,210,254,.6);
  transition: var(--ip-trans);
  position: relative;
  padding: 8px 4px;
}

.in-mgr-tab-link:hover {
  color: #c7d2fe;
}

.in-mgr-tab-link.active {
  color: #a5b4fc;
}

.in-mgr-tab-link.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: #6366f1;
  border-radius: 0 0 4px 4px;
}

.in-mgr-tab-icon {
  font-size: 20px;
  line-height: 1;
}

.in-mgr-tab-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* ── Stat Cards ────────────────────────────────────────────────── */
.in-mgr-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.in-mgr-stat {
  background: var(--ip-surface);
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius);
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--ip-shadow);
  transition: var(--ip-trans);
  position: relative;
  overflow: hidden;
  animation: statFadeUp .4s ease both;
}

@keyframes statFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.in-mgr-stat:nth-child(1) { animation-delay: .05s; }
.in-mgr-stat:nth-child(2) { animation-delay: .10s; }
.in-mgr-stat:nth-child(3) { animation-delay: .15s; }
.in-mgr-stat:nth-child(4) { animation-delay: .20s; }

.in-mgr-stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--ip-shadow-md);
  border-color: var(--ip-primary);
}

.in-mgr-stat::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 50%;
  opacity: .06;
  background: var(--ip-primary);
  transform: translate(20px, -20px);
}

.in-mgr-stat-green::after  { background: var(--ip-green); }
.in-mgr-stat-yellow::after { background: var(--ip-amber); }
.in-mgr-stat-red::after    { background: var(--ip-red); }

.in-mgr-stat-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--ip-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ip-primary-lt);
  font-size: 22px;
}

.in-mgr-stat-green  .in-mgr-stat-icon { background: var(--ip-green-lt); }
.in-mgr-stat-yellow .in-mgr-stat-icon { background: var(--ip-amber-lt); }
.in-mgr-stat-red    .in-mgr-stat-icon { background: var(--ip-red-lt); }

.in-mgr-stat-val {
  font-size: clamp(15px, 2.5vw, 22px);
  font-weight: 800;
  line-height: 1.2;
  color: var(--ip-primary);
  letter-spacing: -.5px;
}

.in-mgr-stat-green  .in-mgr-stat-val { color: var(--ip-green-dk); }
.in-mgr-stat-yellow .in-mgr-stat-val { color: #d97706; }
.in-mgr-stat-red    .in-mgr-stat-val { color: var(--ip-red-dk); }

.in-mgr-stat-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--ip-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
}

/* ── Status Pills ──────────────────────────────────────────────── */
.in-mgr-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.in-mgr-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid var(--ip-border);
  background: var(--ip-surface);
  transition: var(--ip-trans);
}

.in-mgr-pill:hover { transform: scale(1.03); }
.in-mgr-pill strong { font-size: 16px; font-weight: 800; }
.in-mgr-pill-draft   { color: #6b7280; }
.in-mgr-pill-sent    { color: #92400e; background: var(--ip-amber-lt); border-color: #fde68a; }
.in-mgr-pill-paid    { color: #166534; background: var(--ip-green-lt); border-color: #86efac; }
.in-mgr-pill-overdue { color: #991b1b; background: var(--ip-red-lt);   border-color: #fca5a5; }

/* ── Card Container ────────────────────────────────────────────── */
.in-mgr-card {
  background: var(--ip-surface);
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius);
  box-shadow: var(--ip-shadow);
  overflow: hidden;
  margin-bottom: 24px;
  animation: cardIn .35s ease both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.in-mgr-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ip-border);
  font-weight: 700;
  font-size: 15px;
  background: var(--ip-bg);
}

.in-mgr-link {
  color: var(--ip-primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: var(--ip-trans);
}

.in-mgr-link:hover {
  text-decoration: underline;
  color: var(--ip-primary-dk);
}

/* ── Data Table ────────────────────────────────────────────────── */
.in-mgr-table-wrap {
  overflow-x: auto;
}

.in-mgr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 560px;
}

.in-mgr-table thead {
  background: var(--ip-bg);
  border-bottom: 2px solid var(--ip-border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.in-mgr-table th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ip-muted);
  text-align: left;
  white-space: nowrap;
}

.in-mgr-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  color: var(--ip-text-sm);
  transition: background .12s;
}

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

.in-mgr-table tbody tr {
  cursor: default;
  transition: background .12s;
}

.in-mgr-table tbody tr:hover td { background: #f5f7ff; }

.in-mgr-empty {
  text-align: center;
  color: var(--ip-muted-lt);
  padding: 36px;
  font-size: 14px;
}

.in-inv-no {
  font-weight: 700;
  color: var(--ip-primary);
  font-size: 13px;
}

.in-right  { text-align: right !important; }
.in-center { text-align: center !important; }
.in-muted  { color: var(--ip-muted-lt); font-size: 12px; }

/* ── Status Badges ─────────────────────────────────────────────── */
.in-mgr-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.in-mgr-badge-draft     { background: #f3f4f6; color: #6b7280; }
.in-mgr-badge-sent      { background: var(--ip-amber-lt); color: #92400e; }
.in-mgr-badge-paid      { background: var(--ip-green-lt); color: #166534; }
.in-mgr-badge-overdue   { background: var(--ip-red-lt);   color: #991b1b;
  animation: pulseBadge 2s infinite; }
.in-mgr-badge-cancelled { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
.in-mgr-badge-returned  { background: #fef9c3; color: #92400e; border: 1px solid #fde68a; }

@keyframes pulseBadge {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.3); }
  50%      { box-shadow: 0 0 0 4px rgba(239,68,68,.0); }
}

/* ── Buttons ───────────────────────────────────────────────────── */
.in-mgr-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--ip-radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: var(--ip-trans);
  white-space: nowrap;
  font-family: inherit;
}

.in-mgr-btn-primary {
  background: var(--ip-primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--ip-primary-glow);
}
.in-mgr-btn-primary:hover {
  background: var(--ip-primary-dk);
  color: #fff;
  box-shadow: 0 4px 16px var(--ip-primary-glow);
  transform: translateY(-1px);
}

.in-mgr-btn-outline {
  background: transparent;
  color: var(--ip-primary);
  border: 1.5px solid var(--ip-primary);
}
.in-mgr-btn-outline:hover {
  background: var(--ip-primary);
  color: #fff;
  transform: translateY(-1px);
}

.in-mgr-btn-ghost {
  background: transparent;
  color: var(--ip-muted);
  border: 1.5px solid var(--ip-border);
}
.in-mgr-btn-ghost:hover {
  background: var(--ip-bg-alt);
}

.in-mgr-btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

/* ── Filters Bar ───────────────────────────────────────────────── */
.in-mgr-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--ip-surface);
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius);
  box-shadow: var(--ip-shadow);
}

.in-mgr-input {
  padding: 9px 12px;
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius-sm);
  font-size: 13px;
  flex: 1;
  min-width: 180px;
  font-family: inherit;
  outline: none;
  transition: border .15s, box-shadow .15s;
  color: var(--ip-text);
  background: var(--ip-bg);
}

.in-mgr-input:focus {
  border-color: var(--ip-primary);
  box-shadow: 0 0 0 3px var(--ip-primary-glow);
  background: #fff;
}

.in-mgr-select {
  padding: 9px 12px;
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--ip-bg);
  outline: none;
  cursor: pointer;
  color: var(--ip-text);
  transition: border .15s, box-shadow .15s;
}

.in-mgr-select:focus {
  border-color: var(--ip-primary);
  box-shadow: 0 0 0 3px var(--ip-primary-glow);
}

/* ── Mobile Cards — Manager ────────────────────────────────────── */
.in-mgr-mobile-cards {
  display: none;
  flex-direction: column;
  gap: 14px;
}

/* ── Alert ─────────────────────────────────────────────────────── */
.in-mgr-alert {
  padding: 14px 18px;
  background: var(--ip-red-lt);
  color: #991b1b;
  border-radius: var(--ip-radius-sm);
  font-weight: 600;
  border: 1px solid #fca5a5;
}

/* ── Page header ───────────────────────────────────────────────── */
.in-mgr-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.in-mgr-title {
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--ip-text);
  letter-spacing: -.5px;
}

.in-mgr-sub {
  color: var(--ip-muted);
  font-size: 13.5px;
  margin: 0;
}

/* ── Wrap (old compat) ─────────────────────────────────────────── */
.in-mgr-wrap {
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--ip-text);
  max-width: 100%;
  box-sizing: border-box;
}

/* ── Progress Bar ──────────────────────────────────────────────── */
.in-progress-bar-wrap {
  background: var(--ip-bg-alt);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  min-width: 90px;
}

.in-progress-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--ip-green), var(--ip-green-dk));
  transition: width .6s ease;
}

/* ── Product Search Bar (Invoice Form) ─────────────────────────── */
.in-fe-product-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ip-border);
  background: var(--ip-bg);
}

.in-fe-search-icon {
  font-size: 16px;
  flex-shrink: 0;
  color: var(--ip-muted);
}

.in-fe-product-search-wrap .in-mgr-input {
  flex: 1;
  min-width: 0;
  background: var(--ip-surface);
}

/* Dropdown — portalled to <body> via JS, uses position:fixed */
.in-fe-product-dropdown {
  display: none;
  background: var(--ip-surface);
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius);
  box-shadow: var(--ip-shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 99999;
  /* position and coordinates set entirely by JS */
}

.in-fe-dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--ip-border);
  transition: background .12s;
  gap: 12px;
}

.in-fe-dd-item:last-child { border-bottom: none; }

.in-fe-dd-item:hover {
  background: var(--ip-primary-lt);
}

.in-fe-dd-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ip-text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.in-fe-dd-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--ip-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.in-fe-dd-empty {
  padding: 16px 20px;
  color: var(--ip-muted);
  font-size: 13px;
  text-align: center;
}

/* ================================================================
   PORTAL STYLES — [in_invoice_portal] / [in_customer_invoices]
   ================================================================ */

.in-portal-wrap {
  --ip-primary:    #6366f1;
  --ip-primary-dk: #4f46e5;
  --ip-primary-lt: #e0e7ff;
  --ip-green:      #22c55e;
  --ip-green-dk:   #16a34a;
  --ip-red:        #ef4444;
  --ip-orange:     #f97316;
  --ip-amber:      #f59e0b;
  --ip-muted:      #6b7280;
  --ip-border:     #e5e7eb;
  --ip-bg:         #f8fafc;
  --ip-card:       #ffffff;
  --ip-text:       #111827;
  --ip-radius:     12px;
  --ip-shadow:     0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.06);

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ip-text);
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

.in-portal-wrap *, .in-portal-wrap *::before, .in-portal-wrap *::after {
  box-sizing: border-box;
}

/* ── Portal Header ─────────────────────────────────────────────── */
.in-portal-header {
  padding: 32px 24px 28px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #4c1d95 100%);
  border-radius: var(--ip-radius);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.in-portal-header::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
}

.in-portal-header::after {
  content: '';
  position: absolute;
  bottom: -60px; left: 20px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,.03);
}

.in-portal-title {
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 900;
  color: #ffffff;
  margin: 0 0 6px;
  line-height: 1.2;
  position: relative;
  z-index: 1;
}

.in-portal-subtitle {
  color: #a5b4fc;
  font-size: 14px;
  margin: 0;
  position: relative;
  z-index: 1;
}

/* ── Stats Bar ─────────────────────────────────────────────────── */
.in-portal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 0 0 28px;
}

.in-portal-stat {
  background: var(--ip-card);
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--ip-shadow);
  transition: all .2s;
  animation: statFadeUp .4s ease both;
}

.in-portal-stat:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
}

.in-portal-stat-num {
  display: block;
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 800;
  color: var(--ip-primary);
  line-height: 1.2;
  margin-bottom: 6px;
}

.in-portal-stat-due  .in-portal-stat-num { color: var(--ip-red); }
.in-portal-stat-paid .in-portal-stat-num { color: var(--ip-green); }

.in-portal-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ip-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Desktop Table ─────────────────────────────────────────────── */
.in-portal-table-wrap {
  background: var(--ip-card);
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius);
  box-shadow: var(--ip-shadow);
  overflow: hidden;
  display: none;
}

.in-portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.in-portal-table thead tr {
  background: var(--ip-bg);
  border-bottom: 2px solid var(--ip-border);
}

.in-portal-table th {
  padding: 13px 18px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ip-muted);
  text-align: left;
}

.in-portal-table td {
  padding: 15px 18px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

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

.in-portal-tr {
  cursor: pointer;
  transition: background .12s;
}

.in-portal-tr:hover { background: #f5f7ff; }

.in-portal-inv-no { font-weight: 700; color: var(--ip-primary); }
.in-portal-amount { font-weight: 700; color: var(--ip-text); }

/* ── Mobile Cards ──────────────────────────────────────────────── */
.in-portal-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.in-portal-card {
  background: var(--ip-card);
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius);
  box-shadow: var(--ip-shadow);
  overflow: hidden;
  animation: cardIn .3s ease both;
  transition: transform .2s, box-shadow .2s;
}

.in-portal-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.09);
}

.in-portal-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ip-border);
  background: var(--ip-bg);
}

.in-portal-card-body { padding: 14px 18px; }

.in-portal-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.in-portal-card-row:last-child { border-bottom: none; }
.in-portal-card-lbl { color: var(--ip-muted); font-size: 13px; }
.in-portal-card-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--ip-border);
  background: var(--ip-bg);
}

/* ── Status Badges ─────────────────────────────────────────────── */
.in-portal-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.in-portal-badge-draft   { background: #f3f4f6; color: #6b7280; }
.in-portal-badge-sent    { background: var(--ip-amber-lt,#fef9c3); color: #854d0e; }
.in-portal-badge-paid    { background: #dcfce7; color: #166534; }
.in-portal-badge-overdue { background: var(--ip-red-lt,#fee2e2); color: #991b1b; }

/* ── Buttons ───────────────────────────────────────────────────── */
.in-portal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--ip-radius-sm,8px);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .18s;
  white-space: nowrap;
  font-family: inherit;
}

.in-portal-btn-primary {
  background: var(--ip-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}
.in-portal-btn-primary:hover {
  background: var(--ip-primary-dk);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99,102,241,.3);
}

.in-portal-btn-outline {
  background: transparent;
  color: var(--ip-primary);
  border: 1.5px solid var(--ip-primary);
}
.in-portal-btn-outline:hover {
  background: var(--ip-primary);
  color: #fff;
  transform: translateY(-1px);
}

.in-portal-btn-full { width: 100%; justify-content: center; }
.in-portal-btn-sm   { padding: 6px 14px; font-size: 12px; }

/* ── Back Bar ──────────────────────────────────────────────────── */
.in-portal-back-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.in-portal-back-link {
  color: var(--ip-primary);
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: gap .15s;
}
.in-portal-back-link:hover {
  text-decoration: underline;
  gap: 10px;
}

/* ── Empty / Alert ─────────────────────────────────────────────── */
.in-portal-empty-state {
  text-align: center;
  padding: 60px 24px;
  background: var(--ip-card);
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius);
  box-shadow: var(--ip-shadow);
}

.in-portal-empty-icon { font-size: 56px; margin-bottom: 18px; }

.in-portal-empty-state h2,
.in-portal-empty-state h3 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--ip-text);
}

.in-portal-empty-state p {
  color: var(--ip-muted);
  font-size: 15px;
  margin: 0 0 24px;
  line-height: 1.6;
}

.in-portal-alert {
  padding: 14px 18px;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  font-weight: 600;
  border: 1px solid #fca5a5;
}

/* ── Invoice Document ──────────────────────────────────────────── */
.in-portal-invoice {
  background: #fff;
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius);
  box-shadow: var(--ip-shadow);
  padding: clamp(20px, 5vw, 40px);
}

.in-inv-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--ip-border);
}

.in-inv-company-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--ip-primary);
  margin-bottom: 6px;
}

.in-inv-meta-line {
  font-size: 13px;
  color: var(--ip-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.in-inv-meta-box { text-align: right; }

.in-inv-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--ip-primary);
  letter-spacing: 3px;
  margin-bottom: 12px;
}

.in-inv-meta-row {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  font-size: 13px;
  margin-bottom: 4px;
}

.in-inv-meta-row span { color: var(--ip-muted); }
.in-inv-meta-row strong { font-weight: 700; }

.in-inv-bill-to {
  margin-bottom: 28px;
  padding: 18px 20px;
  background: var(--ip-bg);
  border-radius: 10px;
  border-left: 4px solid var(--ip-primary);
}

.in-inv-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ip-muted);
  margin-bottom: 8px;
}

.in-inv-customer-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* ── Invoice Items Table ───────────────────────────────────────── */
.in-inv-table-wrap {
  display: none;
  margin-bottom: 24px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--ip-border);
}

.in-inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.in-inv-table thead { background: var(--ip-primary); color: #fff; }

.in-inv-table th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  text-align: left;
}

.in-inv-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--ip-border);
  vertical-align: middle;
}

.in-inv-table tbody tr:last-child td { border-bottom: none; }
.in-inv-table tbody tr:nth-child(even) { background: #f9fafb; }
.in-inv-num          { color: var(--ip-muted); font-size: 12px; }
.in-inv-total-cell   { font-weight: 700; color: var(--ip-primary); }
.in-inv-empty        { text-align: center; color: var(--ip-muted); padding: 20px; }

/* ── Mobile Item Cards ─────────────────────────────────────────── */
.in-inv-item-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.in-inv-item-card {
  border: 1.5px solid var(--ip-border);
  border-radius: 10px;
  overflow: hidden;
}

.in-inv-item-card-title {
  padding: 12px 16px;
  font-weight: 700;
  background: var(--ip-bg);
  border-bottom: 1px solid var(--ip-border);
  font-size: 14px;
}

.in-inv-item-card-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 16px;
  font-size: 13px;
  border-bottom: 1px solid #f3f4f6;
}

.in-inv-item-card-row:last-child { border-bottom: none; }
.in-inv-item-card-row span:first-child { color: var(--ip-muted); }
.in-inv-item-card-total { background: #f0f4ff; }
.in-inv-item-card-total span:last-child { font-weight: 700; color: var(--ip-primary); }

/* ── Totals Block ──────────────────────────────────────────────── */
.in-inv-totals-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.in-inv-totals {
  width: 100%;
  max-width: 340px;
  border: 1.5px solid var(--ip-border);
  border-radius: 10px;
  overflow: hidden;
}

.in-inv-total-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 18px;
  font-size: 14px;
  border-bottom: 1px solid var(--ip-border);
}

.in-inv-total-row:last-child { border-bottom: none; }

.in-inv-grand-total {
  background: var(--ip-primary);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.in-disc-red { color: var(--ip-red); font-weight: 600; }

/* ── Notes / Footer ────────────────────────────────────────────── */
.in-inv-notes {
  border-top: 1.5px solid var(--ip-border);
  padding-top: 20px;
  margin-bottom: 20px;
  font-size: 13.5px;
  color: var(--ip-muted);
  line-height: 1.7;
}

.in-inv-footer {
  text-align: center;
  color: var(--ip-muted);
  font-size: 13px;
  padding-top: 16px;
  border-top: 1.5px solid var(--ip-border);
  font-style: italic;
}

/* ================================================================
   RESPONSIVE — Tablet (≥ 640px)
   ================================================================ */
@media (min-width: 640px) {
  /* Portal: show table, hide mobile cards */
  .in-portal-table-wrap { display: block; }
  .in-portal-cards      { display: none;  }

  /* Invoice items: show table, hide cards */
  .in-inv-table-wrap { display: block; }
  .in-inv-item-cards { display: none;  }

  .in-inv-totals { max-width: 300px; }
  .in-portal-wrap { padding: 24px; }
}

/* ================================================================
   RESPONSIVE — Desktop (≥ 768px)
   Manager: sidebar visible, bottom tabs hidden
   ================================================================ */
@media (min-width: 768px) {
  .in-mgr-shell          { flex-direction: row; }
  .in-mgr-sidebar        { display: flex; }
  .in-mgr-main           { margin-left: var(--ip-sidebar-w); }
  .in-mgr-topbar         { display: flex; }
  .in-mgr-body           { padding: 28px; }

  /* Hide mobile elements */
  .in-mgr-mobile-topbar  { display: none !important; }
  .in-mgr-bottom-tabs    { display: none !important; }
  .in-mgr-mobile-cards   { display: none !important; }

  /* Show desktop table */
  .in-mgr-table-wrap     { display: block !important; }

  /* Stats 4-col */
  .in-mgr-stats          { grid-template-columns: repeat(4, 1fr); }
}

/* ================================================================
   RESPONSIVE — Mobile (< 768px)
   Manager: no sidebar, mobile top bar + bottom tabs
   ================================================================ */
@media (max-width: 767px) {
  /* Hide desktop elements */
  .in-mgr-sidebar        { display: none !important; }
  .in-mgr-main           { margin-left: 0; }
  .in-mgr-topbar         { display: none; }
  .in-mgr-table-wrap     { display: none !important; }

  /* Show mobile elements */
  .in-mgr-mobile-topbar  { display: flex; }
  .in-mgr-bottom-tabs    { display: flex; }
  .in-mgr-mobile-cards   { display: flex; }

  /* Body padding — account for top bar + bottom tabs */
  .in-mgr-body {
    padding: 16px 14px;
    padding-bottom: calc(var(--ip-bottom-bar-h) + 16px);
  }

  /* Stats 2-col on mobile */
  .in-mgr-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Stat card compact */
  .in-mgr-stat { padding: 14px 12px; gap: 10px; }
  .in-mgr-stat-icon { width: 40px; height: 40px; font-size: 18px; }
  .in-mgr-stat-val { font-size: 16px; }

  /* Filters stacked */
  .in-mgr-filters { flex-direction: column; padding: 14px; }
  .in-mgr-input   { width: 100%; }

  /* Header compact */
  .in-mgr-header { margin-bottom: 16px; }
  .in-mgr-title  { font-size: 20px; }

  /* Pills scroll */
  .in-mgr-pills  { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .in-mgr-pills::-webkit-scrollbar { display: none; }
}

/* ================================================================
   PRINT STYLES
   ================================================================ */
@media print {
  .no-print { display: none !important; }

  .in-portal-wrap {
    max-width: 100%;
    padding: 0;
  }

  .in-portal-invoice {
    border: none;
    box-shadow: none;
    padding: 20px;
    border-radius: 0;
  }

  .in-portal-stats,
  .in-portal-header,
  .in-portal-back-bar { display: none !important; }

  .in-inv-table-wrap { display: block !important; }
  .in-inv-item-cards { display: none  !important; }

  .in-portal-table-wrap { display: block !important; }
  .in-portal-cards      { display: none  !important; }

  .in-mgr-sidebar,
  .in-mgr-bottom-tabs,
  .in-mgr-mobile-topbar,
  .in-mgr-topbar { display: none !important; }

  .in-mgr-main  { margin-left: 0; }
  .in-mgr-table-wrap { display: block !important; }

  body { font-size: 12px; }
  .in-inv-title { font-size: 22px; }
}

/* ================================================================
   FRONTEND NEW / EDIT INVOICE FORM
   ================================================================ */

/* ── Notices ── */
.in-fe-notice {
  padding: 13px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 18px;
  animation: cardIn .3s ease;
}
.in-fe-notice-success {
  background: var(--ip-green-lt);
  border: 1px solid #86efac;
  color: #166534;
}
.in-fe-notice-success a {
  color: var(--ip-green-dk);
  font-weight: 700;
  margin-left: 10px;
}

/* ── Two-column Form Grid ── */
.in-fe-form-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 18px;
  margin-bottom: 0;
  align-items: start;
}

.in-fe-details-card .in-mgr-card-head,
.in-fe-summary-card .in-mgr-card-head {
  font-size: 14px;
}

.in-fe-card-body {
  padding: 20px;
}

/* ── Fields ── */
.in-fe-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.in-fe-field:last-child { margin-bottom: 0; }

.in-fe-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ip-muted);
}
.in-fe-req { color: var(--ip-red); }

/* ── 2-col row within the card ── */
.in-fe-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Discount wrap ── */
.in-fe-disc-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Textarea ── */
.in-fe-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--ip-border);
  border-radius: var(--ip-radius-sm);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  color: var(--ip-text);
  background: var(--ip-bg);
  transition: border .15s, box-shadow .15s;
  outline: none;
}
.in-fe-textarea:focus {
  border-color: var(--ip-primary);
  box-shadow: 0 0 0 3px var(--ip-primary-glow);
  background: #fff;
}

/* ── Summary Totals ── */
.in-fe-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--ip-border);
  font-size: 14px;
  color: var(--ip-text-sm);
}
.in-fe-total-row:last-of-type { border-bottom: none; }

.in-fe-total-final {
  font-size: 20px;
  font-weight: 900;
  color: var(--ip-primary);
  border-top: 2px solid var(--ip-primary) !important;
  border-bottom: none !important;
  margin-top: 6px;
  padding-top: 12px !important;
}

/* ── Product Search ── */
.in-fe-product-search-wrap {
  position: relative;
  padding: 12px 20px 0;
}
.in-fe-search-icon {
  position: absolute;
  left: 32px;
  top: 50%;
  transform: translateY(-2px);
  pointer-events: none;
  font-size: 14px;
}
.in-fe-product-search-wrap .in-mgr-input {
  padding-left: 36px;
}
.in-fe-product-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 20px;
  right: 20px;
  background: #fff;
  border: 1.5px solid var(--ip-border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: 9999;
  max-height: 280px;
  overflow-y: auto;
  animation: cardIn .15s ease;
}
.in-fe-dd-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
  gap: 10px;
}
.in-fe-dd-item:last-child { border-bottom: none; }
.in-fe-dd-item:hover { background: var(--ip-primary-lt); }
.in-fe-dd-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ip-text);
}
.in-fe-dd-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--ip-primary);
  white-space: nowrap;
}
.in-fe-dd-empty {
  padding: 18px;
  color: var(--ip-muted);
  font-size: 13px;
  text-align: center;
}

/* ── Line Items Table ── */
.in-fe-table-wrap {
  overflow-x: auto;
  padding: 0 20px 20px;
}
.in-fe-items-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}
.in-fe-items-table thead th {
  padding: 10px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ip-muted);
  text-align: left;
  border-bottom: 2px solid var(--ip-border);
}
.in-fe-items-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.in-fe-items-table tbody tr:last-child td { border-bottom: none; }
.in-fe-items-table .in-mgr-input {
  width: 100%;
  min-width: 50px;
  padding: 7px 10px;
  font-size: 13px;
}

/* Discount toggle inside table */
.in-fe-disc-toggle {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1.5px solid var(--ip-border);
  flex-shrink: 0;
}
.in-fe-disc-btn {
  padding: 5px 7px;
  font-size: 11px;
  font-weight: 700;
  background: var(--ip-bg);
  color: var(--ip-muted);
  border: none;
  cursor: pointer;
  transition: background .12s;
  font-family: inherit;
}
.in-fe-disc-btn:first-child { border-right: 1.5px solid var(--ip-border); }
.in-fe-disc-btn.active { background: var(--ip-primary); color: #fff; }

/* Line total cell */
.in-fe-line-total {
  font-weight: 700;
  color: var(--ip-primary);
  white-space: nowrap;
}

/* Delete button — clearly visible red button */
.in-fe-del-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fee2e2;
  color: #dc2626;
  border: 1.5px solid #fca5a5;
  cursor: pointer;
  font-size: 15px;
  padding: 5px 9px;
  border-radius: 8px;
  transition: background .15s, border-color .15s, transform .1s;
  line-height: 1;
  opacity: 1;
}
.in-fe-del-row:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  transform: scale(1.08);
}

/* ── Responsive — Form Grid ── */
@media (max-width: 900px) {
  .in-fe-form-grid {
    grid-template-columns: 1fr;
  }
  .in-fe-summary-card { order: -1; }
}

/* ── Mobile Line Items: card layout ── */
@media (max-width: 768px) {
  /* product search full width on mobile */
  .in-fe-product-search-wrap { padding: 12px 14px 0; }
  .in-fe-product-dropdown { left: 14px; right: 14px; }
  .in-fe-search-icon { left: 26px; }

  .in-fe-table-wrap { padding: 0 14px 14px; }

  /* Hide table header, switch to card layout */
  .in-fe-items-table { min-width: unset; }
  .in-fe-items-table thead { display: none; }
  .in-fe-items-table tbody { display: block; }

  .in-fe-items-table tr.in-fe-item-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
    background: #fff;
    border: 1.5px solid var(--ip-border);
    border-radius: 12px;
    padding: 14px 14px 0;
    margin-bottom: 14px;
    box-shadow: 0 2px 10px rgba(99,102,241,.08);
    position: relative;
  }

  .in-fe-items-table td {
    display: block;
    padding: 0 0 12px;
    border: none;
    width: 100%;
  }

  .in-fe-items-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .9px;
    color: var(--ip-muted);
    margin-bottom: 4px;
  }

  /* Description: full width */
  .in-fe-items-table td[data-label="Description"] {
    grid-column: 1 / -1;
    padding-right: 44px;
  }

  /* Qty + Unit Price side by side */
  .in-fe-items-table td[data-label="Qty"]        { grid-column: 1; }
  .in-fe-items-table td[data-label="Unit Price"]  { grid-column: 2; }

  /* Discount + Tax side by side */
  .in-fe-items-table td[data-label="Discount"]    { grid-column: 1; }
  .in-fe-items-table td:nth-child(5)              { grid-column: 2; }

  /* Line Total: full-width footer bar */
  .in-fe-items-table td.in-fe-line-total {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border-top: 1.5px solid var(--ip-primary-lt);
    border-radius: 0 0 10px 10px;
    margin: 0 -14px;
    padding: 10px 16px !important;
    font-size: 15px;
  }
  .in-fe-items-table td.in-fe-line-total::before {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .9px;
    color: var(--ip-muted);
    margin-bottom: 0;
  }

  /* Delete button: absolute top-right */
  .in-fe-items-table td:last-child {
    display: block;
    position: absolute;
    top: 12px; right: 12px;
    width: auto;
    padding: 0;
    border: none;
    grid-column: unset;
  }

  /* Row fields */
  .in-fe-row { grid-template-columns: 1fr; }
  .in-fe-disc-wrap { flex-wrap: nowrap; }
}

@media (max-width: 480px) {
  .in-fe-card-body { padding: 14px 12px; }
  .in-fe-items-table tr.in-fe-item-row { padding: 12px 12px 0; }
  .in-fe-items-table td.in-fe-line-total { margin: 0 -12px; padding: 10px 12px !important; }
}

/* ================================================================
   Product Search Bar — Line Items Card
   ================================================================ */
.in-fe-product-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ip-border);
  background: var(--ip-bg-alt);
  border-radius: 0;
}

.in-fe-search-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  color: var(--ip-muted);
  pointer-events: none;
}

.in-fe-product-search-wrap .in-mgr-input {
  flex: 1;
  border-radius: 8px;
  font-size: 13.5px;
  padding: 9px 14px;
  border: 1.5px solid var(--ip-border);
  background: #fff;
  transition: border-color .18s, box-shadow .18s;
}

.in-fe-product-search-wrap .in-mgr-input:focus {
  border-color: var(--ip-primary);
  box-shadow: 0 0 0 3px var(--ip-primary-glow);
  outline: none;
}

/* ── Dropdown container ─────────────────────────────────── */
.in-fe-product-dropdown {
  display: none;
  background: #fff;
  border: 1.5px solid var(--ip-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(99,102,241,.08);
  z-index: 999999;
  max-height: 340px;
  overflow-y: auto;
  animation: in-fe-dd-in .15s cubic-bezier(.4,0,.2,1);
}

@keyframes in-fe-dd-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Dropdown items ─────────────────────────────────────── */
.in-fe-dd-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--ip-border);
  transition: background .12s, color .12s;
  outline: none;
}

.in-fe-dd-item:last-child { border-bottom: none; }

.in-fe-dd-item:hover,
.in-fe-dd-item:focus {
  background: var(--ip-primary-lt);
}

.in-fe-dd-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ip-text);
  display: flex;
  align-items: center;
  gap: 7px;
  transition: color .12s;
}

.in-fe-dd-item:hover .in-fe-dd-name,
.in-fe-dd-item:focus .in-fe-dd-name {
  color: var(--ip-primary);
}

.in-fe-dd-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--ip-primary);
  white-space: nowrap;
}

.in-fe-dd-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--ip-muted);
  font-size: 13px;
}

.in-fe-dd-empty a {
  color: var(--ip-primary);
  font-weight: 700;
  text-decoration: none;
}

.in-fe-dd-empty a:hover { text-decoration: underline; }

/* ── Mobile: full-width search wrap ────────────────────── */
@media (max-width: 640px) {
  .in-fe-product-search-wrap { padding: 12px 14px; }
  .in-fe-dd-item { padding: 10px 14px; }
}

/* ================================================================
   STATUS BADGES  — used by status_badge() in portal & manager views
   Classes: in-portal-badge  in-portal-badge-{status}
   ================================================================ */
.in-portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  line-height: 1.4;
  white-space: nowrap;
  transition: opacity .15s ease;
}

/* Draft — grey */
.in-portal-badge-draft {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* Sent / Pending — blue */
.in-portal-badge-sent {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* Paid — green ✓ */
.in-portal-badge-paid {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.in-portal-badge-paid::before {
  content: '✓';
  font-weight: 900;
}

/* Overdue — red */
.in-portal-badge-overdue {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.in-portal-badge-overdue::before {
  content: '!';
  font-weight: 900;
}

/* Cancelled — slate */
.in-portal-badge-cancelled {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
  text-decoration: line-through;
  opacity: .85;
}

/* Returned — amber/orange */
.in-portal-badge-returned {
  background: #fef9c3;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* ── Print: flatten badges ────────────────────────────── */
@media print {
  .in-portal-badge {
    background: transparent !important;
    border: 1px solid currentColor !important;
    padding: 2px 8px !important;
  }
}

