/* ═══════════════════════════════════════════════════════════════════
   PLAY IA · APÊ SMART STUDIOS · DESIGN SYSTEM v1.0
   ═══════════════════════════════════════════════════════════════════ */

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

:root {
  /* Brand Colors */
  --ape-dark:   #0d1b2a;
  --ape-navy:   #1a2f4a;
  --ape-blue:   #1565c0;
  --ape-cyan:   #0288d1;
  --ape-teal:   #00897b;
  --ape-gold:   #f9a825;
  --ape-green:  #2e7d32;
  --ape-red:    #c62828;
  --ape-purple: #6a1b9a;
  --ape-orange: #ef6c00;

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Surface */
  --bg-page:    #f0f4f8;
  --bg-surface: #ffffff;
  --bg-sidebar: linear-gradient(180deg, var(--ape-dark) 0%, var(--ape-navy) 100%);

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(13, 27, 42, 0.05);
  --shadow-md:  0 4px 12px rgba(13, 27, 42, 0.08);
  --shadow-lg:  0 8px 24px rgba(13, 27, 42, 0.10);
  --shadow-xl:  0 16px 48px rgba(13, 27, 42, 0.15);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 24px;
  --r-full: 999px;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Sidebar width */
  --sidebar-w: 264px;

  /* Transitions */
  --t-fast: 0.15s ease;
  --t-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─── */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--gray-800);
  background: var(--bg-page);
  font-size: 14px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  z-index: 10;
  overflow-y: auto;
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

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

.topbar {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.85);
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.topbar-subtitle {
  color: var(--gray-500);
  font-size: 13px;
  margin-top: 2px;
}

.page {
  flex: 1;
  padding: 32px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Sidebar Brand ─── */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 20px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: contain;
  background: white;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(21, 101, 192, 0.35);
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-text .name {
  color: white;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-text .co {
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 2px;
  font-weight: 600;
}

/* ─── Sidebar Nav ─── */
.nav-section {
  margin: 20px 0 8px;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.35);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  z-index: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--t-fast);
  position: relative;
}

.nav-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  color: white;
  background: rgba(21, 101, 192, 0.20);
  box-shadow: inset 3px 0 0 var(--ape-blue);
}

.nav-item.active .nav-icon {
  color: var(--ape-cyan);
}

.nav-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  color: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
  transition: color var(--t-fast);
}

.nav-badge {
  margin-left: auto;
  background: var(--ape-gold);
  color: var(--ape-dark);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--r-full);
  font-weight: 700;
}

.nav-footer {
  margin-top: auto;
  padding: 16px 12px 8px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 1;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ape-green);
  margin-right: 6px;
  box-shadow: 0 0 8px rgba(46, 125, 50, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── Cards ─── */
.card {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--t-base), transform var(--t-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.01em;
}

.card-subtitle {
  color: var(--gray-500);
  font-size: 12.5px;
  margin-top: 2px;
}

/* ─── KPI Cards ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: transform var(--t-base), box-shadow var(--t-base);
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--kpi-color, var(--ape-blue));
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.kpi-label {
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-icon {
  width: 14px;
  height: 14px;
  color: var(--kpi-color, var(--ape-blue));
}

.kpi-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--gray-900);
  margin-top: 10px;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-feature-settings: 'tnum';
}

.kpi-sub {
  color: var(--gray-500);
  font-size: 12px;
  margin-top: 6px;
  font-weight: 500;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-full);
  margin-top: 8px;
}

.kpi-delta.pos {
  background: rgba(46, 125, 50, 0.10);
  color: var(--ape-green);
}

.kpi-delta.neg {
  background: rgba(198, 40, 40, 0.10);
  color: var(--ape-red);
}

.kpi-delta.neu {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* KPI color variants */
.kpi.blue   { --kpi-color: var(--ape-blue); }
.kpi.cyan   { --kpi-color: var(--ape-cyan); }
.kpi.teal   { --kpi-color: var(--ape-teal); }
.kpi.gold   { --kpi-color: var(--ape-gold); }
.kpi.green  { --kpi-color: var(--ape-green); }
.kpi.red    { --kpi-color: var(--ape-red); }
.kpi.purple { --kpi-color: var(--ape-purple); }
.kpi.orange { --kpi-color: var(--ape-orange); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--t-fast);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

.btn-primary {
  background: var(--ape-blue);
  color: white;
  box-shadow: 0 2px 6px rgba(21, 101, 192, 0.30);
}
.btn-primary:hover {
  background: #0d47a1;
  box-shadow: 0 4px 12px rgba(21, 101, 192, 0.40);
  transform: translateY(-1px);
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-200);
}
.btn-secondary:hover {
  border-color: var(--gray-300);
  background: var(--gray-50);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.btn-success {
  background: var(--ape-green);
  color: white;
}
.btn-success:hover {
  background: #1b5e20;
}

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 14px; }

/* ─── Form ─── */
.input, .select {
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--gray-200);
  background: white;
  font-size: 13px;
  color: var(--gray-800);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  min-width: 140px;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--ape-blue);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.10);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2364748b' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* ─── Table ─── */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 12px 14px;
  color: var(--gray-500);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.table td {
  padding: 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--t-fast);
}

.table tbody tr:hover {
  background: var(--gray-50);
}

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

.table .num {
  text-align: right;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
}

.table-total {
  font-weight: 700;
  background: var(--gray-50);
}

.table-total td {
  border-top: 2px solid var(--gray-300);
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-full);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.badge-blue   { background: rgba(21,101,192,0.12);  color: var(--ape-blue); }
.badge-green  { background: rgba(46,125,50,0.12);   color: var(--ape-green); }
.badge-red    { background: rgba(198,40,40,0.12);   color: var(--ape-red); }
.badge-gold   { background: rgba(249,168,37,0.15);  color: #b28104; }
.badge-cyan   { background: rgba(2,136,209,0.12);   color: var(--ape-cyan); }
.badge-gray   { background: var(--gray-100);        color: var(--gray-600); }

/* ─── Page Header ─── */
.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.page-desc {
  color: var(--gray-500);
  margin-top: 4px;
  font-size: 14px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Hero (gradient section) ─── */
.hero {
  background: linear-gradient(135deg, var(--ape-dark) 0%, var(--ape-navy) 45%, var(--ape-blue) 100%);
  border-radius: var(--r-xl);
  padding: 32px 36px;
  color: white;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4z'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-eyebrow {
  color: rgba(255,255,255,0.65);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
}

.hero-title {
  font-size: 32px;
  font-weight: 800;
  margin-top: 8px;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.hero-desc {
  color: rgba(255,255,255,0.75);
  margin-top: 10px;
  font-size: 14px;
  max-width: 720px;
  line-height: 1.6;
}

.hero-stats {
  display: flex;
  gap: 32px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.hero-stat .val {
  font-size: 26px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.02em;
  line-height: 1;
}

.hero-stat .lbl {
  color: rgba(255,255,255,0.55);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 6px;
}

/* ─── Skeleton loading ─── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: var(--r-sm);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Utilities ─── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.text-gray-500 { color: var(--gray-500); }
.text-gray-600 { color: var(--gray-600); }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0; }
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .page { padding: 20px; }
}

/* ─── Print (para reports) ─── */
@media print {
  .sidebar, .topbar, .page-actions { display: none; }
  .main { margin-left: 0; }
  .page { padding: 0; max-width: 100%; }
  .card, .kpi { box-shadow: none; border: 1px solid var(--gray-200); }
}
