 :root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f8fa;
  --surface: #ffffff;
  --surface-subtle: #f6f7fb;
  --border: #e5e7eb;
  --text-primary: #111111;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --brand: #3728aacc;
  --brand-solid: #3728aa;
  --brand-hover: #2d208c;
 }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ===== LOGIN PAGE ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.login-container {
  text-align: center;
}

.login-logo {
  margin-bottom: 2rem;
}

.brand-logo {
  display: block;
  width: auto;
  object-fit: contain;
}

.login-logo .brand-logo {
  height: 56px;
  margin: 0 auto;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 420px;
  text-align: left;
  box-shadow: 0 12px 32px rgba(17, 17, 17, 0.08);
}

.login-card h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.password-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.forgot-link {
  font-size: 0.8rem;
  color: var(--text-primary);
  text-decoration: underline;
}

.form-group input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  color: var(--text-primary);
  background: var(--surface);
}

.form-group input:focus {
  border-color: var(--brand-solid);
}

.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  color: var(--text-primary);
  background: var(--surface);
}

.form-group textarea {
  resize: vertical;
  min-height: 96px;
}

.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--brand-solid);
}

.btn-login {
  width: auto;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  margin-top: 0.5rem;
}

.btn-login:hover {
  background: var(--brand-solid);
  transform: translateY(-1px);
}

.btn-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-card .btn-login {
  width: 100%;
  display: block;
}

.error-msg {
  background: #fef2f2;
  color: #dc2626;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid #fecaca;
}

.success-msg {
  background: #f0fdf4;
  color: #166534;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid #bbf7d0;
}

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
}

.sidebar-logo {
  margin-bottom: 2rem;
  padding-left: 0.5rem;
}

.sidebar-logo .brand-logo {
  height: 34px;
}

.sidebar-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(55, 40, 170, 0.1);
  color: var(--text-primary);
  font-weight: 600;
}

/* ===== MAIN ===== */
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 0 2rem 2rem;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.topbar-right {
  position: relative;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  position: relative;
  font-size: 0.9rem;
}

.user-menu:hover {
  background: var(--surface-subtle);
}

.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 120px;
  z-index: 100;
}

.dropdown.show {
  display: block;
}

.dropdown a {
  display: block;
  padding: 0.6rem 1rem;
  text-decoration: none;
  color: #dc2626;
  font-size: 0.9rem;
}

.dropdown a:hover {
  background: #fef2f2;
}

/* ===== PAGES ===== */
.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--brand-solid);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-secondary {
  background: #eef2ff;
  color: var(--brand-solid);
  border: 1px solid rgba(55, 40, 170, 0.18);
}

.btn-secondary:hover {
  background: #e0e7ff;
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid rgba(55, 40, 170, 0.22);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: 0 8px 20px rgba(17, 17, 17, 0.04);
}

.stat-card svg {
  color: var(--brand-solid);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

/* ===== TABLE ===== */
.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.table-controls-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  width: 250px;
  outline: none;
}

.search-input:focus {
  border-color: var(--brand-solid);
}

.group-filter {
  min-width: 180px;
}

.rows-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.rows-control select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  color: var(--text-primary);
  background: var(--surface);
}

.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

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

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.data-table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text-secondary);
}

.data-table tbody tr:hover {
  background: var(--surface-subtle);
}

.data-table a {
  color: var(--brand-solid);
  word-break: break-word;
}

.loading-cell {
  text-align: center;
  padding: 2rem !important;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--brand-solid);
}

/* ===== STATUS BADGE ===== */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active {
  background: #dcfce7;
  color: #166534;
}

.badge-deactivated {
  background: #fee2e2;
  color: #991b1b;
}

/* ===== ACTION BUTTON ===== */
.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.2rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  position: relative;
}

.action-btn:hover {
  background: var(--surface-subtle);
}

.action-dropdown {
  display: none;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 155px;
  z-index: 1000;
}

.action-dropdown.show {
  display: block;
}

.action-dropdown a {
  display: block;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.action-dropdown a:hover {
  background: var(--surface-subtle);
}

/* ===== ACTION LINK ===== */
.action-link {
  background: none;
  border: none;
  color: var(--brand-solid);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0;
}

.action-link:hover {
  color: var(--brand-hover);
}

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: toast-in 0.3s ease forwards, toast-out 0.4s ease 2.6s forwards;
  max-width: 320px;
  font-weight: 500;
}

.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: var(--brand-solid); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; pointer-events: none; }
}

/* ===== CUSTOM CONFIRM MODAL ===== */
#confirmModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8000;
}

#confirmModal.show {
  display: flex;
}

.confirm-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  text-align: center;
}

.confirm-box p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.btn-confirm-cancel {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.btn-confirm-cancel:hover { background: var(--surface-subtle); }

.btn-confirm-ok {
  padding: 0.5rem 1.25rem;
  border: none;
  background: #dc2626;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
}

.btn-confirm-ok:hover { background: #b91c1c; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.page-btn {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  color: #374151;
}

.page-btn:hover {
  background: #f3f4f6;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== 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;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  width: 400px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-lg {
    /* min-width: 600px; */
    width: auto;
}

.modal h3 {
  margin-bottom: 0.75rem;
}

.modal p {
  color: #6b7280;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.modal select {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.status-modal-actions {
  display: block;
}

.btn-cancel {
  padding: 0.5rem 1.25rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-cancel:hover {
  background: #f3f4f6;
}

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

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6b7280;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.9rem;
}

.detail-label {
  color: #6b7280;
}

.detail-value {
  font-weight: 600;
}

.detail-section {
  margin-top: 1rem;
}

.detail-section h4 {
  margin-bottom: 0.5rem;
  color: #374151;
}

.partner-controls {
  align-items: flex-end;
}

.partner-select {
  min-width: 160px;
}

.partner-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.partner-selected {
  color: var(--text-primary);
  font-weight: 600;
}

.partner-table td {
  vertical-align: top;
}

.partner-description {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.partner-description-full {
  white-space: pre-wrap;
  line-height: 1.55;
  color: var(--text-secondary);
}

.partner-muted {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.partner-detail-body {
  display: grid;
  gap: 0.75rem;
}

.partner-detail-grid {
  display: grid;
  gap: 0.5rem;
}

.partner-modal {
  width: min(840px, 94vw);
}

.checkbox-cell {
  width: 42px;
}

.checkbox-cell input {
  width: 16px;
  height: 16px;
}

@media (max-width: 900px) {
  .partner-controls {
    align-items: stretch;
  }

  .partner-meta {
    align-items: flex-start;
  }

  .partner-description {
    max-width: 220px;
  }
}
.dashboard-header{display: flex; justify-content: space-between; align-items: top; margin-bottom: 10px;}

#createUserBtn,
#createUserBtnTop{max-width: 200px; height: 40px; }
.section-title{margin-bottom: 20px;}

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

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
