:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --info: #0891b2;
  --dark: #1e293b;
  --gray: #64748b;
  --light: #f8fafc;
  --border: #e2e8f0;
  --white: #ffffff;
  --sidebar-w: 250px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 8px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--light);
  color: var(--dark);
  font-size: 14px;
}

/* ============ LOGIN ============ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  padding: 20px;
}
.login-card {
  background: var(--white);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}
.login-card h1 { font-size: 24px; margin-bottom: 4px; color: var(--primary); }
.login-card p.sub { color: var(--gray); margin-bottom: 24px; }
.login-card .logo {
  width: 64px; height: 64px; margin: 0 auto 16px;
  background: var(--primary-light); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--primary);
}
.login-demo-banner {
  background: #fef3c7; color: #92400e; padding: 10px 14px; border-radius: 8px;
  font-size: 12px; margin-bottom: 16px; border: 1px solid #fde68a;
}
.login-card .api-hint { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.login-card .api-hint label { display:block; font-size:12px; color:var(--gray); margin-bottom:4px; font-weight:500; }
.login-card .api-hint input { width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:6px; font-size:12px; }

/* ============ LAYOUT ============ */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  color: #cbd5e1;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #334155;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
}
.sidebar-header small { display: block; font-size: 11px; color: #94a3b8; font-weight: 400; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: #334155; color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; border-left-color: #60a5fa; }
.sidebar-nav a i { width: 20px; text-align: center; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid #334155; }
.demo-tag { color:#fbbf24; font-size:11px; font-weight:600; }
.live-tag { color:#34d399; font-size:11px; font-weight:600; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 0;
}
.topbar {
  background: var(--white);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.topbar h2 { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar .user-info { font-size: 13px; text-align: right; }
.topbar .user-info strong { display: block; }
.topbar .user-info small { color: var(--gray); }
.content-area { padding: 24px; }

/* ============ CARDS / STATS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
}
.stat-card .stat-info h3 { font-size: 26px; font-weight: 700; }
.stat-card .stat-info p { color: var(--gray); font-size: 13px; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: var(--light); font-weight: 600; color: var(--gray); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
tr:hover { background: #f1f5f9; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: none; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: var(--gray); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--dark); }
.btn-outline:hover { background: var(--light); }

/* ============ FORMS ============ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; }
.form-control {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; transition: border 0.2s;
  font-family: inherit; background: var(--white);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { cursor: pointer; }

/* ============ BADGES ============ */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 12px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-not_started { background: #e2e8f0; color: #475569; }
.badge-started { background: #dbeafe; color: #1d4ed8; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-testing { background: #ede9fe; color: #6d28d9; }
.badge-completed { background: #d1fae5; color: #047857; }
.badge-closed { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #b91c1c; }
.badge-cancelled { background: #fee2e2; color: #b91c1c; }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--white); border-radius: 12px;
  max-width: 600px; width: 100%; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-lg { max-width: 800px; }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white); z-index: 2;
}
.modal-header h3 { font-size: 18px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--white); }
.close-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--gray); }

/* ============ GRID ============ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media(max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  #menu-btn { display: inline-flex !important; }
}

/* ============ MISC ============ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.text-muted { color: var(--gray); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.progress-bar {
  height: 8px; background: var(--border); border-radius: 4px; overflow: hidden;
}
.progress-bar .fill { height: 100%; background: var(--primary); transition: width 0.3s; }
.field-builder { border: 1px solid var(--border); border-radius: 6px; padding: 12px; margin-bottom: 12px; background: var(--light); }
.field-builder .field-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.field-builder .field-row > * { flex: 1; min-width: 120px; }
.empty-state { text-align: center; padding: 40px; color: var(--gray); }
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.icon-box {
  width: 40px; height: 40px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
}
.req-number { font-weight: 600; color: var(--primary); }
.detail-section { border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.detail-section h4 { margin-bottom: 12px; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.detail-row { display: flex; margin-bottom: 8px; }
.detail-row .label { width: 180px; font-weight: 500; color: var(--gray); flex-shrink: 0; }
.detail-row .value { flex: 1; word-break: break-word; }
.video-preview { max-width: 100%; border-radius: 8px; }
img.thumb { max-width: 120px; border-radius: 6px; border: 1px solid var(--border); }
.checkbox-group { display: flex; gap: 16px; flex-wrap: wrap; }
.checkbox-group label { display: flex; align-items: center; gap: 6px; font-weight: 400; }

/* ============ SETTINGS ============ */
.settings-card { max-width: 640px; }
.settings-row { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 0; border-bottom:1px solid var(--border); }
.settings-row:last-child { border-bottom:none; }
.settings-row .label-block strong { display:block; font-size:14px; }
.settings-row .label-block small { color:var(--gray); font-size:12px; }
.status-pill { padding:6px 14px; border-radius:20px; font-size:12px; font-weight:600; }
.status-pill.demo { background:#fef3c7; color:#92400e; }
.status-pill.live { background:#d1fae5; color:#065f46; }
.toggle-switch { position:relative; width:46px; height:26px; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-switch .slider { position:absolute; inset:0; background:#cbd5e1; border-radius:26px; cursor:pointer; transition:0.3s; }
.toggle-switch .slider:before { content:""; position:absolute; width:20px; height:20px; left:3px; top:3px; background:#fff; border-radius:50%; transition:0.3s; }
.toggle-switch input:checked + .slider { background:var(--primary); }
.toggle-switch input:checked + .slider:before { transform:translateX(20px); }
