/* MercaDesk App — Panel v2 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --sb-width:    240px;
  --sb-bg:       #0f172a;
  --sb-border:   rgba(255,255,255,.07);
  --sb-text:     rgba(255,255,255,.55);
  --sb-text-h:   rgba(255,255,255,.9);
  --sb-active-bg:rgba(255,255,255,.08);
  --sb-section:  rgba(255,255,255,.28);

  --top-h:       56px;
  --page-bg:     #f1f5f9;
  --card-bg:     #ffffff;
  --border:      #e2e8f0;

  --primary:     #4f46e5;
  --primary-d:   #3730a3;
  --primary-l:   #818cf8;
  --violet:      #7c3aed;
  --green:       #10b981;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --cyan:        #06b6d4;
  --dark:        #0f172a;
  --gray:        #64748b;
  --muted:       #94a3b8;

  --r-sm: .375rem;
  --r-md: .625rem;
  --r-lg: .875rem;
  --r-xl: 1.25rem;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
}

/* ── Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .9rem;
  background: var(--page-bg);
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout shell ─────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  width: var(--sb-width);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-shrink: 0;
}

.brand-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .95rem;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  letter-spacing: -.02em;
}

.sidebar-org {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.org-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sb-section); }

.org-name {
  font-size: .82rem;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.nav-section-label {
  padding: .625rem 1.25rem .3rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--sb-section);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem 1.25rem;
  margin: 1px .5rem;
  border-radius: var(--r-md);
  font-size: .82rem;
  font-weight: 500;
  color: var(--sb-text);
  text-decoration: none;
  transition: background .15s, color .15s;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: var(--sb-text-h);
}

.nav-item.active {
  background: rgba(79,70,229,.2);
  color: var(--primary-l);
  font-weight: 600;
}

.nav-item.active .nav-icon { color: var(--primary-l); }

.nav-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  color: var(--sb-text);
  transition: color .15s;
}

.nav-item:hover .nav-icon { color: var(--sb-text-h); }

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  padding: .15rem .4rem;
  border-radius: 2rem;
  line-height: 1.3;
}

.nav-separator { height: 1px; background: var(--sb-border); margin: .5rem 1.25rem; }

.sidebar-user {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem;
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}

.user-card:hover { background: rgba(255,255,255,.06); }

.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.user-name  { font-size: .78rem; font-weight: 600; color: rgba(255,255,255,.8); line-height: 1.2; }
.user-email { font-size: .67rem; color: rgba(255,255,255,.35); }

.user-chevron { margin-left: auto; color: rgba(255,255,255,.3); font-size: .75rem; }

/* ── Main area ────────────────────────────────────── */
.main-area {
  flex: 1;
  margin-left: var(--sb-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Topbar ───────────────────────────────────────── */
.topbar {
  height: var(--top-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gray);
  font-size: 1.25rem;
  cursor: pointer;
  padding: .25rem;
  border-radius: var(--r-sm);
  line-height: 1;
  transition: background .15s, color .15s;
}

.topbar-toggle:hover { background: var(--border); color: var(--dark); }

.topbar-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--dark);
  letter-spacing: -.01em;
}

.topbar-sep { width: 1px; height: 20px; background: var(--border); }

.topbar-breadcrumb {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .625rem; }

.topbar-org-badge {
  font-size: .72rem;
  font-weight: 600;
  color: var(--gray);
  background: var(--page-bg);
  border: 1px solid var(--border);
  padding: .25rem .75rem;
  border-radius: 2rem;
}

/* ── Flash messages ───────────────────────────────── */
.flash-bar {
  padding: .625rem 1.5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  font-weight: 500;
}

.flash-bar.flash-success { background: #f0fdf4; color: #15803d; border-bottom: 1px solid #bbf7d0; }
.flash-bar.flash-error   { background: #fef2f2; color: #b91c1c; border-bottom: 1px solid #fecaca; }
.flash-bar.flash-info    { background: #eff6ff; color: #1d4ed8; border-bottom: 1px solid #bfdbfe; }

/* ── Page content ─────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 1.75rem;
  max-width: 1280px;
}

/* ── Page header ──────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--dark);
  letter-spacing: -.03em;
  margin: 0 0 .2rem;
}

.page-header-sub { font-size: .8rem; color: var(--muted); margin: 0; }

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  font-size: .82rem;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: .5rem;
  border-radius: var(--r-xl) var(--r-xl) 0 0 !important;
}

.card-header .card-icon { color: var(--muted); }
.card-body { padding: 1.25rem; }

/* ── KPI Cards ────────────────────────────────────── */
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow .2s, transform .2s;
  box-shadow: var(--shadow);
}

.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.kpi-val { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; color: var(--dark); line-height: 1; }
.kpi-label { font-size: .72rem; color: var(--muted); font-weight: 500; margin-top: .25rem; }
.kpi-change { font-size: .72rem; font-weight: 600; margin-top: .3rem; }
.kpi-up   { color: var(--green); }
.kpi-down { color: var(--red); }
.kpi-neu  { color: var(--muted); }

/* ── Tables ───────────────────────────────────────── */
.table th {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  white-space: nowrap;
}

.table td {
  font-size: .82rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--page-bg); }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: .82rem;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: all .15s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--violet));
  border: none;
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-d), #5b21b6);
  box-shadow: 0 4px 12px rgba(79,70,229,.35);
  color: #fff;
  transform: translateY(-1px);
}

.btn-outline-primary { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--gray);
}

.btn-ghost:hover { background: var(--page-bg); color: var(--dark); }

/* ── Forms ────────────────────────────────────────── */
.form-label { font-size: .8rem; font-weight: 600; color: var(--dark); margin-bottom: .375rem; }

.form-control, .form-select {
  font-size: .85rem;
  border-radius: var(--r-md);
  border-color: var(--border);
  color: var(--dark);
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.form-text { font-size: .75rem; color: var(--muted); }

/* ── Badges ───────────────────────────────────────── */
.badge {
  font-size: .68rem;
  font-weight: 600;
  border-radius: 2rem;
  padding: .3em .7em;
}

/* ── Empty state ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.25rem;
}

.empty-title { font-size: 1rem; font-weight: 700; color: var(--dark); margin-bottom: .375rem; }
.empty-desc  { font-size: .82rem; color: var(--muted); max-width: 340px; margin: 0 auto 1.5rem; line-height: 1.6; }

/* ── Coming soon ──────────────────────────────────── */
.coming-soon-wrap {
  text-align: center;
  padding: 3rem 1.5rem;
}

.coming-icon {
  width: 80px; height: 80px;
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.25rem;
  margin: 0 auto 1.5rem;
}

.coming-tag {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--primary);
  background: rgba(79,70,229,.08);
  border: 1px solid rgba(79,70,229,.15);
  border-radius: 2rem;
  padding: .3rem .875rem;
  margin-bottom: 1rem;
}

.coming-title { font-size: 1.35rem; font-weight: 800; color: var(--dark); letter-spacing: -.03em; margin-bottom: .5rem; }
.coming-desc  { font-size: .875rem; color: var(--gray); max-width: 460px; margin: 0 auto 2rem; line-height: 1.7; }

.feature-preview {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  text-align: left;
  height: 100%;
}

.fp-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  margin-bottom: .75rem;
}

.fp-title { font-size: .82rem; font-weight: 700; color: var(--dark); margin-bottom: .25rem; }
.fp-desc  { font-size: .75rem; color: var(--muted); line-height: 1.5; margin: 0; }

/* ── Mobile sidebar overlay ───────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 190;
  backdrop-filter: blur(2px);
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-area { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .page-content { padding: 1.25rem 1rem; }
}

/* ── Misc helpers ─────────────────────────────────── */
.text-muted   { color: var(--muted) !important; }
.text-primary { color: var(--primary) !important; }

.avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; color: #fff;
}

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
label[for] { cursor: pointer; }

/* ── Dropdown overrides ───────────────────────────── */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  font-size: .82rem;
}

.dropdown-item {
  padding: .5rem 1rem;
  color: var(--dark);
  font-weight: 500;
  border-radius: var(--r-sm);
}

.dropdown-item:hover { background: var(--page-bg); }
.dropdown-item.text-danger:hover { background: #fef2f2; }

/* ── Alert overrides ──────────────────────────────── */
.alert { border-radius: var(--r-lg); border: none; font-size: .82rem; }
