:root {
  --color-coffee: #6B4226;
  --color-espresso: #2C1810;
  --color-latte: #D4A574;
  --color-cream: #FDF8F3;
  --color-mocha: #8B5E3C;
  --color-caramel: #C4883A;
  --color-foam: #F5EDE4;
  --color-roast: #3D2B1F;

  --color-bg: #FDF8F3;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F5EDE4;
  --color-border: #E8DDD2;
  --color-text: #2C1810;
  --color-text-muted: #8B7B6B;
  --color-primary: #6B4226;
  --color-primary-hover: #8B5E3C;
  --color-accent: #C4883A;
  --color-success: #2D8B55;
  --color-warning: #D4883A;
  --color-danger: #C0392B;
  --color-info: #2980B9;

  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(44,24,16,0.06);
  --shadow: 0 2px 8px rgba(44,24,16,0.08);
  --shadow-lg: 0 8px 24px rgba(44,24,16,0.12);
  --transition: 200ms ease;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #1A1210;
    --color-surface: #251C17;
    --color-surface-alt: #302420;
    --color-border: #3D302A;
    --color-text: #F0E6DC;
    --color-text-muted: #9B8B7B;
    --color-primary: #D4A574;
    --color-primary-hover: #E0B888;
    --color-foam: #302420;
    --color-cream: #1A1210;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  }
}
:root[data-theme="dark"] {
  --color-bg: #1A1210;
  --color-surface: #251C17;
  --color-surface-alt: #302420;
  --color-border: #3D302A;
  --color-text: #F0E6DC;
  --color-text-muted: #9B8B7B;
  --color-primary: #D4A574;
  --color-primary-hover: #E0B888;
  --color-foam: #302420;
  --color-cream: #1A1210;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}
.sidebar-brand .badge {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--color-accent);
  color: white;
  border-radius: 4px;
  font-weight: 600;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}
.sidebar-nav a:hover { background: var(--color-surface-alt); color: var(--color-text); }
.sidebar-nav a.active { background: var(--color-primary); color: white; }
.sidebar-nav a .count {
  margin-left: auto;
  font-size: 12px;
  background: var(--color-surface-alt);
  padding: 2px 8px;
  border-radius: 10px;
}
.sidebar-nav a.active .count { background: rgba(255,255,255,0.2); color: white; }

.sidebar-section { padding: 8px 12px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-top: 8px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-footer .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}
.sidebar-footer .user-info { flex: 1; }
.sidebar-footer .user-name { font-size: 13px; font-weight: 600; }
.sidebar-footer .user-role { font-size: 11px; color: var(--color-text-muted); text-transform: capitalize; }

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.page-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }

.page-body { padding: 24px 32px; }

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: var(--color-success); }
.stat-change.down { color: var(--color-danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 10px 16px; text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); background: var(--color-surface-alt); }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
tbody tr:hover { background: var(--color-surface-alt); }
td .badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }

/* Badges */
.badge-draft { background: #f0f0f0; color: #666; }
.badge-active { background: #e8f5e9; color: #2d8b55; }
.badge-sent { background: #e3f2fd; color: #2980b9; }
.badge-published { background: #e8f5e9; color: #2d8b55; }
.badge-paused { background: #fff3e0; color: #d4883a; }
.badge-failed { background: #fde8e8; color: #c0392b; }
.badge-approved { background: #e8f5e9; color: #2d8b55; }
.badge-pending_approval { background: #fff3e0; color: #d4883a; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn:hover { background: var(--color-surface-alt); box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-success { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn-danger { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(107,66,38,0.1);
}
.form-textarea { resize: vertical; min-height: 100px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50; display: none; align-items: center; justify-content: center; }
.modal-backdrop.active { display: flex; }
.modal { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 8px; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 13px; animation: slideIn 0.3s ease; }
.toast-success { background: var(--color-success); color: white; }
.toast-error { background: var(--color-danger); color: white; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Pipeline funnel */
.pipeline-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--color-surface-alt); margin: 8px 0; }
.pipeline-bar .segment { height: 100%; transition: width var(--transition); }

/* Responsive */
.mobile-toggle { display: none; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: block; }
  .page-header { padding: 16px; }
  .page-body { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
