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

:root {
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: 0.2s ease;
  --sidebar-w: 250px;
  --sidebar-w-collapsed: 64px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: var(--primary-600);
}

[data-theme="dark"] {
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-light: #64748b;
  --bg: #0f172a;
  --card: #1e293b;
  --border: #334155;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --primary-50: #172554;
  --primary-100: #1e3a5f;
  --primary-200: #1e40af;
  --sidebar-bg: #020617;
  --sidebar-hover: #1e293b;
  --sidebar-active: var(--primary-600);
  --success-bg: #064e3b;
  --warning-bg: #78350f;
  --danger-bg: #7f1d1d;
}

[data-theme="dark"] tr:hover td { background: #1e293b; }

[data-theme="dark"] .user-trigger:hover { border-color: var(--primary-600); background: var(--primary-100); }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== LOGIN PAGE ===== */
#login-page {
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.login-split {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* Left: Hero panel */
.login-hero {
  flex: 1.2;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('https://images.unsplash.com/photo-1586528116311-ad8dd3c8310d?w=800&q=80') center / cover no-repeat;
  overflow: hidden;
}

.login-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.92), rgba(37, 99, 235, 0.7));
}

.login-hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff;
  padding: 40px;
  max-width: 440px;
}

.login-hero-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  color: #fff;
}

.login-hero-logo svg {
  width: 100%;
  height: 100%;
}

.login-hero-content h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.login-hero-tagline {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 16px;
  line-height: 1.5;
}

.login-hero-desc {
  font-size: 14px;
  opacity: 0.7;
  line-height: 1.7;
  max-width: 340px;
  margin: 0 auto;
}

/* Right: Form panel */
.login-form-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg);
  overflow-y: auto;
}

.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
  animation: modalIn 0.5s ease;
}

.login-form-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.login-form-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-card .btn-block {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  text-align: center;
  min-height: 20px;
}

.login-info {
  text-align: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.login-info p {
  font-size: 12px;
  color: var(--text-light);
}

.login-info p code {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

/* ===== MULTI-STEP REGISTER ===== */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 20px 0 12px;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--border);
  color: var(--text-light);
  transition: background 0.3s, color 0.3s, box-shadow 0.3s;
  flex-shrink: 0;
}

.step-dot.active {
  background: var(--primary-600);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.step-dot.completed {
  background: var(--success, #22c55e);
  color: #fff;
}

.step-line {
  width: 48px;
  height: 2px;
  background: var(--border);
  transition: background 0.3s;
  flex-shrink: 0;
}

.step-line.completed {
  background: var(--success, #22c55e);
}

.step-label {
  text-align: center !important;
  margin-bottom: 20px !important;
  min-height: 20px;
}

.register-step {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-group .btn {
  flex: 1;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg);
  border-color: var(--text-light);
}

/* ===== APP LAYOUT ===== */
#app {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease-in-out, transform 0.2s ease-in-out;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 45;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.sidebar-brand .brand-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.9);
}

.sidebar-brand .brand-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-brand .brand-text {
  color: white;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-brand .brand-text {
  opacity: 0;
  width: 0;
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.sidebar.collapsed .sidebar-toggle {
  display: none;
}

/* --- Sidebar Nav --- */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px;
}

.sidebar-nav .nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.25);
  padding: 16px 14px 6px;
  font-weight: 600;
}

.sidebar.collapsed .sidebar-nav .nav-section {
  display: none;
}

.sidebar-nav a, .sidebar-nav .nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  width: 100%;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  white-space: nowrap;
  margin-bottom: 2px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-nav a:hover, .sidebar-nav .nav-btn:hover {
  background: var(--sidebar-hover);
  color: rgba(255, 255, 255, 0.9);
}

.sidebar-nav a.active, .sidebar-nav .nav-btn.active {
  background: var(--sidebar-active);
  color: white;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.sidebar-nav .nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-nav .nav-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-nav .nav-text {
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-nav .nav-text {
  opacity: 0;
  width: 0;
  display: none;
}

.sidebar.collapsed .sidebar-nav a,
.sidebar.collapsed .sidebar-nav .nav-btn {
  justify-content: center;
  padding: 11px 0;
}

/* --- Sidebar Dropdown Sub-menu --- */
.sidebar-nav .has-submenu {
  position: relative;
}

.sidebar-nav .nav-arrow {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s ease;
  opacity: 0.5;
}

.sidebar-nav .has-submenu.open .nav-arrow {
  transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-nav .has-submenu .nav-arrow {
  display: none;
}

.sidebar-nav .nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 0;
  padding-left: 4px;
}

.sidebar-nav .nav-submenu.open {
  max-height: 200px;
  opacity: 1;
}

.sidebar.collapsed .sidebar-nav .nav-submenu {
  max-height: 0 !important;
  opacity: 0 !important;
  display: none;
}

.sidebar-nav .nav-sub-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 48px;
  width: 100%;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.5);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  transition: all 0.15s ease;
  margin-bottom: 1px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-nav .nav-sub-btn:hover {
  background: var(--sidebar-hover);
  color: rgba(255, 255, 255, 0.85);
}

.sidebar-nav .nav-sub-btn.active {
  background: rgba(37, 99, 235, 0.2);
  color: white;
}

.sidebar.collapsed .sidebar-nav .nav-sub-btn {
  display: none;
}

/* --- Sidebar Footer --- */
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  text-align: center;
}

.sidebar-footer .sidebar-footer-text {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.2);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-footer .sidebar-footer-text {
  display: none;
}

/* ===== TOP BAR ===== */
.top-bar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:hover { background: var(--border); }

/* Floating hamburger — mobile only */
.mobile-toggle-btn {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 55;
  width: 40px;
  height: 40px;
  background: var(--sidebar-bg);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  transition: background 0.15s ease, opacity 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.mobile-toggle-btn:hover { background: var(--sidebar-hover); }
.mobile-toggle-btn svg { width: 20px; height: 20px; }

.user-dropdown { position: relative; }

.user-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 4px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.user-trigger:hover { border-color: var(--primary-300); background: var(--primary-50); }

.user-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-600);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

/* user-name-top removed — avatar-only display */

.dropdown-arrow {
  color: var(--text-light);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.user-dropdown.open .dropdown-arrow { transform: rotate(180deg); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  display: none;
  z-index: 100;
  overflow: hidden;
  animation: dropdownIn 0.15s ease;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown.open .dropdown-menu { display: block; }

.dropdown-item {
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
  text-align: left;
}

.dropdown-item:hover { background: var(--bg); }

.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }

.dropdown-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.dropdown-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary-600);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.dropdown-user-details {
  flex: 1;
  min-width: 0;
}

.dropdown-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-user-store {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ===== MAIN CONTENT ===== */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  transition: padding 0.3s ease;
}

/* ===== VIEWS ===== */
.view { display: none; }
.view.active { display: block; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.page-header .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1;
  font-family: inherit;
}

.btn-primary { background: var(--primary-600); color: white; }
.btn-primary:hover { background: var(--primary-700); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--primary-400);
  color: var(--primary-600);
  background: var(--primary-50);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-xs); }

.action-group { display: inline-flex; gap: 4px; flex-wrap: nowrap; }
.action-group button { white-space: nowrap; }
.action-group button:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-danger-outline {
  background: transparent;
  border: 1.5px solid var(--danger);
  color: var(--danger);
}
.btn-danger-outline:hover {
  background: var(--danger);
  color: white;
}
.btn-danger-outline:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.card-header h3 { font-size: 16px; font-weight: 600; }

.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-card .stat-change {
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-light);
}

.stat-icon.blue { background: var(--primary-100); color: var(--primary-600); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }

.sub-view { display: none; }
.sub-view.active { display: block; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  background: var(--bg);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

table .empty-state td {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 14px;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

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

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  background: var(--card);
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }

.password-wrapper { position: relative; }
.password-wrapper .form-control { padding-right: 44px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-light);
  transition: all 0.15s ease;
}
.password-toggle:hover { background: var(--bg); color: var(--text-secondary); }
.password-toggle:active { background: var(--border); }

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

.modal-wide { max-width: 640px; }

/* ===== USER DETAIL MODAL ===== */
.user-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.user-detail-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-detail-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.user-detail-username {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.user-detail-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.detail-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
  width: 140px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.detail-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
/* ===== END USER DETAIL ===== */

.modal-settings {
  display: flex;
  min-height: 380px;
  max-height: 65vh;
  padding: 0;
}

.modal-settings-sidebar {
  flex: 0 0 180px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 12px 0;
  overflow-y: auto;
}

.modal-settings-sidebar button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.modal-settings-sidebar button:hover { background: var(--primary-50); color: var(--text); }
.modal-settings-sidebar button.active { background: var(--primary-50); color: var(--primary-600); font-weight: 600; border-right: 3px solid var(--primary-600); }

.modal-settings-content {
  flex: 1;
  min-width: 0;
  padding: 20px 24px;
  overflow-y: auto;
}

[dir="rtl"] .modal-settings-sidebar { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .modal-settings-sidebar button { text-align: right; }
[dir="rtl"] .modal-settings-sidebar button.active { border-right: none; border-left: 3px solid var(--primary-600); }

.modal-confirm { max-width: 380px; }

.avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.avatar-upload .avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--primary-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--primary-600);
  font-weight: 700;
  overflow: hidden;
  border: 3px solid var(--primary-200);
  cursor: pointer;
  transition: var(--transition);
}

.avatar-upload .avatar-preview:hover { border-color: var(--primary-500); }

.avatar-upload .avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-upload input[type="file"] { display: none; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body { padding: 20px; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--primary-600); }

.toast-close { margin-left: auto; cursor: pointer; opacity: 0.8; }
.toast-close:hover { opacity: 1; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ===== BADGE ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: #065f46; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info { background: var(--primary-100); color: var(--primary-800); }

[data-theme="dark"] .badge-success { color: #a7f3d0; }
[data-theme="dark"] .badge-danger { color: #fecaca; }
[data-theme="dark"] .badge-warning { color: #fde68a; }
[data-theme="dark"] .badge-info { color: #93c5fd; }

.badge-role {
  font-size: 11px;
  padding: 2px 10px;
}

.badge-role.admin { background: #e0e7ff; color: #3730a3; }
.badge-role.manager { background: #e0e7ff; color: #3730a3; }
.badge-role.seller { background: var(--warning-bg); color: #92400e; }
.badge-role.warehouse { background: var(--primary-100); color: var(--primary-800); }

[data-theme="dark"] .badge-role.admin,
[data-theme="dark"] .badge-role.manager { background: #312e81; color: #c7d2fe; }
[data-theme="dark"] .badge-role.seller { background: #451a03; color: #fde68a; }
[data-theme="dark"] .badge-role.warehouse { background: #1e3a5f; color: #93c5fd; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state h4 { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 14px; color: var(--text-light); margin-bottom: 16px; }

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-bar .form-control { max-width: 260px; }
.filter-bar .search-input { flex: 1; min-width: 180px; max-width: 320px; }

/* ===== STOCK LEVEL ===== */
.stock-level { display: flex; align-items: center; gap: 8px; }

.stock-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stock-dot.high { background: var(--success); }
.stock-dot.medium { background: var(--warning); }
.stock-dot.low { background: var(--danger); }

.stock-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  flex: 1;
  max-width: 120px;
}

.stock-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.stock-bar-fill.high { background: var(--success); }
.stock-bar-fill.medium { background: var(--warning); }
.stock-bar-fill.low { background: var(--danger); }

/* ===== TABLE CONTROLS (search + per-page) ===== */
.row-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.row-controls .search-input { flex: 1; min-width: 0; }
.per-page-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.per-page-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.per-page-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.per-page-select:focus { border-color: var(--primary); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.pagination-info {
  font-size: 12px;
  color: var(--text-secondary);
}
.pagination-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  transition: all 0.15s ease;
}
.page-btn:hover:not(:disabled):not(.active) {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary);
}
.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.page-ellipsis {
  padding: 0 4px;
  color: var(--text-light);
  font-size: 13px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile: sidebar slides in/out via transform, floating hamburger visible */
@media (max-width: 1023px) {
  .mobile-toggle-btn { display: flex; }
  .mobile-menu-btn { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w) !important;
    height: 100vh;
    z-index: 45;
    transform: translateX(-100%);
    transition: transform 0.2s ease-in-out;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: var(--sidebar-w) !important;
  }

  .sidebar.collapsed .sidebar-brand .brand-text,
  .sidebar.collapsed .sidebar-nav .nav-text {
    display: block;
    opacity: 1;
    width: auto;
  }

  .sidebar.collapsed .sidebar-nav a,
  .sidebar.collapsed .sidebar-nav .nav-btn {
    justify-content: flex-start;
    padding: 10px 14px;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 44;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-backdrop.show { display: block; }

  .main-area { margin-left: 0 !important; }
  .top-bar { padding: 0 12px; height: 50px; }
  .content { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-icon { width: 36px; height: 36px; font-size: 16px; margin-bottom: 10px; }
  .page-header h2 { font-size: 17px; }
  .form-row { grid-template-columns: 1fr; }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 14px; }
  table th, table td { padding: 10px 12px; font-size: 13px; }
  .user-trigger { padding: 3px 5px 3px 3px; }

  /* Login page responsive */
  .login-split { flex-direction: column; }
  .login-hero { flex: none; min-height: 220px; }
  .login-hero-content { padding: 32px 24px; }
  .login-hero-content h1 { font-size: 28px; }
  .login-hero-logo { width: 52px; height: 52px; margin-bottom: 12px; }
  .login-hero-desc { display: none; }
  .login-hero-tagline { font-size: 14px; margin-bottom: 0; }
  .login-form-wrap { padding: 32px 20px; align-items: flex-start; }
  .login-card { padding: 32px 24px 28px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }

  /* Dashboard 2-col jadi 1-col */
  #view-dashboard > div:last-child { grid-template-columns: 1fr !important; }
}

/* Small phones */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 12px; }
  .stat-card .stat-value { font-size: 18px; }
  .content { padding: 10px; }
  .btn { padding: 8px 14px; font-size: 13px; }
  .btn-sm { padding: 5px 10px; font-size: 11px; }
  table th, table td { padding: 8px 10px; font-size: 12px; }
  #toast-container { left: 12px; right: 12px; top: 12px; }
  .toast { min-width: 0; max-width: none; padding: 12px 16px; font-size: 13px; }
  .modal { margin: 10px; }
  .modal-body { padding: 16px; }
  .page-header { margin-bottom: 14px; }
  .page-header h2 { font-size: 16px; }
  .filter-bar .form-control { max-width: 100%; }
  .filter-bar .search-input { max-width: 100%; }
  /* Login extra-small */
  .login-hero { min-height: 160px; }
  .login-hero-content h1 { font-size: 22px; }
  .login-hero-logo { width: 40px; height: 40px; }
  .login-hero-tagline { font-size: 13px; }
  .login-card { padding: 24px 16px 20px; border-radius: 16px; }
  .login-form-title { font-size: 20px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ===== PRINT ===== */
@media print {
  .sidebar, .filter-bar, .btn, .modal-overlay, #toast-container { display: none !important; }
  .view { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .main-area { margin-left: 0 !important; }
}
