:root {
  --primary: #0066FF;
  --primary-hover: #0052CC;
  --primary-light: #E6F0FF;
  --success: #00C853;
  --warning: #FFB300;
  --danger: #FF3D00;
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --bg-body: #F3F4F6;
  --bg-card: #FFFFFF;
  --border: #E5E7EB;
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  position: relative;
}
.login-card {
  background: var(--bg-card);
  padding: 48px;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: fadeIn 0.5s ease-out;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.login-logo p {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 14px;
}
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: all 0.2s;
  outline: none;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  gap: 8px;
}
.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,102,255,0.3);
}
.lang-switcher {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  gap: 8px;
  z-index: 2;
}
.lang-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.lang-btn.active, .lang-btn:hover {
  background: rgba(255,255,255,0.3);
}

/* Admin Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover, .nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}
.nav-icon {
  width: 20px;
  height: 20px;
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-item.active .nav-icon, .nav-item:hover .nav-icon {
  opacity: 1;
}
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}
.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-search input {
  width: 320px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}
.header-search input:focus {
  border-color: var(--primary);
  width: 360px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.user-menu:hover {
  background: var(--bg-body);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}
.content-area {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 16px;
  background: #fafbfc;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.filter-bar .filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-bar .filter-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.filter-bar .filter-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
  min-width: 160px;
  background: #fff;
}
.filter-bar .filter-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22,119,255,0.1);
}
.filter-bar .filter-select {
  padding: 7px 30px 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 8px center;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  min-width: 120px;
}
.filter-bar .filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}
.filter-bar .btn-filter {
  padding: 7px 16px;
  font-size: 13px;
  white-space: nowrap;
  width: auto;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}
.page-header .btn-primary {
  width: auto;
  padding: 10px 20px;
  font-size: 14px;
}

/* Cards & Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.stat-change {
  font-size: 13px;
  font-weight: 500;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Tables */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: 14px 24px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg-body);
}
.data-table td {
  padding: 16px 24px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td {
  border-bottom: none;
}
.data-table tr:hover td {
  background: var(--bg-body);
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success {
  background: #E8F5E9;
  color: #2E7D32;
}
.badge-warning {
  background: #FFF3E0;
  color: #EF6C00;
}
.badge-danger {
  background: #FFEBEE;
  color: #C62828;
}
.badge-default {
  background: #F5F5F5;
  color: #616161;
}
.badge-info {
  background: #E0F2FE;
  color: #0369A1;
}

/* Form Layout */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* Tabs */
.tab-bar {
  background: #FAFBFC;
}
.tab-item {
  padding: 14px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.tab-item:hover {
  color: var(--primary);
}
.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #fff;
  font-weight: 600;
}

/* Buttons */
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.btn-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-outline:disabled:hover {
  border-color: var(--border);
  color: var(--text-secondary);
  background: transparent;
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-success {
  background: var(--success);
  color: white;
}

/* Permission Groups */
.perm-group {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
  transform: scale(0.95);
  transition: transform 0.2s;
  overflow: hidden;
}
.modal-overlay.active .modal {
  transform: scale(1);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

/* QR Code Page (Consumer) */
.qr-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #E8F0FE 0%, #F5F7FA 100%);
  padding: 24px;
}
.qr-device {
  background: white;
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  animation: fadeIn 0.5s ease-out;
}
.qr-device-header {
  background: #0066FF;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.qr-device-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-size: 20px;
  font-weight: 700;
}
.qr-device-header .lang-select {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.qr-device-body {
  padding: 32px;
  text-align: center;
}
.qr-merchant-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 24px;
}
.qr-code-box {
  background: white;
  padding: 20px;
  border-radius: 16px;
  border: 2px solid #E8F0FE;
  margin-bottom: 24px;
  display: inline-block;
}
.qr-code-box canvas, .qr-code-box img {
  width: 240px;
  height: 240px;
  display: block;
}
.qr-amount-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 18px;
  text-align: center;
  margin-bottom: 16px;
  outline: none;
  transition: all 0.2s;
}
.qr-amount-input:focus {
  border-color: var(--primary);
}
.qr-pay-btn {
  width: 100%;
  padding: 16px;
  background: #0066FF;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.qr-pay-btn:hover {
  background: #0052CC;
}
.qr-device-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fadeIn 0.3s ease-out;
}

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--text-primary);
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 300;
  transform: translateX(120%);
  transition: transform 0.3s ease-out;
}
.toast.show {
  transform: translateX(0);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .header-search input {
    width: 160px;
  }
  .content-area {
    padding: 20px;
  }
}
