/* ============================================================
   Zed Market Panel — Premium Design System v2
   Clean SaaS UI — Inter font, refined palette, polished UX
   ============================================================ */

/* ─── CSS Variables ───────────────────────────────────────── */
:root {
  /* Brand */
  --brand-primary:    #4f46e5;
  --brand-secondary:  #6366f1;
  --brand-light:      #eef2ff;
  --brand-dark:       #3730a3;

  /* Sidebar */
  --sidebar-bg:       #111827;
  --sidebar-border:   rgba(255,255,255,0.06);
  --sidebar-text:     rgba(255,255,255,0.65);
  --sidebar-active:   #ffffff;
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-active-bg: rgba(99,102,241,0.18);

  /* Layout */
  --toolbar-height:   60px;
  --sidebar-width:    252px;

  /* Surfaces */
  --body-bg:          #f8fafc;
  --card-bg:          #ffffff;
  --card-border:      #e2e8f0;

  /* Typography */
  --text-primary:     #0f172a;
  --text-secondary:   #64748b;
  --text-muted:       #94a3b8;

  /* Borders */
  --border-color:     #e2e8f0;
  --border-light:     #f1f5f9;

  /* Semantic colors */
  --success:          #16a34a;
  --success-light:    #f0fdf4;
  --success-border:   #bbf7d0;
  --warning:          #d97706;
  --warning-light:    #fffbeb;
  --warning-border:   #fde68a;
  --danger:           #dc2626;
  --danger-light:     #fef2f2;
  --danger-border:    #fecaca;
  --info:             #0284c7;
  --info-light:       #f0f9ff;
  --info-border:      #bae6fd;

  /* Radii */
  --radius-xs:        4px;
  --radius-sm:        6px;
  --radius-md:        10px;
  --radius-lg:        14px;
  --radius-xl:        18px;

  /* Shadows */
  --shadow-xs:        0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:        0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:        0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:        0 10px 15px rgba(0,0,0,0.07), 0 4px 6px rgba(0,0,0,0.04);

  --transition:       0.15s ease;
  --transition-md:    0.2s ease;
}

/* ─── Reset / Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--body-bg);
  line-height: 1.6;
}

a { color: var(--brand-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-dark); }

h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.3; color: var(--text-primary); }

img { max-width: 100%; }

/* ─── Layout ──────────────────────────────────────────────── */
.zp-app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.zp-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-md);
  overflow: hidden;
  border-right: 1px solid var(--sidebar-border);
}

/* Logo */
.zp-sidebar__logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
  flex-shrink: 0;
}

.zp-sidebar__logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79,70,229,0.35);
}

.zp-sidebar__logo-text { line-height: 1.25; }

.zp-sidebar__logo-name {
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.zp-sidebar__logo-badge {
  font-size: 10px;
  font-weight: 600;
  color: rgba(99,102,241,0.85);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* Scrollable nav body */
.zp-sidebar__body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.zp-sidebar__body::-webkit-scrollbar { width: 3px; }
.zp-sidebar__body::-webkit-scrollbar-track { background: transparent; }
.zp-sidebar__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* Nav sections */
.zp-nav__section { padding: 10px 0 2px; }

.zp-nav__section-title {
  padding: 0 16px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
}

.zp-nav__item { list-style: none; }

.zp-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 16px;
  margin: 1px 8px;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
}

.zp-nav__link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

.zp-nav__link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
}

.zp-nav__link.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--brand-secondary);
  border-radius: 0 3px 3px 0;
}

.zp-nav__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.zp-nav__link:hover .zp-nav__icon,
.zp-nav__link.active .zp-nav__icon { opacity: 1; }

.zp-nav__badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(99,102,241,0.25);
  color: #a5b4fc;
  line-height: 1.4;
}

.zp-nav__badge--danger {
  background: rgba(220,38,38,0.2);
  color: #fca5a5;
}

/* Submenu */
.zp-nav__submenu {
  padding-left: 20px;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}

.zp-nav__submenu.open { max-height: 500px; }

.zp-nav__submenu .zp-nav__link {
  font-size: 13px;
  padding: 6px 14px 6px 16px;
}

.zp-nav__arrow {
  margin-left: auto;
  transition: transform var(--transition-md);
  opacity: 0.5;
  flex-shrink: 0;
}

.zp-nav__item--open .zp-nav__arrow { transform: rotate(-90deg); }

/* Sidebar footer */
.zp-sidebar__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

/* ─── Main Content ────────────────────────────────────────── */
.zp-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  /* Contain wide children (tables, pre, etc.) so they don't push
     the toolbar / user button off-screen on small viewports.
     NOTE: do NOT set overflow-x here — it creates an implicit
     overflow-y: auto scroll container that breaks sticky toolbar
     + absolute-positioned dropdown alignment. Per-container
     scroll (e.g. .zp-card__body--flush) handles table overflow. */
  max-width: 100%;
}

/* ─── Toolbar ─────────────────────────────────────────────── */
.zp-toolbar {
  height: var(--toolbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 80;              /* above page content, below modals */
  box-shadow: var(--shadow-xs);
  overflow: visible;        /* never clip the autocomplete dropdown */
}

.zp-toolbar__toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: none;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}

.zp-toolbar__toggle:hover { background: var(--body-bg); color: var(--text-primary); }

.zp-toolbar__spacer { flex: 1; }

/* ─── Toolbar search ──────────────────────────────────────── */
/* The <form> is just the flex item that reserves horizontal space
   in the toolbar. It should NOT be the positioning context for
   the dropdown (forms are unreliable containing blocks inside a
   flex layout — causes the desktop drift bug). */
.zp-toolbar__search {
  flex: 0 1 340px;
  min-width: 0;
  max-width: 340px;
  overflow: visible;
  margin: 0;                /* kill UA <form> default margins */
  padding: 0;
}

/* The wrapper is the one and only positioning context for the
   input + icon + dropdown. Plain div, predictable across browsers. */
.zp-search-wrapper {
  position: relative;
  display: block;
  width: 100%;
  overflow: visible;
}

.zp-toolbar__search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.zp-toolbar__search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--body-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.zp-toolbar__search-input::placeholder { color: var(--text-muted); }

.zp-toolbar__search-input:focus {
  background: var(--card-bg);
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

/* Hide native search "X" where inconsistent */
.zp-toolbar__search-input::-webkit-search-cancel-button { cursor: pointer; }

/* ─── Live search dropdown ────────────────────────────────── */
/* Anchored to .zp-search-wrapper (the div), not the <form>.
   top: calc(100% + 6px) → directly under the input with a small gap.
   left: 0 / width: 100% → exact input width.
   This is the standard SaaS autocomplete positioning and works
   identically on desktop and mobile. */
.zp-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  animation: zpSearchIn 0.12s ease-out;
}

@keyframes zpSearchIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.zp-search-dropdown[hidden] { display: none !important; }

.zp-search-dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: background var(--transition);
  cursor: pointer;
}

.zp-search-dropdown__item:hover,
.zp-search-dropdown__item.is-active {
  background: var(--body-bg);
  color: var(--text-primary);
}

.zp-search-dropdown__img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--body-bg);
  flex-shrink: 0;
}

.zp-search-dropdown__img--ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.zp-search-dropdown__text { min-width: 0; flex: 1; }

.zp-search-dropdown__name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zp-search-dropdown__name mark {
  background: rgba(79,70,229,0.14);
  color: var(--brand-primary);
  padding: 0 1px;
  border-radius: 3px;
}

.zp-search-dropdown__cat {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.zp-search-dropdown__empty {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.zp-toolbar__balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--body-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.zp-toolbar__balance svg { color: var(--success); }

.zp-toolbar__btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  position: relative;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}

.zp-toolbar__btn:hover { background: var(--body-bg); color: var(--text-primary); }

.zp-toolbar__indicator {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--card-bg);
}

/* User dropdown trigger */
.zp-user-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 40px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.zp-user-btn:hover { background: var(--body-bg); border-color: #cbd5e1; }

.zp-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.zp-user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.zp-user-info { line-height: 1.2; }

.zp-user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }

.zp-user-role { font-size: 11px; color: var(--text-secondary); text-transform: capitalize; }

/* Bootstrap dropdown overrides */
.dropdown-menu {
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: 6px;
  font-size: 13.5px;
  min-width: 175px;
}

.dropdown-item {
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  display: flex;
  align-items: center;
  color: var(--text-primary);
  font-weight: 500;
  transition: background var(--transition);
}

.dropdown-item:hover { background: var(--body-bg); color: var(--text-primary); }
.dropdown-item.text-danger { color: var(--danger) !important; }
.dropdown-item.text-danger:hover { background: var(--danger-light); }
.dropdown-divider { border-color: var(--border-color); margin: 4px 0; }

/* ─── Page Body ───────────────────────────────────────────── */
.zp-body {
  flex: 1;
  padding: 28px 28px 60px;
  min-width: 0;
  max-width: 100%;
}

.zp-page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.zp-page-header__left { flex: 1; min-width: 0; }

.zp-page-title {
  font-size: 21px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}

.zp-page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 3px 0 0;
  font-weight: 400;
}

/* ─── Cards ───────────────────────────────────────────────── */
.zp-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.zp-card__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card-bg);
}

.zp-card__title {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
}

.zp-card__body { padding: 20px; }
.zp-card__body--flush { padding: 0; }

/* When a card body holds a wide table, allow it to scroll
   horizontally rather than blow out the page layout. */
.zp-card__body--flush { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─── Stat Widgets ────────────────────────────────────────── */
.zp-stat {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.zp-stat:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.zp-stat__body { flex: 1; min-width: 0; }

.zp-stat__label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zp-stat__value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.zp-stat__sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
  font-weight: 400;
}

.zp-stat__icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.zp-stat__icon--primary { background: linear-gradient(135deg, #4f46e5, #6366f1); box-shadow: 0 4px 10px rgba(79,70,229,0.3); }
.zp-stat__icon--success { background: linear-gradient(135deg, #16a34a, #22c55e); box-shadow: 0 4px 10px rgba(22,163,74,0.3); }
.zp-stat__icon--warning { background: linear-gradient(135deg, #d97706, #f59e0b); box-shadow: 0 4px 10px rgba(217,119,6,0.3); }
.zp-stat__icon--danger  { background: linear-gradient(135deg, #dc2626, #f87171); box-shadow: 0 4px 10px rgba(220,38,38,0.3); }
.zp-stat__icon--info    { background: linear-gradient(135deg, #0284c7, #38bdf8); box-shadow: 0 4px 10px rgba(2,132,199,0.3); }

/* ─── Tables ──────────────────────────────────────────────── */
.zp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.zp-table td > div {
    align-items: center;
}

.zp-table img {
    flex-shrink: 0;
}

.zp-table thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  background: var(--body-bg);
  white-space: nowrap;
}

.zp-table thead th:first-child { border-radius: 0; }

.zp-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text-primary);
}

.zp-table tbody tr:last-child td { border-bottom: none; }

.zp-table tbody tr {
  transition: background var(--transition);
}

.zp-table tbody tr:hover td { background: #f8fafc; }

/* ─── Badges ──────────────────────────────────────────────── */
.zp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.4;
  white-space: nowrap;
}

.zp-badge--success  { background: var(--success-light); color: #15803d; border: 1px solid var(--success-border); }
.zp-badge--warning  { background: var(--warning-light); color: #92400e; border: 1px solid var(--warning-border); }
.zp-badge--danger   { background: var(--danger-light);  color: #b91c1c; border: 1px solid var(--danger-border); }
.zp-badge--info     { background: var(--info-light);    color: #075985; border: 1px solid var(--info-border); }
.zp-badge--secondary{ background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.zp-badge--primary  { background: var(--brand-light);   color: var(--brand-dark); border: 1px solid #c7d2fe; }

/* ─── Buttons ─────────────────────────────────────────────── */
.zp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
  font-family: inherit;
}

.zp-btn:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }

.zp-btn--primary {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 1px 2px rgba(79,70,229,0.2);
}
.zp-btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; box-shadow: 0 2px 6px rgba(79,70,229,0.3); }

.zp-btn--success { background: var(--success); color: #fff; border-color: var(--success); }
.zp-btn--success:hover { background: #15803d; color: #fff; box-shadow: 0 2px 6px rgba(22,163,74,0.3); }

.zp-btn--warning { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.zp-btn--warning:hover { background: var(--warning); color: #fff; }

.zp-btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.zp-btn--danger:hover { background: #b91c1c; color: #fff; box-shadow: 0 2px 6px rgba(220,38,38,0.3); }

.zp-btn--outline {
  background: var(--card-bg);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.zp-btn--outline:hover { background: var(--body-bg); border-color: #cbd5e1; color: var(--text-primary); }

.zp-btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.zp-btn--ghost:hover { background: var(--body-bg); color: var(--text-primary); }

.zp-btn--sm { padding: 5px 11px; font-size: 12.5px; border-radius: var(--radius-xs); }
.zp-btn--lg { padding: 11px 22px; font-size: 15px; border-radius: var(--radius-md); }
.zp-btn--full { width: 100%; justify-content: center; }

/* ─── Forms ───────────────────────────────────────────────── */
.zp-form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.zp-form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  line-height: 1.5;
  font-family: inherit;
}

.zp-form-control:hover { border-color: #cbd5e1; }

.zp-form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

.zp-form-control::placeholder { color: var(--text-muted); }
.zp-form-control.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }

.zp-form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
  cursor: pointer;
}

.zp-form-hint  { font-size: 12px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.zp-form-error { font-size: 12px; color: var(--danger); margin-top: 4px; font-weight: 500; }

.zp-form-group { margin-bottom: 18px; }

/* Checkbox / toggle */
.zp-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
}

.zp-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

/* ─── Alerts ──────────────────────────────────────────────── */
.zp-alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  font-weight: 500;
  border: 1px solid transparent;
}

.zp-alert--success { background: var(--success-light); border-color: var(--success-border); color: #15803d; }
.zp-alert--danger  { background: var(--danger-light);  border-color: var(--danger-border);  color: #b91c1c; }
.zp-alert--warning { background: var(--warning-light); border-color: var(--warning-border); color: #92400e; }
.zp-alert--info    { background: var(--info-light);    border-color: var(--info-border);    color: #075985; }

/* ─── Product Grid ────────────────────────────────────────── */
.zp-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.zp-product-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition-md), transform var(--transition-md), border-color var(--transition-md);
  cursor: pointer;
}

.zp-product-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

.zp-product-card__img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--body-bg);
}

.zp-product-card__body { padding: 12px 14px; }

.zp-product-card__name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.zp-product-card__price {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-primary);
}

.zp-product-card__price-label { font-size: 11px; color: var(--text-muted); }

/* ─── Category Grid ───────────────────────────────────────── */
.zp-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.zp-cat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-align: center;
  padding: 22px 14px 18px;
  transition: box-shadow var(--transition-md), transform var(--transition-md), border-color var(--transition-md);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.zp-cat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

/* Scoped to category cards only — does not touch .zp-thumb* or
   product/admin thumbnails. */
.zp-cat-card__img,
.zp-cat-card__placeholder {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  margin: 0 auto 12px;
  display: block;
  flex-shrink: 0;
  transition: transform var(--transition-md);
  will-change: transform;
}

.zp-cat-card__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(79,70,229,0.25);
}

/* Subtle image-only zoom on hover — paired with the card's own lift. */
@media (hover: hover) and (pointer: fine) {
  .zp-cat-card:hover .zp-cat-card__img,
  .zp-cat-card:hover .zp-cat-card__placeholder {
    transform: scale(1.05);
  }
}

.zp-cat-card__name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: -0.005em;
}

/* ─── Footer ──────────────────────────────────────────────── */
.zp-footer {
  text-align: center;
  padding: 16px 24px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
}

/* ─── Announcement Banner ─────────────────────────────────── */
.zp-announcement {
  background: linear-gradient(135deg, var(--brand-primary), #818cf8);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

/* ─── Code reveal ─────────────────────────────────────────── */
.zp-code-box {
  background: #0f172a;
  color: #e2e8f0;
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  padding: 18px 24px;
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid rgba(255,255,255,0.08);
  position: relative;
}

.zp-code-box__copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
}

.zp-code-box__copy:hover { background: rgba(255,255,255,0.2); }

/* ─── Sensitive data reveal ───────────────────────────────── */
.zp-sensitive-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--body-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.zp-sensitive-value {
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  flex: 1;
  font-size: 13px;
  letter-spacing: 0.5px;
}

/* ─── Pagination ──────────────────────────────────────────── */
.zp-pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 20px 0 8px;
  flex-wrap: wrap;
}

.zp-pagination a,
.zp-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: all var(--transition);
  background: var(--card-bg);
}

.zp-pagination a:hover { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.zp-pagination .active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.zp-pagination .disabled { color: var(--text-muted); cursor: default; background: var(--body-bg); }

/* ─── Sidebar Mobile Overlay ──────────────────────────────── */
.zp-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ─── Auth Page ───────────────────────────────────────────── */
.zp-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  padding: 20px;
}

.zp-auth-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.35);
}

.zp-auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.zp-auth-logo__icon {
  display: inline-flex;
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
  box-shadow: 0 8px 20px rgba(79,70,229,0.35);
}

.zp-auth-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.zp-auth-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 28px;
}

/* ─── Divider ─────────────────────────────────────────────── */
.zp-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

/* ─── Info row (key-value pairs in detail views) ──────────── */
.zp-info-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
  align-items: baseline;
}

.zp-info-row:last-child { border-bottom: none; }

.zp-info-row__label {
  flex: 0 0 160px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.zp-info-row__value {
  flex: 1;
  font-size: 13.5px;
  color: var(--text-primary);
  min-width: 0;
  word-break: break-word;
}

/* ─── Empty state ─────────────────────────────────────────── */
.zp-empty {
  text-align: center;
  padding: 52px 24px;
  color: var(--text-secondary);
}

.zp-empty__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  opacity: 0.3;
}

.zp-empty__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.zp-empty__sub {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ─── Filter bar ──────────────────────────────────────────── */
.zp-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--card-bg);
}

/* ─── Search input with icon ──────────────────────────────── */
.zp-search {
  position: relative;
}

.zp-search__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.zp-search .zp-form-control { padding-left: 34px; }

/* ─── Tabs ────────────────────────────────────────────────── */
.zp-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.zp-tab {
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  text-decoration: none;
  display: inline-block;
}

.zp-tab:hover { color: var(--text-primary); }
.zp-tab.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }

/* ─── Responsive ──────────────────────────────────────────── */

/* Global safety net — prevents fixed / wide children from forcing
   a horizontal page scroll and hiding the right-hand toolbar buttons. */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Any <table class="zp-table"> without an explicit scroll wrapper
   will still behave correctly because its surrounding card body
   (.zp-card__body--flush / .zp-card__body) now scrolls horizontally. */
.zp-card__body { max-width: 100%; }
.zp-card__body:has(> table),
.zp-card__body:has(> .zp-table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Keep tables from squishing into unreadable columns — let them
   keep their natural width and scroll inside the card. */
.zp-table { min-width: 640px; }

/* Images / media never force overflow. */
img, svg, video, canvas { max-width: 100%; height: auto; }

@media (max-width: 1024px) {
  .zp-sidebar {
    transform: translateX(-100%);
  }
  .zp-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .zp-sidebar-backdrop.open { display: block; }
  .zp-main { margin-left: 0; }
  .zp-toolbar__toggle { display: flex; }
  .zp-body { padding: 20px 16px 50px; }
  .zp-toolbar { padding: 0 16px; }
}

@media (max-width: 640px) {
  .zp-user-info { display: none; }
  .zp-product-grid { grid-template-columns: repeat(2, 1fr); }
  .zp-cat-grid { grid-template-columns: repeat(2, 1fr); }
  .zp-cat-card { padding: 18px 10px 14px; }
  .zp-cat-card__img,
  .zp-cat-card__placeholder {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
  }
  .zp-cat-card__placeholder { font-size: 24px; }
  .zp-page-title { font-size: 18px; }

  /* Tight toolbar so the user menu and balance stay reachable. */
  .zp-toolbar { padding: 0 12px; gap: 8px; }
  .zp-toolbar__balance { padding: 4px 10px; font-size: 12px; }
  .zp-user-btn { padding: 3px 8px 3px 3px; }
  .zp-toolbar__search { flex: 1 1 auto; max-width: none; }
  .zp-toolbar__search-input { height: 34px; font-size: 13px; }
  /* Keep the dropdown anchored to the input but never wider than
     the viewport, so it can't spill off-screen on tiny phones. */
  .zp-search-dropdown {
    max-height: min(60vh, 380px);
    max-width: calc(100vw - 24px);
  }

  /* Body padding fits narrow phones. */
  .zp-body { padding: 16px 12px 48px; }

  /* Card headers and filter bars wrap instead of clipping CTAs. */
  .zp-card__header,
  .zp-filter-bar {
    flex-wrap: wrap;
    align-items: stretch;
  }
  .zp-card__header > *,
  .zp-filter-bar > * { min-width: 0; }

  /* Info rows stack label above value on phones. */
  .zp-info-row { flex-direction: column; gap: 2px; padding: 8px 0; }
  .zp-info-row__label { flex: 0 0 auto; }

  /* Auth card: no more 40px padding on tiny screens. */
  .zp-auth-card { padding: 28px 22px; border-radius: var(--radius-lg); }

  /* Tables stay scrollable but shrink their floor a bit. */
  .zp-table { min-width: 560px; }
  .zp-table thead th,
  .zp-table tbody td { padding: 10px 12px; }

  /* Buttons: allow full-width actions to breathe in stacked headers. */
  .zp-btn { white-space: nowrap; }
}

@media (max-width: 420px) {
  /* Very small phones: drop balance label to icon-only size,
     keep user avatar + chevron visible. */
  .zp-toolbar__balance { font-size: 11.5px; padding: 3px 8px; }
  .zp-page-title { font-size: 17px; }
  .zp-card__body { padding: 14px; }
}

/* ─── Thumbnails (zp-thumb) ───────────────────────────────── */
/* Reusable square thumbnail — used anywhere a product / category
   image appears in a table or compact card. Pairs with uploads
   normalized to 300×300 by App\Services\ImageService. */
.zp-thumb {
    width: 60px;
    height: 60px;

    min-width: 60px;
    min-height: 60px;

    border-radius: 8px;
    object-fit: cover;

    display: block;

    transition: transform 0.25s ease, box-shadow 0.25s ease;
    cursor: pointer;
}

.zp-thumb--sm { width: 36px;  height: 36px;  border-radius: 6px; }
.zp-thumb--md { width: 60px;  height: 60px;  min-width: 60px;  min-height: 60px; }
.zp-thumb--lg { width: 60px;  height: 60px;  border-radius: 10px; }
.zp-thumb--xl { width: 80px;  height: 80px;  border-radius: 12px; }

/* Placeholder (first-letter badge) — same geometry, different fill.
   Used when a product has no image. */
.zp-thumb--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  font-weight: 700;
  border-color: transparent;
}

/* Desktop hover — scale up in place and lift onto a higher paint
   layer so the zoomed image overlaps neighbours instead of pushing them. */
@media (hover: hover) and (pointer: fine) {
  .zp-thumb:hover {
    transform: scale(2);
    box-shadow: var(--shadow-lg);
    z-index: 5;
    /* Re-sync z-index transition so the lift is instant, not delayed. */
    transition: transform 0.18s ease, box-shadow 0.18s ease, z-index 0s;
  }
}

/* Keep table rows from clipping the zoomed thumb. `overflow: visible`
   is already the default for <td> but is explicit here so any cell
   level override can't amputate the hover preview. */
.zp-table td:has(.zp-thumb) { overflow: visible; }

/* ─── Modal (zp-modal) ────────────────────────────────────── */
/* Lightweight, framework-free modal. Open by toggling .is-open on
   the .zp-modal root. Pairs with body.zp-modal-open to lock scroll. */
.zp-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1050;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
  animation: zpFadeIn 0.15s ease-out;
}

.zp-modal.is-open { display: flex; }

.zp-modal__dialog {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px rgba(0,0,0,0.35);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: zpModalIn 0.18s ease-out;
}

.zp-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-light);
}

.zp-modal__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.zp-modal__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  line-height: 0;
  flex-shrink: 0;
}
.zp-modal__close:hover { background: var(--body-bg); color: var(--text-primary); }
.zp-modal__close:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }

.zp-modal__body {
  padding: 16px 22px 22px;
  overflow-y: auto;
  font-size: 13.5px;
  color: var(--text-primary);
  line-height: 1.55;
  white-space: pre-wrap;   /* preserve line breaks from admin descriptions */
  word-break: break-word;
}

body.zp-modal-open { overflow: hidden; }

@keyframes zpFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes zpModalIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Clickable product name (opens the description modal) */
.zp-product-name {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
  transition: color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}
.zp-product-name:hover {
  color: var(--brand-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.zp-product-name:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: 3px;
}
.zp-product-name__icon {
  opacity: 0.5;
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.zp-product-name:hover .zp-product-name__icon { opacity: 1; }

@media (max-width: 640px) {
  .zp-modal { padding: 12px; }
  .zp-modal__dialog { max-height: calc(100vh - 24px); }
  .zp-modal__header { padding: 16px 18px 12px; }
  .zp-modal__body   { padding: 14px 18px 18px; }
}

/* ─── Utility helpers ─────────────────────────────────────── */
.text-muted    { color: var(--text-secondary) !important; }
.text-success  { color: var(--success) !important; }
.text-danger   { color: var(--danger) !important; }
.text-warning  { color: var(--warning) !important; }
.text-info     { color: var(--info) !important; }
.text-primary  { color: var(--brand-primary) !important; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.gap-2  { gap: 8px !important; }
.gap-3  { gap: 12px !important; }
.mb-0   { margin-bottom: 0 !important; }
.mt-0   { margin-top: 0 !important; }
.fs-12  { font-size: 12px !important; }
.fs-13  { font-size: 13px !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
