/* Reset & Base Variables */
:root {
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #ffffff;
  --border-color: #e2e8f0;
  
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #06b6d4;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

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

.logo-icon {
  font-size: 26px;
}

.logo-text h2 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-sidebar);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.nav-icon {
  font-size: 16px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.server-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-indicator.online {
  background: var(--color-success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-title {
  font-size: 12px;
  font-weight: 600;
  color: #f1f5f9;
}

.status-sub {
  font-size: 11px;
  color: #64748b;
}

/* MAIN CONTENT */
.main-content {
  flex-grow: 1;
  padding: 30px 40px;
  overflow-y: auto;
  max-width: 1400px;
}

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

.header-left h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

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

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

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

.btn-secondary {
  background-color: #fff;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: #f1f5f9;
}

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

.btn-action-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.btn-action {
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
}

.btn-action:hover {
  background: #e2e8f0;
}

.btn-action-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.btn-action-success:hover {
  background: #d1fae5;
}

.btn-action-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.btn-action-danger:hover {
  background: #fee2e2;
}

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

.stat-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

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

.stat-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.bg-blue { background: #eff6ff; }
.bg-green { background: #ecfdf5; }
.bg-amber { background: #fffbeb; }
.bg-red { background: #fef2f2; }

.stat-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -1px;
}

.text-green { color: var(--color-success); }
.text-amber { color: var(--color-warning); }
.text-red { color: var(--color-danger); }

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* CARDS & PANELS */
.tab-pane {
  display: none;
}

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

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

.card-body.p-0 {
  padding: 0;
}

.flex-1 { flex: 1; }

.input-group-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-group-row .form-control {
  flex: 1;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13.5px;
  vertical-align: middle;
}

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

.table tr:hover td {
  background: #fafafa;
}

/* BADGES & PILLS */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
}

.badge-primary { background: #1e3a8a; color: #93c5fd; }
.badge-counter { background: #334155; color: #f8fafc; margin-left: auto; }
.badge-warning { background: #fef3c7; color: #92400e; margin-left: auto; }
.badge-outline { border: 1px solid var(--border-color); color: var(--text-muted); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 14px;
}

.status-pill-active { background: #ecfdf5; color: #047857; }
.status-pill-trial { background: #fffbeb; color: #b45309; }
.status-pill-expired { background: #fef2f2; color: #b91c1c; }
.status-pill-blocked { background: #f1f5f9; color: #475569; }

/* FILTERS ROW */
.filters-row {
  display: flex;
  gap: 14px;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 13.5px;
}

.filter-group {
  display: flex;
  gap: 8px;
}

.select-compact {
  padding: 8px 12px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-row {
  display: flex;
  gap: 14px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-dialog {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.modal-dialog-lg {
  max-width: 860px !important;
}

.company-card-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  background: #f8fafc;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 18px;
}

.metric-box {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.metric-val {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.metric-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.text-blue { color: #2563eb; }

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}

.table-bordered {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.table-bordered th {
  background: #f8fafc;
}

.table-bordered td, .table-bordered th {
  border: 1px solid var(--border-color);
  padding: 10px 14px;
}

.cursor-pointer {
  cursor: pointer;
}

.contact-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}

.contact-link:hover {
  text-decoration: underline;
}

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

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

.modal-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* SIMULATOR */
.simulator-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
}

.json-viewer {
  background: #0f172a;
  color: #38bdf8;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: monospace;
  overflow-x: auto;
  max-height: 240px;
  margin-top: 8px;
}

.widget-preview-box {
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  padding: 20px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.sim-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.sim-notice {
  margin-top: 12px;
  font-size: 13px;
  color: #334155;
}

/* TARIFFS EDITOR */
.tariffs-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.tariff-card-item {
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

/* TOASTS */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.text-center { text-align: center; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }

/* ========================================================
   LOGIN OVERLAY & AUTH STYLES
   ======================================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 20%, rgba(37, 99, 235, 0.15) 0%, rgba(15, 23, 42, 0.95) 75%), #0f172a;
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: cardZoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardZoomIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-icon {
  font-size: 38px;
  margin-bottom: 8px;
  display: inline-block;
}

.login-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.login-header p {
  font-size: 13px;
  color: #64748b;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-weight: 500;
}

.login-form .form-group {
  margin-bottom: 18px;
}

.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.btn-link-action {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.btn-link-action:hover {
  text-decoration: underline;
}

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

.input-with-icon .form-control {
  width: 100%;
  padding-right: 38px;
}

.field-icon {
  position: absolute;
  right: 12px;
  font-size: 14px;
  color: #94a3b8;
  pointer-events: none;
}

.btn-toggle-eye {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #94a3b8;
  padding: 4px;
  border-radius: 4px;
  transition: opacity 0.15s;
}

.btn-toggle-eye:hover {
  opacity: 0.7;
}

.checkbox-row {
  margin-top: 10px;
  margin-bottom: 22px !important;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #64748b;
  cursor: pointer;
  user-select: none;
}

.btn-login-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  padding: 12px 16px;
  font-size: 14px;
}

.login-footer {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #64748b;
}

.badge-credential {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: monospace;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}

.badge-credential:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

/* User Session in Sidebar */
.user-session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-session-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

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

.user-session-name {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.2;
}

.user-session-role {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.2;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.25);
  transform: scale(1.05);
}

