:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 18px;
}

.logo-title {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
}

.logo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 8px;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-download-zip {
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-download-zip:hover {
  background: #dbeafe;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
}

.role-pill {
  font-size: 10px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}
.role-superadmin { background: #fee2e2; color: #b91c1c; }
.role-admin { background: #fef3c7; color: #b45309; }
.role-manager { background: #e0e7ff; color: #3730a3; }

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 10px;
}
.btn-logout:hover { color: #0f172a; }

/* Main Container */
.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

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

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.kpi-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.kpi-blue { background: #eff6ff; color: #2563eb; }
.kpi-green { background: #ecfdf5; color: #10b981; }
.kpi-yellow { background: #fffbeb; color: #f59e0b; }
.kpi-red { background: #fef2f2; color: #ef4444; }

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Panel Containers */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 12px;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search Box */
.search-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.input-field {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: all 0.15s;
}
.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.quick-demo-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-demo-pill {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-demo-pill:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Result Card */
.result-card {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: none;
}
.result-card.visible {
  display: block;
}

.result-header {
  padding: 14px 18px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: white;
}
.badge-green { background: var(--success); }
.badge-yellow { background: var(--warning); }
.badge-red { background: var(--danger); }
.badge-grey { background: #64748b; }

.result-body {
  padding: 20px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
}

.data-table tr:hover {
  background: #f8fafc;
}

.tag-red {
  background: #fee2e2;
  color: #991b1b;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
}

/* Login Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden {
  display: none;
}

.login-card {
  background: white;
  width: 100%;
  max-width: 420px;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* amoCRM Simulator Frame */
.amocrm-window {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f4f6f9;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  overflow: hidden;
}

.amocrm-topbar {
  background: #2b394e;
  color: white;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

.amocrm-body {
  padding: 20px;
}

.amocrm-deal-header {
  background: white;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
