/* ==========================================================================
   JIAFLOW PLATFORM ADMIN - DESIGN SYSTEM
   Modern Dark Glassmorphic Aesthetic
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Colors */
  --bg-app: #080c14;
  --bg-sidebar: #0d121f;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(24, 33, 53, 0.85);
  --bg-surface: #111827;
  --bg-input: rgba(15, 23, 42, 0.8);
  --bg-hover: rgba(255, 255, 255, 0.05);

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-card: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(99, 102, 241, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --secondary-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);

  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.3);

  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.3);

  --rose: #f43f5e;
  --rose-bg: rgba(244, 63, 94, 0.12);
  --rose-border: rgba(244, 63, 94, 0.3);

  --sky: #0ea5e9;
  --sky-bg: rgba(14, 165, 233, 0.12);
  --sky-border: rgba(14, 165, 233, 0.3);

  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.3);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.font-mono {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

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

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
}

.btn-glow {
  box-shadow: 0 0 15px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

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

.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 20px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spin-on-click:active {
  animation: spin 0.6s linear;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background: rgba(15, 23, 42, 0.95);
}

.form-input::placeholder {
  color: var(--text-dim);
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-with-icon .form-input {
  padding-left: 42px;
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.password-toggle:hover {
  color: var(--text-primary);
}

.input-with-action {
  display: flex;
  gap: 8px;
}

.input-with-action .form-input {
  flex: 1;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.inline-code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: #e2e8f0;
}

/* ==========================================================================
   BADGES & PILLS
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  line-height: 1.2;
}

.badge-success {
  background: var(--emerald-bg);
  color: #34d399;
  border: 1px solid var(--emerald-border);
}

.badge-warning {
  background: var(--amber-bg);
  color: #fbbf24;
  border: 1px solid var(--amber-border);
}

.badge-danger {
  background: var(--rose-bg);
  color: #fb7185;
  border: 1px solid var(--rose-border);
}

.badge-info {
  background: var(--sky-bg);
  color: #38bdf8;
  border: 1px solid var(--sky-border);
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.dot-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.dot-indicator.active {
  background-color: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  animation: pulse-dot 2s infinite;
}

.dot-indicator.revoked {
  background-color: var(--rose);
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* ==========================================================================
   AUTH / LOGIN PAGE
   ========================================================================== */

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
}

.auth-backdrop {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 60%),
              radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
              var(--bg-app);
  z-index: 0;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: card-appear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes card-appear {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.auth-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.brand-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--primary);
  display: block;
}

.auth-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 22px;
}

.auth-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-tab:hover {
  color: var(--text-primary);
}

.auth-tab.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.auth-helper {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 18px;
  line-height: 1.4;
}

.alert-box {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  margin-bottom: 18px;
}

.alert-box.error {
  background: var(--rose-bg);
  border: 1px solid var(--rose-border);
  color: #fda4af;
}

/* ==========================================================================
   APP LAYOUT (SIDEBAR + MAIN)
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-app);
}

/* Sidebar */
.app-sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: transform var(--transition-normal);
}

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

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 0 15px var(--primary-glow);
}

.brand-title-sm {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  display: block;
  line-height: 1;
}

.brand-sub-sm {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--primary);
  display: block;
  margin-top: 2px;
}

.env-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-full);
  color: #34d399;
}

.env-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #34d399;
  animation: pulse-dot 2s infinite;
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all var(--transition-fast);
}

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

.nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: #ffffff;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-item.active svg {
  color: var(--primary);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.nav-item.active .nav-badge {
  background: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--secondary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  color: #ffffff;
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  width: 100%;
  justify-content: flex-start;
  color: var(--text-muted);
}

.btn-logout:hover {
  color: var(--rose);
  background: var(--rose-bg);
}

/* ==========================================================================
   APP MAIN CONTENT
   ========================================================================== */

.app-main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: 64px;
  background: rgba(13, 18, 31, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

.breadcrumb-root {
  color: var(--text-muted);
  font-weight: 500;
}

.breadcrumb-separator {
  color: var(--text-dim);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Scrollable Container */
.content-scroll {
  padding: 28px;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: tab-enter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-pane.active {
  display: block;
}

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

/* Section Header */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.section-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 260px;
  padding-left: 36px;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 0.875rem;
}

.filter-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
}

.filter-chip.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: #ffffff;
}



/* Panel Card */
.panel-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.panel-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  padding: 20px;
}

.panel-body.no-padding {
  padding: 0;
}



/* ==========================================================================
   DATA TABLES
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  padding: 12px 18px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.text-right {
  text-align: right;
}

.table-empty {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
  font-style: italic;
}

/* Table Item Components */
.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-cell-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
  font-weight: 700;
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-cell-meta {
  display: flex;
  flex-direction: column;
}

.user-cell-name {
  font-weight: 600;
  color: var(--text-primary);
}

.user-cell-email {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-cell-tenant {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-dim);
}

/* Code Cell with Copy Button */
.code-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: 0.03em;
}

.btn-copy-mini {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-copy-mini:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.btn-copy-mini.copied {
  color: var(--emerald) !important;
}

/* Usage Progress Bar */
.usage-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 110px;
}

.usage-text {
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.progress-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-bar.green { background: var(--emerald); }
.progress-bar.amber { background: var(--amber); }
.progress-bar.rose { background: var(--rose); }

/* Table Action Buttons */
.table-actions {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* ==========================================================================
   MODALS
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: modal-bg-fade 0.2s ease;
}

@keyframes modal-bg-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 35px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  animation: modal-card-scale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card-sm {
  max-width: 420px;
}

@keyframes modal-card-scale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
}

.modal-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

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

.modal-form {
  padding: 24px;
}

.seat-presets {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.preset-chip {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.preset-chip.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary);
  color: #ffffff;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-subtle);
}

.modal-footer.centered {
  justify-content: center;
}

/* Success Celebration Modal */
.success-icon-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--emerald-border);
  color: var(--emerald);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 28px auto 14px;
}

.key-display-box {
  background: rgba(0, 0, 0, 0.5);
  border: 1px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 20px 24px;
}

.key-code-large {
  font-size: 1.15rem;
  font-weight: 700;
  color: #c7d2fe;
  letter-spacing: 0.05em;
  word-break: break-all;
  margin-bottom: 14px;
}

.btn-copy-hero {
  padding: 10px 16px;
  font-size: 0.9375rem;
}

.created-key-details {
  padding: 0 24px 20px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ==========================================================================
   DIALOG: CUSTOMER DETAILS (CENTERED DIALOG MODAL)
   ========================================================================== */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modal-bg-fade 0.2s ease;
}

.drawer-panel {
  width: 100%;
  max-width: 1400px;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg), 0 0 50px rgba(0, 0, 0, 0.85);
  animation: modal-card-scale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.drawer-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.drawer-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.drawer-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.drawer-body {
  padding: 24px 28px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.drawer-section {
  margin-bottom: 24px;
}

.drawer-section-title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.info-item {
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.info-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
}

.info-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
  display: block;
  word-break: break-all;
}

.device-card-item {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.device-card-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: #ffffff;
}

.device-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  word-break: break-all;
}

.drawer-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid #b91c1c;
}

.btn-danger:hover {
  background: #b91c1c;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4);
}

.drawer-tab.tab-danger {
  color: #ef4444;
}

.drawer-tab.tab-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.drawer-tab.tab-danger.active {
  background: rgba(239, 68, 68, 0.22);
  color: #ffffff;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: #1e293b;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 380px;
}

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

.toast.toast-out {
  animation: toast-out 0.25s ease forwards;
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

.toast.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
}
.toast.toast-success svg {
  color: var(--emerald);
}

.toast.toast-error {
  border-color: rgba(244, 63, 94, 0.4);
}
.toast.toast-error svg {
  color: var(--rose);
}

.toast.toast-info {
  border-color: rgba(14, 165, 233, 0.4);
}
.toast.toast-info svg {
  color: var(--sky);
}

/* ==========================================================================
   MOBILE & RESPONSIVE BREAKPOINTS
   ========================================================================== */

@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.8);
  }

  .app-main {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .content-scroll {
    padding: 18px;
  }

  .search-input {
    width: 100%;
  }

  .section-actions {
    width: 100%;
  }

  .section-actions .search-input-wrapper {
    flex: 1;
  }

  .drawer-panel {
    max-width: 100%;
  }
}

/* Online organization controls */
.organization-counts {
  font-weight: 600;
  margin-bottom: 8px;
}

.organization-description,
.organization-email,
.organization-delivery {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}

.organization-description {
  margin-bottom: 20px;
}

#organizationsList {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.organization-heading {
  align-items: flex-start;
  gap: 16px;
}

.organization-identity {
  min-width: 0;
}

.organization-identity .panel-title,
.organization-email {
  overflow-wrap: anywhere;
}

.organization-email {
  margin-top: 4px;
}

.organization-usage {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.organization-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.organization-fields {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
}

.organization-fields .form-group {
  min-width: 0;
  margin-bottom: 0;
}

.organization-creation {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  cursor: pointer;
}

.organization-creation input {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.organization-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.organization-delivery {
  overflow-wrap: anywhere;
}

.organization-history {
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.organization-history summary {
  cursor: pointer;
}

.organization-history pre {
  margin-top: 12px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1200px) {
  #organizationsList {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .organization-heading {
    flex-direction: column;
  }

  .organization-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================
   ORGANIZATIONS & BRANCHES TABLE STYLES
   ========================================================================== */

.badge-online {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-offline {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background-color: currentColor;
}

.badge-dot.pulse {
  box-shadow: 0 0 8px currentColor;
  animation: pulse-dot 2s infinite;
}

.org-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.org-cell-name {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
}

.org-cell-sub {
  color: var(--text-muted);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.org-cell-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.branch-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.branch-cell-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.branch-cell-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.table-actions-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  white-space: normal;
}

.status-indicator-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
}

.sync-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.sync-status-badge.synced {
  color: #34d399;
}

.sync-status-badge.pending {
  color: #fbbf24;
}

.sync-status-badge.error {
  color: #fb7185;
}

/* ==========================================================================
   PLANS, SUBSCRIPTIONS & ENHANCED CUSTOMER DRAWER
   ========================================================================== */

.badge-purple {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #c084fc;
}

.badge-cyan {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #22d3ee;
}

.modal-card-lg {
  max-width: 680px;
}

.drawer-tabs {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  overflow-x: auto;
}

.drawer-tab {
  flex: 1;
  min-width: fit-content;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  text-align: center;
}

.drawer-tab:hover {
  color: var(--text-primary);
}

.drawer-tab.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.sub-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color var(--transition-fast);
}

.sub-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.sub-card.active {
  border-left: 3px solid #34d399;
}

.sub-card.expired {
  border-left: 3px solid #f87171;
}

.sub-card.suspended {
  border-left: 3px solid #fbbf24;
}

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

.sub-title {
  font-weight: 700;
  font-size: 0.9375rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sub-meta-item {
  display: flex;
  flex-direction: column;
}

.sub-meta-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sub-meta-val {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  padding-left: 16px;
}

.timeline-list::before {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 5px;
  width: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.timeline-item {
  position: relative;
  font-size: 0.8125rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  top: 5px;
  left: -15px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 2px var(--bg-surface);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timeline-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
}



#modalAddCustomer .modal-card,
#modalCustomerPassword .modal-card,
#modalCustomerLogin .modal-card {
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
}
#modalAddCustomer .modal-card { max-width: 680px; }
#modalAddCustomer .modal-header,
#modalCustomerPassword .modal-header,
#modalCustomerLogin .modal-header { flex-shrink: 0; }
#modalAddCustomer .modal-form,
#modalCustomerPassword .modal-form,
#modalCustomerLogin .modal-body { overflow-y: auto; min-height: 0; }
#modalCustomerLogin .modal-body { padding: 24px; }
#modalAddCustomer .form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 560px) {
  #modalAddCustomer .form-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

.phone-input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.phone-input-group .phone-code-select {
  flex: 0 0 110px;
  width: 110px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  padding: 10px 8px;
  padding-right: 28px;
  background-position: right 8px center;
  font-size: 0.875rem;
  cursor: pointer;
}

.phone-input-group .phone-number-input {
  flex: 1 1 auto;
  min-width: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.phone-input-group .phone-code-select:focus,
.phone-input-group .phone-number-input:focus {
  z-index: 2;
  position: relative;
}


/* Customer actions wrap within the table instead of widening the page. */
#tab-customers .data-table { table-layout: fixed; }
#tab-customers .data-table th,
#tab-customers .data-table td { white-space: normal; overflow-wrap: anywhere; }
#tab-customers .data-table th:nth-child(1) { width: 19%; }
#tab-customers .data-table th:nth-child(2) { width: 15%; }
#tab-customers .data-table th:nth-child(3) { width: 10%; }
#tab-customers .data-table th:nth-child(4) { width: 9%; }
#tab-customers .data-table th:nth-child(5) { width: 9%; }
#tab-customers .data-table th:nth-child(6) { width: 8%; }
#tab-customers .data-table th:nth-child(7) { width: 9%; }
#tab-customers .data-table th:nth-child(8) { width: 21%; }
#tab-customers .table-actions .btn,
#tab-customers .badge { max-width: 100%; white-space: normal; }
#tab-customers .user-cell-meta { min-width: 0; }
#tab-customers .user-cell-avatar { flex-shrink: 0; }
