/* ORMdoo Admin — Obsidian Console Design System */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,600;12..96,700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-primary:      #090e1a;
  --bg-secondary:    #090e1a;
  --bg-card:         #0f1729;
  --bg-card-hover:   #1a2744;
  --bg-input:        #0d1e38;
  --bg-sidebar:      #07091a;
  --border-color:    #1e2d4a;
  --text-primary:    #f0f6ff;
  --text-secondary:  #7e9ab8;
  --text-muted:      #3d5a7a;
  --accent-blue:     #38bdf8;
  --accent-green:    #34d399;
  --accent-yellow:   #fb923c;
  --accent-red:      #f87171;
  --accent-cyan:     #38bdf8;
  --accent-purple:   #818cf8;
  --sidebar-width:   220px;
  --topbar-height:   60px;
}

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

body {
  font-family: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

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

.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand-text {
  min-width: 0;
}

.sidebar-brand-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-brand-sub {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 600;
}

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

.sidebar-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 10px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.sidebar-item:hover {
  background: rgba(56, 189, 248, 0.06);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-blue);
  border-left: 3px solid var(--accent-blue);
  padding-left: 9px;
  font-weight: 600;
}

.sidebar-item.danger {
  color: var(--accent-red);
}

.sidebar-item.danger:hover {
  background: rgba(248, 113, 113, 0.08);
  color: var(--accent-red);
}

.sidebar-item-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 10px 8px 16px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 199;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.open {
  display: block;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border-color);
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Brand (legacy — kept for auth page and any non-sidebar template) */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-dot {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-dot::after {
  content: 'O';
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.brand-text .eyebrow {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 600;
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

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

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

.btn.primary {
  background: var(--accent-blue);
  color: #07091a;
}

.btn.primary:hover {
  background: #7dd3fc;
}

.btn.danger {
  background: var(--accent-red);
  color: white;
}

.btn.danger:hover {
  background: #fca5a5;
  color: #07091a;
}

.btn.sm {
  padding: 5px 11px;
  font-size: 12px;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 6px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-blue);
  color: #07091a;
}

.btn-primary:hover {
  background: #7dd3fc;
}

.btn-warning {
  background: var(--accent-yellow);
  color: #07091a;
}

.btn-warning:hover {
  background: #fdba74;
}

.btn-info {
  background: var(--accent-cyan);
  color: #07091a;
}

.btn-info:hover {
  background: #7dd3fc;
}

.btn-success {
  background: var(--accent-green);
  color: #07091a;
}

.btn-success:hover {
  background: #6ee7b7;
}

.btn-danger {
  background: var(--accent-red);
  color: white;
}

.btn-danger:hover {
  background: #fca5a5;
  color: #07091a;
}

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

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.main-content.grid-2 {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  max-width: 1400px;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 22px 24px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.25);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
}

.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 34px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-family: 'JetBrains Mono', monospace;
}

.stat-card:nth-child(1) .value { color: var(--accent-blue); }
.stat-card:nth-child(2) .value { color: var(--accent-green); }
.stat-card:nth-child(3) .value { color: var(--accent-yellow); }
.stat-card:nth-child(4) .value { color: var(--accent-purple); }

/* ============================================
   CARD PANEL
   ============================================ */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
}

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

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-header .hint {
  font-size: 12px;
  color: var(--text-muted);
}

.card-body {
  padding: 22px;
}

/* ============================================
   TABLE ACTIONS
   ============================================ */
.table-actions {
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ============================================
   TABLE STYLES
   ============================================ */
.table-container {
  overflow-x: auto;
}

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

thead {
  background: var(--bg-secondary);
}

thead th {
  padding: 12px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background 0.12s ease;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

tbody td {
  padding: 15px 20px;
  vertical-align: middle;
  font-size: 13px;
  color: var(--text-secondary);
}

tbody td:not(:last-child) {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody td:last-child {
  white-space: normal;
  min-width: 320px;
}

/* ============================================
   INSTANCE NAME
   ============================================ */
.instance-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.instance-link {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: color 0.15s ease;
  font-family: 'JetBrains Mono', monospace;
}

.instance-link:hover {
  color: #7dd3fc;
  text-decoration: underline;
}

.instance-name .icon-link {
  font-size: 13px;
  opacity: 0.6;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.badge-version {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.badge-production {
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.badge-staging {
  background: rgba(251, 146, 60, 0.12);
  color: #fdba74;
  border: 1px solid rgba(251, 146, 60, 0.25);
}

.badge-active {
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.badge-inactive {
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.badge.success {
  background: rgba(52, 211, 153, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.badge.danger {
  background: rgba(248, 113, 113, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.badges-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ============================================
   ACTION BUTTONS GROUP
   ============================================ */
.actions-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.action-stack {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* ============================================
   FORM STYLES
   ============================================ */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.form-input,
.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 7px;
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.form-input::placeholder,
.form-control::placeholder {
  color: var(--text-muted);
}

.form-group small {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Checkbox */
input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 11px 14px;
  background: var(--bg-input);
  border-radius: 7px;
  border: 1px solid var(--border-color);
  transition: border-color 0.15s ease;
}

.checkbox-line:hover {
  border-color: var(--accent-blue);
}

.checkbox-line span {
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* Toggle Switch */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle input[type="checkbox"] {
  width: 40px;
  height: 22px;
  appearance: none;
  background: var(--border-color);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: left 0.2s ease;
}

.toggle input[type="checkbox"]:checked {
  background: var(--accent-green);
}

.toggle input[type="checkbox"]:checked::before {
  left: 20px;
}

.toggle span {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}

.form-actions .btn {
  padding: 10px 20px;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
  padding: 14px 16px;
  border-radius: 8px;
  margin: 14px 0;
  font-size: 13.5px;
}

.alert-warning {
  background: rgba(251, 146, 60, 0.08);
  border: 1px solid rgba(251, 146, 60, 0.25);
  color: #fdba74;
}

.alert-info {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #7dd3fc;
}

.alert strong {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.alert ul {
  margin: 0;
  padding-left: 18px;
}

.alert li {
  margin: 4px 0;
  font-size: 13px;
}

/* ============================================
   MODAL STYLES
   ============================================ */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.modal-content {
  background: var(--bg-card);
  margin: 5% auto;
  border-radius: 14px;
  width: 90%;
  max-width: 700px;
  border: 1px solid var(--border-color);
  box-shadow: 0 24px 48px -12px rgb(0 0 0 / 0.55);
  animation: slideIn 0.25s ease;
  overflow: hidden;
}

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

.modal-header h2,
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-header h3 span {
  color: var(--accent-blue);
  font-family: 'JetBrains Mono', monospace;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

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

.modal-body {
  padding: 22px;
  max-height: 60vh;
  overflow-y: auto;
}

/* Config modal pre (code blocks) */
.modal-body pre {
  background: #050912;
  color: #a8c8f0;
  padding: 18px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
  border: 1px solid var(--border-color);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 44px;
  margin-bottom: 14px;
  opacity: 0.7;
}

.empty-state p {
  font-size: 14.5px;
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

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

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   AUTH PAGE (LOGIN)
   ============================================ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(ellipse at 30% 40%, rgba(56, 189, 248, 0.04) 0%, transparent 60%),
              var(--bg-secondary);
}

.auth-page .shell {
  width: 100%;
  max-width: 400px;
}

.auth-page .brand {
  justify-content: center;
  margin-bottom: 28px;
}

.auth-page .card {
  padding: 30px;
}

.auth-page .card h2 {
  font-size: 19px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 22px;
  text-align: center;
}

.auth-page .card form label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.auth-page .card form input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 7px;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-page .card form input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.auth-page .card form input::placeholder {
  color: var(--text-muted);
}

.auth-page .card form .btn {
  width: 100%;
  padding: 12px 20px;
  margin-top: 6px;
}

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

  .main-content.grid-2 {
    grid-template-columns: 1fr;
  }

  .nav-actions {
    gap: 8px;
  }

  .btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* ============================================
   RESPONSIVE — MOBILE (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
  /* Sidebar collapses to drawer */
  .sidebar {
    transform: translateX(-100%);
  }

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

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

  .sidebar-toggle {
    display: flex;
  }

  /* Topbar */
  .topbar {
    padding: 0 16px;
    height: auto;
    min-height: 56px;
    gap: 10px;
  }

  .main-content {
    padding: 16px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  thead th,
  tbody td {
    padding: 11px 12px;
  }

  .badges-group {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-actions {
    flex-wrap: wrap;
  }

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }

  .table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28px;
    background: linear-gradient(to left, var(--bg-card), transparent);
    pointer-events: none;
    opacity: 0.8;
  }

  .modal-content {
    width: 95%;
    margin: 2% auto;
    max-height: 90vh;
    border-radius: 12px;
  }

  .modal-body {
    padding: 16px;
    max-height: 70vh;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-header h2,
  .modal-header h3 {
    font-size: 15px;
  }

  .actions-group, .action-stack {
    gap: 6px;
  }

  .btn.sm, .btn-sm {
    padding: 5px 8px;
    font-size: 11px;
  }

  .brand-text h1 {
    font-size: 16px;
  }

  .card-header h2 {
    font-size: 15px;
  }

  .stat-card .value {
    font-size: 26px;
  }

  .stat-card {
    padding: 16px;
  }

  .card-body {
    padding: 16px;
  }

  .card-header {
    padding: 14px 16px;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .tabs-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    white-space: nowrap;
  }
}

/* ============================================
   MOBILE STYLES (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
  .card-body {
    padding: 0 !important;
  }

  .table-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .table-container::after {
    display: none !important;
  }

  table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
  }

  thead {
    display: none !important;
  }

  tbody {
    display: block !important;
    width: 100% !important;
  }

  tbody tr {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    padding: 16px;
    margin-bottom: 10px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-sizing: border-box !important;
  }

  tbody tr:hover {
    background: var(--bg-card-hover);
  }

  tbody td {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    padding: 8px 0 !important;
    border-bottom: 1px solid var(--border-color);
    max-width: none !important;
    white-space: normal !important;
    text-overflow: initial !important;
    overflow: visible !important;
    width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
  }

  tbody td:last-child {
    border-bottom: none !important;
    min-width: auto !important;
    padding-top: 12px !important;
    display: block !important;
    width: 100% !important;
  }

  tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    margin-right: 12px;
    min-width: 80px;
  }

  tbody td:last-child::before {
    display: none;
  }

  tbody td:last-child .actions-group,
  tbody td:last-child .action-stack {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 8px !important;
  }

  tbody td:last-child .actions-group .btn,
  tbody td:last-child .action-stack .btn,
  tbody td:last-child .actions-group button,
  tbody td:last-child .action-stack button,
  .actions-group .btn.btn-sm,
  .actions-group button.btn-sm {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }

  .modal-content {
    width: 100%;
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
    max-height: 100vh;
  }

  .modal-body {
    max-height: calc(100vh - 70px);
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .form-group {
    margin-bottom: 14px;
  }

  .form-input,
  .form-control {
    padding: 10px 12px;
  }

  .actions-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .actions-group .btn,
  .actions-group button {
    width: 100% !important;
    justify-content: center !important;
    display: flex !important;
    box-sizing: border-box !important;
  }

  .action-stack {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .action-stack .btn,
  .action-stack button {
    width: 100% !important;
    justify-content: center !important;
    display: flex !important;
    box-sizing: border-box !important;
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .stat-card .value {
    font-size: 22px;
  }

  .stat-card .label {
    font-size: 10px;
  }

  .main-content {
    padding: 10px;
  }

  .stat-card {
    padding: 12px;
  }

  .empty-state {
    padding: 38px 16px;
  }

  .topbar {
    padding: 10px 14px;
  }

  .logo-dot {
    width: 30px;
    height: 30px;
  }

  .logo-dot::after {
    font-size: 15px;
  }

  .brand-text .eyebrow {
    font-size: 9px;
  }

  .nav-actions .btn {
    padding: 5px 9px;
    font-size: 11px;
  }

  .auth-page .card {
    padding: 20px;
  }

  .auth-page .card h2 {
    font-size: 17px;
  }

  .badges-group {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
  }

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

  .instance-name {
    justify-content: flex-end;
  }

  .instance-link {
    font-size: 13px;
  }

  .table-actions {
    padding: 10px;
    flex-direction: column;
    align-items: stretch;
  }

  .table-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .card {
    border-radius: 8px;
  }

  .stats-grid {
    gap: 10px;
    margin-bottom: 14px;
  }
}

/* ============================================
   SMALL MOBILE (max-width: 375px — iPhone SE)
   ============================================ */
@media (max-width: 375px) {
  .brand {
    gap: 8px;
  }

  .logo-dot {
    width: 28px;
    height: 28px;
  }

  .logo-dot::after {
    font-size: 13px;
  }

  .brand-text h1 {
    font-size: 14px;
  }

  .brand-text .eyebrow {
    font-size: 9px;
  }

  .nav-actions {
    gap: 6px;
  }

  .nav-actions .btn {
    padding: 5px 8px;
    font-size: 10px;
  }

  .main-content {
    padding: 8px;
  }

  .stat-card {
    padding: 10px;
  }

  .stat-card .value {
    font-size: 19px;
  }

  .stat-card .label {
    font-size: 9px;
  }

  .card-header h2 {
    font-size: 13px;
  }

  tbody td {
    font-size: 12px;
  }

  tbody td::before {
    font-size: 10px;
    min-width: 70px;
  }

  .btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  .btn.sm, .btn-sm {
    padding: 4px 6px;
    font-size: 10px;
  }

  .modal-header h2,
  .modal-header h3 {
    font-size: 13px;
  }

  .modal-body {
    padding: 12px;
  }

  .form-input,
  .form-control {
    padding: 8px 10px;
    font-size: 13px;
  }

  .auth-page .card {
    padding: 16px;
  }

  .auth-page .card h2 {
    font-size: 15px;
    margin-bottom: 18px;
  }
}

/* ============================================
   TOUCH TARGETS — min 44px on mobile
   ============================================ */
@media (max-width: 768px) {
  .btn, .btn-sm, .btn.sm {
    min-height: 44px;
    min-width: 44px;
  }

  .modal-close, .btn-close {
    min-width: 44px;
    min-height: 44px;
  }

  .toggle input[type="checkbox"] {
    min-width: 44px;
    min-height: 28px;
  }

  input[type="checkbox"] {
    min-width: 24px;
    min-height: 24px;
  }
}

/* ============================================
   LANDSCAPE ORIENTATION
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-content {
    margin: 1% auto;
    max-height: 95vh;
  }

  .modal-body {
    max-height: 70vh;
  }

  .auth-page {
    padding: 10px;
  }
}

/* ============================================
   TABS
   ============================================ */
.tabs-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  bottom: -2px;
}

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

.tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: tabFadeIn 0.25s ease;
}

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

/* ============================================
   FILTERS ROW
   ============================================ */
.filters-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#pageInfo {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ============================================
   EMAIL DETAILS
   ============================================ */
.email-details {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-color);
}

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

.detail-row strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.message-box {
  background: var(--bg-input);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.error-box {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  padding: 12px;
  border-radius: 6px;
  color: var(--accent-red);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* CASCADE INTENTIONNELLE — cette déclaration écrase padding:22px ci-dessus */
.modal-body {
  padding: 0;
}

/* ============================================
   EMAIL MODAL (users.html)
   ============================================ */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: modalFadeIn 0.2s ease-out;
}

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

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

textarea.form-input,
textarea.form-control {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .modal {
    padding: 10px;
  }

  .modal-content {
    padding: 16px;
  }
}

/* ============================================
   ADMIN PASSWORD DISPLAY
   ============================================ */
.admin-passwd {
  display: inline-block;
  padding: 5px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--accent-cyan);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: all;
  letter-spacing: 0.04em;
}

.admin-passwd:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.12);
}

.admin-passwd:active {
  transform: scale(0.98);
}

/* ============================================
   LANGUAGE SWITCH
   ============================================ */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  border-left: 1px solid var(--border-color);
  padding-left: 12px;
}

.lang-switch form { display: inline; margin: 0; }

.lang-switch button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  padding: 3px 7px;
  cursor: pointer;
  transition: all 0.12s ease;
  letter-spacing: 0.04em;
}

.lang-switch button:hover {
  border-color: var(--border-color);
  color: var(--text-primary);
}

.lang-switch button.lang-active {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.text-muted {
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================
   INSTANCE CARDS GRID
   ============================================ */
.instance-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

@media (max-width: 768px) {
  .instance-grid { gap: 10px; padding: 12px; }
}

.icard {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 11px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.icard:hover {
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.08);
}

.icard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.icard-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Status dot */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--accent-green);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.2);
}

.status-dot.inactive {
  background: var(--accent-red);
}

.status-dot.provisioning {
  background: var(--accent-yellow);
  animation: dotpulse 1.4s ease-in-out infinite;
}

@keyframes dotpulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.icard-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.icard-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: -4px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

/* Password access section */
.icard-access {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.pwd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  min-height: 28px;
}

.pwd-label {
  color: var(--text-muted);
  min-width: 46px;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pwd-val {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--accent-cyan);
  letter-spacing: 0.06em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.pwd-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Icon-only buttons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.12s ease;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  color: var(--text-primary);
}

.btn-icon.danger:hover {
  border-color: var(--accent-red);
  background: rgba(248, 113, 113, 0.08);
  color: var(--accent-red);
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Card action bar */
.action-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.action-sep {
  flex: 1;
}

/* Empty state */
.icard-empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
  font-size: 14.5px;
}

/* ============================================
   SERVER SECTIONS
   ============================================ */
.iserver-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 13px;
  overflow: hidden;
}

.iserver-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.iserver-icon { font-size: 0.95rem; }

.iserver-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.iserver-domain {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.iserver-count {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 9px;
  border-radius: 20px;
}

.iserver-body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 14px;
  align-items: start;
}

@media (max-width: 1200px) { .iserver-body { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .iserver-body { grid-template-columns: 1fr; gap: 10px; } }

/* Production + its stagings: a flex column in one grid cell */
.iprod-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Staging cards in the same column, below the production */
.istaging-nest {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(251, 146, 60, 0.28);
}

/* URL line in card */
.icard-url {
  font-size: 12px;
  margin-top: -6px;
}

.icard-url a {
  color: var(--accent-cyan);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  word-break: break-all;
}

.icard-url a:hover { text-decoration: underline; }

.icard--staging {
  border-left: 3px solid var(--accent-yellow);
  opacity: 0.92;
}

/* ============================================
   MODAL FIELDSET SECTIONS
   ============================================ */
fieldset.form-section {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

fieldset.form-section legend {
  padding: 0 7px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--accent-blue);
}

fieldset.form-section .form-group:last-child {
  margin-bottom: 0;
}

/* Touch targets for icon buttons on mobile */
@media (max-width: 768px) {
  .btn-icon {
    width: 40px;
    height: 40px;
    font-size: 15px;
    min-width: 40px;
    min-height: 40px;
  }

  .icard {
    padding: 14px;
  }
}
