/* ============================================================
   TART CAFE - Modern Admin Panel Design System & Styles
   ============================================================ */

:root {
  --bg-app: #0c0e14;
  --bg-sidebar: #12151f;
  --bg-card: #181c2a;
  --bg-card-hover: #1e2335;
  --bg-input: #121520;
  --bg-modal: #181c2b;

  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #f59e0b;
  --border-subtle: rgba(255, 255, 255, 0.04);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #f59e0b;
  --primary-hover: #d97706;
  --primary-glow: rgba(245, 158, 11, 0.2);

  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --info: #3b82f6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, 0.7);
  --transition: all 0.2s ease;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ============================================================
   APP LOADER
   ============================================================ */
.app-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10000;
  color: var(--text-muted);
  font-size: 14px;
}
.loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: var(--text-main);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--info); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   LOGIN VIEW
   ============================================================ */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top center, #1e1b29 0%, var(--bg-app) 70%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}
.login-header {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo {
  display: inline-block;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(245, 158, 11, 0.3));
}
.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}
.login-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.login-footer {
  margin-top: 24px;
  text-align: center;
}

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 250px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  padding: 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: block;
  line-height: 1.2;
}
.brand-badge {
  font-size: 10px;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.15);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.nav-item svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}
.nav-item.active {
  background: var(--primary);
  color: #111;
  font-weight: 600;
}
.nav-item.active svg {
  stroke: #111;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar-action-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-action-link svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.sidebar-action-link:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.03);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
}
.user-avatar {
  width: 32px;
  height: 32px;
  background: #334155;
  color: #f1f5f9;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.user-info {
  flex: 1;
  min-width: 0;
}
.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
}
.logout-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.logout-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.logout-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.admin-main {
  flex: 1;
  margin-left: 250px;
  min-height: 100vh;
  padding: 28px 36px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.top-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

/* Tabs */
.content-tab {
  display: none;
}
.content-tab.active {
  display: block;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   DASHBOARD STATS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.stat-icon-amber { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.stat-icon-blue  { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.stat-icon-rose  { background: rgba(244, 63, 94, 0.15); color: #f43f5e; }
.stat-icon-emerald{ background: rgba(16, 185, 129, 0.15); color: #10b981; }

.stat-content {
  display: flex;
  flex-direction: column;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}
.stat-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.dashboard-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.quick-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.quick-action-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}
.quick-action-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}
.qa-icon {
  font-size: 24px;
}
.qa-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
}
.qa-desc {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.3;
}

.recent-logs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.log-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.log-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.log-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
  white-space: nowrap;
}

/* ============================================================
   CARDS & TABLES
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin-bottom: 24px;
}
.max-w-3xl {
  max-width: 800px;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.card-body {
  padding: 22px;
}
.card-body.p-0 {
  padding: 0;
}

.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.filters-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}

.search-box {
  position: relative;
  min-width: 240px;
  flex: 1;
}
.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-dim);
  stroke-width: 2;
  fill: none;
}
.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px 9px 36px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}
.search-box input:focus {
  border-color: var(--border-focus);
}

.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}
.data-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.data-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

.prod-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #222;
  border: 1px solid var(--border);
}
.prod-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
}
.prod-thumb-empty svg {
  opacity: 0.45;
}
.prod-meta-title {
  font-weight: 600;
  color: var(--text-main);
  font-size: 13.5px;
}
.prod-meta-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.badge-active { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-inactive { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.badge-category { background: rgba(255, 255, 255, 0.07); color: var(--text-muted); }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state svg {
  width: 40px;
  height: 40px;
  stroke: var(--text-dim);
  stroke-width: 1.5;
  fill: none;
  margin-bottom: 12px;
}

/* Campaigns Grid */
.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.campaign-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.campaign-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #222;
}
.campaign-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.campaign-title {
  font-size: 14.5px;
  font-weight: 600;
}
.campaign-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
}
.campaign-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 8px;
}
.campaign-price {
  font-weight: 700;
  color: var(--primary);
  font-size: 16px;
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="tel"],
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-group textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.45;
}
.form-row {
  display: flex;
  gap: 14px;
}
.form-row > * {
  min-width: 0;
}
.flex-1 { flex: 1; min-width: 0; }
.flex-2 { flex: 2; min-width: 0; }
.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin: 24px 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  stroke: var(--text-dim);
  stroke-width: 2;
  fill: none;
  pointer-events: none;
}
.input-with-icon input {
  padding-left: 40px !important;
}
.input-action-btn {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
}
.input-action-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Custom Checkbox */
.checkbox-group {
  margin-top: 8px;
}
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.custom-checkbox input {
  display: none;
}
.checkbox-box {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.custom-checkbox input:checked + .checkbox-box {
  background: var(--primary);
  border-color: var(--primary);
}
.custom-checkbox input:checked + .checkbox-box::after {
  content: '✓';
  color: #111;
  font-size: 12px;
  font-weight: 700;
}
.checkbox-label {
  font-size: 13px;
  color: var(--text-main);
}

/* Image Upload UI */
.image-upload-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: var(--transition);
}
.image-upload-wrapper:hover {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(255, 255, 255, 0.035);
}
.image-preview-box {
  width: 66px;
  height: 66px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #111420;
  flex-shrink: 0;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.image-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}
.image-preview-empty {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  text-align: center;
  padding: 4px;
  user-select: none;
}
.image-preview-empty .empty-icon {
  width: 22px;
  height: 22px;
  stroke: var(--text-dim);
  stroke-width: 1.75;
  fill: none;
  opacity: 0.55;
}
.image-preview-empty .empty-text {
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.2px;
  opacity: 0.75;
}
.btn-remove-img {
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-remove-img:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: #ef4444 !important;
}
.image-upload-controls {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.image-upload-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.upload-hint {
  font-size: 11.5px;
  color: var(--text-dim);
}
.upload-progress {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Color Picker */
.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-picker-wrapper input[type="color"] {
  width: 40px;
  height: 38px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.color-hex-label {
  font-size: 13px;
  font-family: monospace;
  color: var(--text-muted);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
}
.btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.btn-primary {
  background: var(--primary);
  color: #111;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}
.btn-subtle {
  background: transparent;
  color: var(--text-muted);
}
.btn-subtle:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn-block {
  width: 100%;
}
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  margin-left: 6px;
  vertical-align: middle;
}
.btn-icon svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  display: block;
  pointer-events: none;
}
.btn-icon:hover {
  color: var(--primary);
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}
.btn-icon-danger {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.04);
}
.btn-icon-danger:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 13, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: modalBackdropFadeIn 0.22s ease-out;
}
@keyframes modalBackdropFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 40px);
  background: var(--bg-modal);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideInDown 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center top;
}
.modal-dialog-sm { max-width: 480px; }
.modal-dialog-xs { max-width: 380px; }

@keyframes modalSlideInDown {
  from {
    opacity: 0;
    transform: translateY(-24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #141724;
  flex-shrink: 0;
}
.modal-title {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}
.modal-close-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.modal-close-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border);
}

.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 999px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  transition: background 0.2s;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: #131622;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
}

/* Utilities */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  margin-bottom: 16px;
}
.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.link-subtle {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12.5px;
  transition: var(--transition);
}
.link-subtle:hover {
  color: var(--primary);
}
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.text-xs { font-size: 11px !important; }
.text-sm { font-size: 12.5px !important; }

/* Responsive */
@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-main {
    margin-left: 0;
    padding: 20px 16px;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .dashboard-sections {
    grid-template-columns: 1fr;
  }
}
