/* ==========================================================================
   ApexCode Customer Portal
   Built on top of the ApexCode marketing site design tokens.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&display=swap');

:root {
  /* Colors — identical to apexcode.com */
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-mid: rgba(37, 99, 235, 0.12);
  --dark-blue: #0F172A;
  --bg-main: #FFFFFF;
  --bg-light: #F8FAFC;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --border-focus: #3B82F6;

  --primary-glow: rgba(37, 99, 235, 0.08);
  --primary-glow-hover: rgba(37, 99, 235, 0.15);
  --white-translucent: rgba(255, 255, 255, 0.75);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  --shadow-primary: 0 10px 35px -5px rgba(37, 99, 235, 0.45);

  --container-width: 1240px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 24px;
  --border-radius-full: 9999px;

  /* Portal-specific semantic colors (status system) */
  --ok-bg: #ECFDF5;     --ok-text: #047857;     --ok-dot: #10B981;
  --warn-bg: #FFFBEB;   --warn-text: #B45309;   --warn-dot: #F59E0B;
  --bad-bg: #FEF2F2;    --bad-text: #B91C1C;    --bad-dot: #EF4444;
  --info-bg: #EFF6FF;   --info-text: #1D4ED8;   --info-dot: #2563EB;
  --neutral-bg: #F1F5F9; --neutral-text: #475569; --neutral-dot: #94A3B8;

  --sidebar-w: 264px;
}

/* ==========================================================================
   Reset
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--bg-light);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; transition: var(--transition-fast); }
button, input, textarea, select {
  font-family: inherit; font-size: inherit; color: inherit; outline: none; border: none;
}
button { cursor: pointer; background: none; }
ul, ol { list-style: none; }
::selection { background-color: var(--primary-light); color: var(--primary); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-light); }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%); border-radius: var(--border-radius-full); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ==========================================================================
   Shared bits: logo, buttons, badges, forms
   ========================================================================== */
.logo { display: flex; align-items: center; }
.logo img { display: block; height: 30px; width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; font-weight: 600; font-size: 0.92rem;
  border-radius: var(--border-radius-md); transition: all var(--transition-normal);
  position: relative; overflow: hidden; white-space: nowrap;
}
.btn::after {
  content: ''; position: absolute; top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: skewX(-20deg); transition: left 0.5s ease;
}
.btn:hover::after { left: 150%; }
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { box-shadow: var(--shadow-primary); filter: brightness(1.08); }
.btn-secondary { background-color: var(--primary-light); color: var(--primary); }
.btn-secondary:hover { background-color: var(--primary-glow-hover); }
.btn-outline { background-color: transparent; color: var(--text-main); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); background-color: var(--primary-light); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 10px 16px; }
.btn-ghost:hover { background: var(--bg-light); color: var(--text-main); }
.btn-danger-ghost { background: transparent; color: var(--bad-text); padding: 10px 16px; }
.btn-danger-ghost:hover { background: var(--bad-bg); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:disabled::after { display: none; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--border-radius-full);
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); } .badge-ok .badge-dot { background: var(--ok-dot); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); } .badge-warn .badge-dot { background: var(--warn-dot); }
.badge-bad { background: var(--bad-bg); color: var(--bad-text); } .badge-bad .badge-dot { background: var(--bad-dot); }
.badge-info { background: var(--info-bg); color: var(--info-text); } .badge-info .badge-dot { background: var(--info-dot); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-text); } .badge-neutral .badge-dot { background: var(--neutral-dot); }

.form-group { margin-bottom: 18px; position: relative; }
.form-group-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 18px; }
.form-control {
  width: 100%; padding: 14px 16px; background: var(--bg-light);
  border: 1.5px solid var(--border); border-radius: var(--border-radius-md);
  color: var(--text-main); font-size: 0.92rem; transition: all var(--transition-normal);
}
.form-control:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 110px; line-height: 1.5; }
select.form-control {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748B' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 16px center; background-repeat: no-repeat; background-size: 18px;
}
.form-label-static { display: block; font-size: 0.82rem; font-weight: 700; color: var(--text-main); margin-bottom: 8px; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }
.form-error { font-size: 0.8rem; color: var(--bad-text); margin-top: 6px; display: none; align-items: center; gap: 6px; }
.form-error.show { display: flex; }
.form-control.invalid { border-color: var(--bad-dot); background: var(--bad-bg); }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   AUTH (login / register / forgot password)
   ========================================================================== */
.auth-shell {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.auth-side {
  position: relative; overflow: hidden; display: flex; flex-direction: column;
  justify-content: space-between; padding: 56px;
  background: radial-gradient(ellipse 80% 60% at 30% -10%, rgba(37,99,235,0.35) 0%, transparent 60%), var(--dark-blue);
  color: #fff;
}
.auth-side::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 70% 70% at 30% 20%, black 0%, transparent 70%);
}
.auth-side .logo { position: relative; z-index: 1; } .auth-side .logo img { filter: brightness(0) invert(1); }

.auth-quote { position: relative; z-index: 1; max-width: 420px; }
.auth-quote p { font-family: 'DM Sans', sans-serif; font-size: 1.65rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; margin-bottom: 20px; }
.auth-quote .who { font-size: 0.9rem; color: rgba(255,255,255,0.7); }
.auth-side-foot { position: relative; z-index: 1; font-size: 0.85rem; color: rgba(255,255,255,0.55); }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px; background: var(--bg-light); }
.auth-box { width: 100%; max-width: 400px; }
.auth-box .logo { display: none; }
.auth-title { font-family: 'DM Sans', sans-serif; font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }
.auth-sub { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 32px; }
.auth-foot-link { text-align: center; margin-top: 24px; font-size: 0.9rem; color: var(--text-muted); }
.auth-foot-link a { color: var(--primary); font-weight: 700; }
.auth-foot-link a:hover { text-decoration: underline; }
.auth-divider { display: flex; align-items: center; gap: 14px; margin: 22px 0; color: var(--text-muted); font-size: 0.82rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-forgot { display: flex; justify-content: flex-end; margin: -8px 0 18px; }
.auth-forgot a { font-size: 0.85rem; color: var(--primary); font-weight: 600; }
.auth-forgot a:hover { text-decoration: underline; }
.auth-back { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; font-weight: 600; color: var(--text-muted); margin-bottom: 28px; }
.auth-back:hover { color: var(--primary); }
.auth-alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px;
  background: var(--bad-bg); color: var(--bad-text); border-radius: var(--border-radius-md);
  font-size: 0.85rem; font-weight: 600; margin-bottom: 20px; display: none;
}
.auth-alert.show { display: flex; }
.auth-alert svg { flex-shrink: 0; margin-top: 1px; }

@media (max-width: 920px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-box .logo { display: flex; margin-bottom: 36px; justify-content: center; color: var(--text-main); }
}

/* ==========================================================================
   APP SHELL (sidebar + topbar)
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
  transition: transform var(--transition-normal);
}
.sidebar-head { padding: 24px 24px 20px; border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 20px 16px; }
.nav-group-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); padding: 0 12px; margin: 20px 0 10px; }
.nav-group-label:first-child { margin-top: 0; }
.snav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--border-radius-md);
  font-size: 0.92rem; font-weight: 600; color: var(--text-muted); margin-bottom: 2px; position: relative;
  transition: all var(--transition-fast);
}
.snav-item svg { flex-shrink: 0; opacity: 0.85; }
.snav-item:hover { background: var(--bg-light); color: var(--text-main); }
.snav-item.active { background: var(--primary-light); color: var(--primary); }
.snav-item.active svg { opacity: 1; }
.snav-count {
  margin-left: auto; background: var(--neutral-bg); color: var(--text-muted); font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: var(--border-radius-full); transition: all var(--transition-fast);
}
.snav-item.active .snav-count { background: var(--primary); color: #fff; }
.sidebar-foot { padding: 16px; border-top: 1px solid var(--border); }
.user-pill {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--border-radius-md);
  cursor: pointer; transition: background var(--transition-fast); position: relative;
}
.user-pill:hover { background: var(--bg-light); }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #60a5fa);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.user-pill-info { flex: 1; min-width: 0; }
.user-pill-name { font-size: 0.86rem; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pill-co { font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: var(--border-radius-md); box-shadow: var(--shadow-xl); padding: 8px; opacity: 0; visibility: hidden;
  transform: translateY(6px); transition: all var(--transition-fast); z-index: 50;
}
.user-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.user-menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 0.86rem; font-weight: 600; color: var(--text-main); }
.user-menu-item:hover { background: var(--bg-light); }
.user-menu-item.danger { color: var(--bad-text); }
.user-menu-item.danger:hover { background: var(--bad-bg); }

.sidebar-toggle {
  display: none; width: 38px; height: 38px; align-items: center; justify-content: center;
  border-radius: var(--border-radius-md); background: var(--bg-light); flex-shrink: 0;
}

.main-area { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 76px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px) saturate(180%); position: sticky; top: 0; z-index: 60; gap: 20px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.page-title { font-family: 'DM Sans', sans-serif; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--border-radius-md); color: var(--text-muted); position: relative; transition: all var(--transition-fast);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-light); color: var(--text-main); }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad-dot); border: 2px solid #fff; }

.view { padding: 32px; max-width: 1240px; width: 100%; margin: 0 auto; flex: 1; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.view-head h1 { font-family: 'DM Sans', sans-serif; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.view-head p { color: var(--text-muted); font-size: 0.95rem; }
.view-actions { display: flex; gap: 12px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .main-area { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .page-title { font-size: 1.1rem; }
  .topbar { padding: 0 16px; }
  .view { padding: 20px; }
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.4); z-index: 90; backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ==========================================================================
   DASHBOARD widgets
   ========================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }
.stat-card { padding: 22px 24px; position: relative; overflow: hidden; }
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.stat-icon {
  width: 42px; height: 42px; border-radius: var(--border-radius-md); display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary); flex-shrink: 0;
}
.stat-trend { font-size: 0.76rem; font-weight: 700; display: flex; align-items: center; gap: 3px; }
.stat-trend.up { color: var(--ok-text); } .stat-trend.down { color: var(--bad-text); }
.stat-value { font-family: 'DM Sans', sans-serif; font-size: 2rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.panel { padding: 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-head h3 { font-family: 'DM Sans', sans-serif; font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.panel-head a { font-size: 0.84rem; font-weight: 700; color: var(--primary); }
.panel-head a:hover { text-decoration: underline; }

.activity-item { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; padding-bottom: 0; }
.activity-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 0.88rem; font-weight: 600; color: var(--text-main); margin-bottom: 2px; }
.activity-meta { font-size: 0.78rem; color: var(--text-muted); }

.quick-action {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: var(--border-radius-md);
  border: 1.5px solid var(--border); margin-bottom: 10px; transition: all var(--transition-fast); font-weight: 700; font-size: 0.88rem;
}
.quick-action:last-child { margin-bottom: 0; }
.quick-action:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.quick-action svg { color: var(--primary); flex-shrink: 0; }

@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   TABLES / LISTS (tickets, invoices)
   ========================================================================== */
.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.search-input-wrap { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search-input-wrap svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input-wrap input { padding-left: 42px; }
.filter-bar select.form-control { max-width: 180px; }
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-pill {
  padding: 8px 16px; border-radius: var(--border-radius-full); font-size: 0.84rem; font-weight: 700;
  border: 1.5px solid var(--border); color: var(--text-muted); transition: all var(--transition-fast);
}
.filter-pill:hover { border-color: var(--primary); color: var(--primary); }
.filter-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  text-align: left; font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 0 20px 12px; border-bottom: 1px solid var(--border);
}
.data-table tbody tr { transition: background var(--transition-fast); cursor: pointer; }
.data-table tbody tr:hover { background: var(--bg-light); }
.data-table tbody td { padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.cell-main { font-weight: 700; color: var(--text-main); }
.cell-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.cell-muted { color: var(--text-muted); }
.table-scroll { overflow-x: auto; }
@media (max-width: 800px) { .data-table { min-width: 720px; } }

.empty-state { text-align: center; padding: 64px 24px; }
.empty-icon {
  width: 64px; height: 64px; border-radius: 50%; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 20px;
}
.empty-state h3 { font-family: 'DM Sans', sans-serif; font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); font-size: 0.92rem; max-width: 360px; margin: 0 auto 20px; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding-top: 18px; margin-top: 4px; }
.pagination-info { font-size: 0.82rem; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 8px; }
.page-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--border-radius-md); border: 1.5px solid var(--border); color: var(--text-muted); font-weight: 700; font-size: 0.85rem; }
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ==========================================================================
   TICKET DETAIL / THREAD
   ========================================================================== */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 4px; flex-wrap: wrap; }
.detail-back { display: inline-flex; align-items: center; gap: 8px; font-size: 0.86rem; font-weight: 700; color: var(--text-muted); margin-bottom: 16px; }
.detail-back:hover { color: var(--primary); }
.detail-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.detail-title-row h1 { font-family: 'DM Sans', sans-serif; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; }
.detail-meta { font-size: 0.84rem; color: var(--text-muted); }
.detail-meta b { color: var(--text-main); }

.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; margin-top: 22px; align-items: start; }

.thread { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.msg { display: flex; gap: 14px; }
.msg-avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.82rem; flex-shrink: 0; color: #fff; }
.msg.from-customer .msg-avatar { background: linear-gradient(135deg, var(--primary), #60a5fa); }
.msg.from-staff .msg-avatar { background: linear-gradient(135deg, #0F172A, #334155); }
.msg-body { flex: 1; min-width: 0; }
.msg-bubble { background: var(--bg-light); border-radius: var(--border-radius-md); padding: 14px 16px; font-size: 0.9rem; line-height: 1.55; color: var(--text-main); }
.msg.from-staff .msg-bubble { background: var(--primary-light); }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.msg-name { font-size: 0.85rem; font-weight: 700; }
.msg-time { font-size: 0.76rem; color: var(--text-muted); }
.msg-attachments { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--border-radius-md); font-size: 0.78rem; font-weight: 600; color: var(--text-main); }
.attachment-chip-remove { cursor: pointer; color: var(--text-muted); line-height: 0; margin-left: 2px; }
.attachment-chip-remove:hover { color: var(--bad-text); }

.reply-box { border-top: 1px solid var(--border); padding: 20px 24px; }
.reply-box textarea { margin-bottom: 8px; }
.reply-attachments-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; min-height: 0; }
.reply-box-foot { display: flex; align-items: center; gap: 10px; }
.reply-box-foot .form-hint { flex: 1; }

.attachment-upload-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: var(--border-radius-md); border: 1.5px solid var(--border);
  font-size: 0.82rem; font-weight: 700; color: var(--text-muted); cursor: pointer;
  transition: all var(--transition-fast); flex-shrink: 0;
}
.attachment-upload-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* Toggle switch */
.toggle-wrap { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 99px; cursor: pointer;
  transition: background var(--transition-normal);
}
.toggle-slider::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  box-shadow: var(--shadow-sm); transition: transform var(--transition-normal);
}
.toggle-input:checked + .toggle-slider { background: var(--primary); }
.toggle-input:checked + .toggle-slider::after { transform: translateX(18px); }

.notif-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.notif-toggle-row:last-child { border-bottom: none; padding-bottom: 0; }
.notif-toggle-row:first-of-type { padding-top: 0; }

/* Company switcher */
.company-switcher { position: relative; }
.company-switcher-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border-radius: var(--border-radius-md); border: 1.5px solid var(--border);
  background: #fff; font-size: 0.84rem; font-weight: 700; color: var(--text-main);
  cursor: pointer; transition: all var(--transition-fast); max-width: 220px;
}
.company-switcher-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-switcher-btn:hover { border-color: var(--primary); color: var(--primary); }
.company-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 240px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--border-radius-md); box-shadow: var(--shadow-xl);
  z-index: 200; overflow: hidden; opacity: 0; visibility: hidden;
  transform: translateY(6px); transition: all var(--transition-fast);
}
.company-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.company-dropdown-header { padding: 10px 14px 8px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.company-option {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  font-size: 0.86rem; font-weight: 600; color: var(--text-main); cursor: pointer; transition: background var(--transition-fast);
}
.company-option:hover { background: var(--bg-light); }
.company-option.active { color: var(--primary); background: var(--primary-light); }
.company-option-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.company-option.active .company-option-dot { background: var(--primary); }
.company-option-sub { font-size: 0.72rem; color: var(--text-muted); font-weight: 400; margin-top: 1px; }
.closed-banner {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--neutral-bg);
  color: var(--neutral-text); font-size: 0.85rem; font-weight: 600; border-radius: var(--border-radius-md); margin: 0 24px 0;
}

.side-panel { padding: 20px; }
.side-panel + .side-panel { margin-top: 16px; }
.side-panel h4 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 14px; }
.side-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; font-size: 0.87rem; border-bottom: 1px solid var(--border); }
.side-row:last-child { border-bottom: none; padding-bottom: 0; }
.side-row:first-child { padding-top: 0; }
.side-row span:first-child { color: var(--text-muted); }
.side-row span:last-child { font-weight: 700; text-align: right; }

@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   INVOICES
   ========================================================================== */
.invoice-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 24px; }
@media (max-width: 800px) { .invoice-summary-grid { grid-template-columns: 1fr; } }

.invoice-detail-card { padding: 0; overflow: hidden; }
.invoice-detail-head { padding: 32px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.invoice-detail-head .logo img { height: 26px; }
.invoice-num { font-family: 'DM Sans', sans-serif; font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 28px 32px; border-bottom: 1px solid var(--border); }
.invoice-party-label { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 8px; }
.invoice-party p { font-size: 0.9rem; color: var(--text-main); line-height: 1.6; }
.invoice-party strong { display: block; margin-bottom: 2px; }
.invoice-lines { padding: 28px 32px; }
.invoice-lines table { width: 100%; border-collapse: collapse; }
.invoice-lines th { text-align: left; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding-bottom: 12px; border-bottom: 1.5px solid var(--border); }
.invoice-lines th:last-child, .invoice-lines td:last-child { text-align: right; }
.invoice-lines td { padding: 14px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.invoice-lines tr:last-child td { border-bottom: none; }
.invoice-totals { padding: 0 32px 32px; margin-left: auto; max-width: 320px; }
.total-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 0.9rem; color: var(--text-muted); }
.total-row.grand { border-top: 1.5px solid var(--border); margin-top: 6px; padding-top: 14px; font-size: 1.15rem; font-weight: 600; color: var(--text-main); font-family: 'DM Sans', sans-serif; }
.invoice-foot { padding: 24px 32px; background: var(--bg-light); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ==========================================================================
   MODAL (new ticket, etc.)
   ========================================================================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5); backdrop-filter: blur(10px) saturate(180%);
  z-index: 2000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none;
  transition: opacity var(--transition-normal); padding: 24px;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-container {
  background: linear-gradient(145deg, #ffffff 0%, #f8faff 100%); border-radius: var(--border-radius-lg);
  border: 1px solid var(--border); box-shadow: 0 40px 100px rgba(15,23,42,0.2);
  width: 100%; max-width: 560px; overflow: hidden; transform: translateY(24px) scale(0.97);
  transition: transform var(--transition-normal); max-height: 88vh; display: flex; flex-direction: column;
}
.modal-overlay.active .modal-container { transform: translateY(0) scale(1); }
.modal-header { padding: 28px 32px 16px; display: flex; justify-content: space-between; align-items: flex-start; flex-shrink: 0; }
.modal-title { font-family: 'DM Sans', sans-serif; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.modal-sub { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
.modal-close { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-light); color: var(--text-muted); display: flex; align-items: center; justify-content: center; transition: all var(--transition-fast); flex-shrink: 0; }
.modal-close:hover { background: var(--bad-bg); color: var(--bad-text); transform: rotate(90deg); }
.modal-body { padding: 16px 32px 28px; overflow-y: auto; }
.modal-foot { padding: 18px 32px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }

.file-drop {
  border: 1.5px dashed var(--border); border-radius: var(--border-radius-md); padding: 22px;
  text-align: center; color: var(--text-muted); font-size: 0.85rem; transition: all var(--transition-fast); cursor: pointer;
}
.file-drop:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.file-drop svg { margin-bottom: 8px; }

/* Severity / priority pickers */
.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-pill {
  flex: 1; min-width: 90px; text-align: center; padding: 10px 8px; border-radius: var(--border-radius-md);
  border: 1.5px solid var(--border); font-size: 0.84rem; font-weight: 700; color: var(--text-muted); transition: all var(--transition-fast);
}
.choice-pill:hover { border-color: var(--primary); }
.choice-pill.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ==========================================================================
   TOASTS
   ========================================================================== */
.toast-stack { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-xl); padding: 14px 18px; font-size: 0.87rem; font-weight: 600; max-width: 340px;
  transform: translateX(120%); transition: transform var(--transition-normal); opacity: 0;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-icon { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast.ok .toast-icon { background: var(--ok-bg); color: var(--ok-text); }
.toast.bad .toast-icon { background: var(--bad-bg); color: var(--bad-text); }
.toast.info .toast-icon { background: var(--info-bg); color: var(--info-text); }
@media (max-width: 560px) { .toast-stack { left: 16px; right: 16px; bottom: 16px; } .toast { max-width: none; } }

/* ==========================================================================
   ACCOUNT / SETTINGS
   ========================================================================== */
.settings-grid { display: grid; grid-template-columns: 240px 1fr; gap: 28px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav-item { padding: 11px 14px; border-radius: var(--border-radius-md); font-size: 0.88rem; font-weight: 700; color: var(--text-muted); }
.settings-nav-item:hover { background: var(--bg-light); color: var(--text-main); }
.settings-nav-item.active { background: var(--primary-light); color: var(--primary); }
.settings-section { padding: 28px; margin-bottom: 20px; }
.settings-section h3 { font-family: 'DM Sans', sans-serif; font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.settings-section .sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 22px; }
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   ADMIN — customer cards, line-item builder, role badge
   ========================================================================== */
.role-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--border-radius-full);
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--dark-blue); color: #fff; margin-left: 8px; vertical-align: middle;
}

.customer-row-name { display: flex; align-items: center; gap: 12px; }
.customer-row-name .user-avatar { width: 34px; height: 34px; font-size: 0.78rem; }

.kpi-mini { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; font-weight: 700; }
.kpi-mini.bad { color: var(--bad-text); }
.kpi-mini.neutral { color: var(--text-muted); }

.customer-profile-head { display: flex; align-items: center; gap: 16px; padding: 28px; border-bottom: 1px solid var(--border); }
.customer-profile-head .user-avatar { width: 56px; height: 56px; font-size: 1.2rem; }
.customer-profile-head h2 { font-family: 'DM Sans', sans-serif; font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; }
.customer-profile-head p { font-size: 0.85rem; color: var(--text-muted); }
.customer-profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); }
.cp-stat { background: #fff; padding: 18px 20px; }
.cp-stat .stat-value { font-size: 1.4rem; margin-bottom: 2px; }
.cp-stat .stat-label { font-size: 0.76rem; }
@media (max-width: 700px) { .customer-profile-stats { grid-template-columns: repeat(2, 1fr); } }

.line-item-row {
  display: grid; grid-template-columns: 1fr 70px 110px 36px; gap: 10px; margin-bottom: 10px; align-items: center;
}
.line-item-row input { padding: 11px 14px; }
.line-item-remove {
  width: 36px; height: 36px; border-radius: var(--border-radius-md); display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all var(--transition-fast);
}
.line-item-remove:hover { background: var(--bad-bg); color: var(--bad-text); }
.line-item-head { display: grid; grid-template-columns: 1fr 70px 110px 36px; gap: 10px; margin-bottom: 8px; padding: 0 2px; }
.line-item-head span { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.add-line-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 0.84rem; font-weight: 700; color: var(--primary); padding: 8px 0; }
.add-line-btn:hover { text-decoration: underline; }
.invoice-form-total {
  display: flex; justify-content: flex-end; gap: 32px; padding: 16px 0; margin-top: 8px; border-top: 1.5px solid var(--border);
}
.invoice-form-total div { text-align: right; }
.invoice-form-total .label { font-size: 0.76rem; color: var(--text-muted); margin-bottom: 2px; }
.invoice-form-total .value { font-family: 'DM Sans', sans-serif; font-weight: 600; font-size: 1.1rem; }

@media (max-width: 560px) {
  .line-item-row, .line-item-head { grid-template-columns: 1fr 56px 90px 32px; }
}

/* ==========================================================================
   VOORBEELDSITES
   ========================================================================== */
.voorbeeld-add-form {
  background: var(--bg-light); border-radius: var(--border-radius-md);
  padding: 16px; margin-bottom: 20px; border: 1.5px dashed var(--border);
}

.voorbeeld-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 4px;
}

.voorbeeld-card {
  border: 1.5px solid var(--border); border-radius: var(--border-radius-md);
  overflow: hidden; transition: all var(--transition-normal); position: relative;
  background: #fff;
}
.voorbeeld-card:hover { border-color: var(--primary); box-shadow: 0 6px 20px rgba(37,99,235,0.1); }

.voorbeeld-thumb {
  width: 100%; height: 160px; background: var(--bg-light); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
  cursor: pointer;
}
.voorbeeld-thumb iframe {
  width: 200%; height: 200%; transform: scale(0.5); transform-origin: top left;
  pointer-events: none; border: none; border-radius: 0;
}
.voorbeeld-thumb-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,0); transition: background var(--transition-fast);
}
.voorbeeld-thumb:hover .voorbeeld-thumb-overlay { background: rgba(15,23,42,0.35); }
.voorbeeld-thumb-overlay svg { color: #fff; opacity: 0; transform: scale(0.85); transition: all var(--transition-fast); }
.voorbeeld-thumb:hover .voorbeeld-thumb-overlay svg { opacity: 1; transform: scale(1); }

.voorbeeld-foot {
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.voorbeeld-foot-info { min-width: 0; flex: 1; }
.voorbeeld-foot-label { font-size: 0.86rem; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voorbeeld-foot-url { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voorbeeld-foot-actions { display: flex; gap: 4px; flex-shrink: 0; }
.voorbeeld-action {
  width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all var(--transition-fast); flex-shrink: 0;
}
.voorbeeld-action:hover { background: var(--bg-light); color: var(--text-main); }
.voorbeeld-action.danger:hover { background: var(--bad-bg); color: var(--bad-text); }

/* iframe preview overlay */
.preview-overlay {
  position: fixed; inset: 0; z-index: 4000; background: rgba(15,23,42,0.6);
  backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 24px;
}
.preview-overlay.hidden { display: none; }
.preview-shell {
  width: 100%; max-width: 1200px; height: 88vh; background: #fff;
  border-radius: var(--border-radius-lg); overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 40px 80px rgba(15,23,42,0.3);
}
.preview-bar {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; gap: 16px; border-bottom: 1px solid var(--border); background: var(--bg-light);
}
.preview-bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.preview-favicon {
  width: 28px; height: 28px; border-radius: 8px; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.preview-label { font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.preview-url {
  font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px;
}
.preview-bar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.preview-shell iframe { flex: 1; border: none; width: 100%; }

@media (max-width: 700px) {
  .voorbeeld-grid { grid-template-columns: 1fr; }
  .preview-overlay { padding: 0; }
  .preview-shell { border-radius: 0; height: 100vh; max-width: 100%; }
  .preview-url { display: none; }
}


.day-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; font-size: 0.78rem; font-weight: 700;
  background: var(--primary-light); color: var(--primary); border: 1.5px solid rgba(37,99,235,0.2);
}
.day-chip.inactive { background: var(--neutral-bg); color: var(--text-muted); border-color: var(--border); }

.note-item { background: var(--bg-light); border-radius: var(--border-radius-md); padding: 12px 14px; }
.note-item-time { font-size: 0.76rem; color: var(--text-muted); margin-bottom: 5px; }
.note-item-text { font-size: 0.88rem; color: var(--text-main); line-height: 1.5; }

.lead-status-btn {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--border-radius-md);
  border: 1.5px solid var(--border); font-size: 0.84rem; font-weight: 700; color: var(--text-muted);
  transition: all var(--transition-fast); text-align: left;
}
.lead-status-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.lead-status-btn.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.lead-status-btn .status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Utility */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0 !important; }
.hidden { display: none !important; }
