:root {
  --accent-primary: #0052cc;
  --accent-secondary: #0747a6;
  --accent-danger: #cf222e;
  --accent-cta: #ff2b5a;
  --bg-primary: #f6f8fa;
  --text-primary: #1f2328;
  --text-secondary: #57606a;
  --text-muted: #8c959f;
  --border-primary: #d0d7de;
  --border-secondary: #e1e4e8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  --radius-md: 8px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-main); color: var(--text-primary); }
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ==============================
   Dashboard / Admin layout
   ============================== */

.admin-container {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  padding: 24px 20px 8px;
  letter-spacing: -0.5px;
}

.sidebar-role {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-name {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-item.active {
  background: rgba(0,82,204,0.3);
  color: #fff;
  font-weight: 600;
}

.sidebar-icon { font-size: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logout {
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  font-weight: 500;
  display: block;
  padding: 8px 0;
  transition: color 0.15s;
}

.sidebar-logout:hover { color: #fff; }

/* Main area */
.admin-main {
  flex: 1;
  padding: 32px 36px;
  overflow-y: auto;
  min-width: 0;
}

.main-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.main-title {
  font-size: 24px;
  font-weight: 800;
  flex: 1;
}

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Notification badge */
.notif-badge {
  background: #cf222e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 7px;
  margin-left: auto;
}

/* ==============================
   Cards
   ============================== */

.card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-secondary);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

/* ==============================
   Tables
   ============================== */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-secondary);
  white-space: nowrap;
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-secondary);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg-primary); }

/* ==============================
   Buttons
   ============================== */

.btn-add {
  padding: 9px 20px;
  border-radius: 6px;
  background: var(--accent-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-add:hover { background: var(--accent-secondary); }

.btn-primary-sm {
  padding: 8px 18px;
  border-radius: 6px;
  background: var(--accent-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary-sm:hover { background: var(--accent-secondary); }
.btn-primary-sm:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost-sm {
  padding: 8px 16px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-primary);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-ghost-sm:hover { background: var(--bg-primary); }

.btn-danger-sm {
  padding: 6px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--accent-danger);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #ffb3ba;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger-sm:hover { background: #fff0f0; }

.btn-icon {
  padding: 6px 10px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  title: attr(data-title);
}
.btn-icon:hover { background: var(--bg-primary); }

/* Status toggle */
.status-toggle {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.status-toggle.active { background: #e6f4ea; color: #1a7f37; }
.status-toggle.inactive { background: #fef0f0; color: #cf222e; }

/* ==============================
   Forms
   ============================== */

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.form-group { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0,82,204,0.1);
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.error-inline {
  color: var(--accent-danger);
  font-size: 13px;
  background: #fff0f0;
  border: 1px solid #ffccd0;
  border-radius: 6px;
  padding: 8px 12px;
}

/* Search bar */
.search-bar {
  margin-bottom: 16px;
}
.search-bar .form-input {
  max-width: 360px;
  background: #fff;
}

/* ==============================
   Modal
   ============================== */

.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title { font-size: 20px; font-weight: 800; }

.modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg-primary); }

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.selected-file {
  background: var(--bg-primary);
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  word-break: break-all;
}

/* Upload progress */
.upload-progress { margin: 16px 0; }
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-secondary);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 6px;
  width: 0%;
  transition: width 0.3s;
  animation: progress-pulse 1.5s ease-in-out infinite;
}
@keyframes progress-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.progress-text { font-size: 13px; color: var(--text-secondary); }

/* ==============================
   States
   ============================== */

.loading-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ==============================
   Plan badges
   ============================== */

.plan-badge-starter { background: #f0f0f0; color: var(--text-secondary); border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.plan-badge-pro { background: #e6f0ff; color: var(--accent-primary); border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.plan-badge-enterprise { background: #fff8e1; color: #b45309; border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600; }

/* ==============================
   Responsive
   ============================== */

@media (max-width: 900px) {
  .admin-sidebar { width: 200px; }
  .admin-main { padding: 24px 20px; }
}

@media (max-width: 640px) {
  .admin-container { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: static; }
  .admin-main { padding: 20px 16px; }
  .main-header { flex-direction: column; align-items: flex-start; }
}
