:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-bg: rgba(99,102,241,0.08);
  --success: #10b981;
  --success-bg: rgba(16,185,129,0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,0.1);
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--gray-50); color: var(--gray-800); line-height: 1.5; }

/* Header */
.header {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  color: white;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: 14px; }
.header-logo {
  width: 42px; height: 42px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
  backdrop-filter: blur(10px);
}
.header h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.header .subtitle { font-size: 12px; opacity: 0.6; font-weight: 400; margin-top: 1px; }
.header-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; opacity: 0.7;
}
.header-dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
}
.nav-tab {
  padding: 10px 24px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}
.nav-tab:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.05);
}
.nav-tab.active {
  color: white;
  border-bottom-color: var(--primary-light);
}

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tab Panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Buttons */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 1px 2px rgba(99,102,241,0.3); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(99,102,241,0.4); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--gray-500); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 8px; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--gray-800); display: flex; align-items: center; gap: 8px; }
.card-header .icon { font-size: 18px; }
.card-body { padding: 20px; }

/* Section Title */
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-400);
  margin-bottom: 12px;
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 768px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  padding: 18px 20px;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: var(--gray-800); font-variant-numeric: tabular-nums; }
.stat-card .stat-label { font-size: 12px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* Company Info */
.company-grid { display: grid; grid-template-columns: 100px 1fr; gap: 8px 16px; align-items: center; }
.company-label { font-size: 12px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; }
.company-value { font-size: 14px; color: var(--gray-700); font-weight: 500; }
.company-value.empty { color: var(--gray-300); font-style: italic; font-weight: 400; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
td { padding: 14px 20px; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr { transition: background 0.1s; }
tr:hover td { background: var(--primary-bg); }
.td-id { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; font-weight: 600; color: var(--gray-700); }
.td-name { color: var(--gray-600); }
.td-date { font-size: 12px; color: var(--gray-400); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-no { background: var(--gray-100); color: var(--gray-400); }
.badge-demo { background: var(--warning-bg); color: var(--warning); }
.badge-prod { background: #ede9fe; color: #7c3aed; }

/* Status indicator */
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-online .status-dot { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.status-online { color: var(--success); }
.status-away .status-dot { background: var(--warning); }
.status-away { color: var(--warning); }
.status-offline .status-dot { background: var(--gray-300); }
.status-offline { color: var(--gray-400); }

.actions { display: flex; gap: 4px; }

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar-count { font-size: 13px; color: var(--gray-500); font-weight: 500; }

/* Empty State */
.empty-state { text-align: center; padding: 56px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; color: var(--gray-400); margin-bottom: 20px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: white;
  border-radius: 16px;
  width: 580px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 { font-size: 18px; font-weight: 700; color: var(--gray-800); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--gray-50);
}
.close-btn {
  width: 32px; height: 32px;
  background: var(--gray-100);
  border: none;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.close-btn:hover { background: var(--gray-200); color: var(--gray-700); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--gray-800);
  background: white;
  transition: all 0.15s;
}
.form-group input::placeholder { color: var(--gray-300); }
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-group input:disabled { background: var(--gray-50); color: var(--gray-400); }
.form-section {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary);
  margin: 24px 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary-bg);
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-section:first-child { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Company Edit Form */
.company-edit-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.company-edit-row label { min-width: 110px; font-size: 12px; font-weight: 600; color: var(--gray-500); }
.company-edit-row input {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--gray-800);
  transition: all 0.15s;
}
.company-edit-row input::placeholder { color: var(--gray-300); }
.company-edit-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 10px;
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes toastIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Refresh Bar */
.refresh-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.refresh-bar label { font-weight: 600; color: var(--gray-500); font-size: 12px; white-space: nowrap; }
.refresh-bar select {
  padding: 5px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  color: var(--gray-700);
  background: white;
  cursor: pointer;
}
.refresh-bar select:focus { outline: none; border-color: var(--primary); }
.refresh-countdown {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-400);
  font-size: 12px;
  margin-left: auto;
}
.refresh-countdown .countdown-bar {
  width: 80px;
  height: 4px;
  background: var(--gray-100);
  border-radius: 2px;
  overflow: hidden;
}
.refresh-countdown .countdown-fill {
  height: 100%;
  background: var(--primary-light);
  border-radius: 2px;
  transition: width 1s linear;
}
.btn-refresh {
  background: var(--primary-bg);
  color: var(--primary);
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-refresh:hover { background: var(--primary); color: white; }
.btn-refresh.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Warnings */
.warnings-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.warnings-card .warning-icon { font-size: 20px; }
.warnings-card .warning-text { font-size: 13px; color: var(--gray-500); font-weight: 500; }

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--gray-400);
}
.footer a { color: var(--primary-light); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
