/* =====================================================
   ZapFlow Design System — SafeLink Panel Palette
   ===================================================== */

:root {
  --sl-green:       #22D17C;
  --sl-green-dark:  #1aad63;
  --sl-green-soft:  rgba(34,209,124,0.12);
  --sl-green-glow:  rgba(34,209,124,0.35);

  --sl-bg:          #0D1117;
  --sl-surface:     #161B22;
  --sl-surface-2:   #1C2330;
  --sl-border:      #2A3038;
  --sl-border-soft: rgba(42,48,56,0.6);

  --sl-text:        #E6EDF3;
  --sl-text-muted:  #8B949E;
  --sl-text-dim:    #4D5866;

  --sl-danger:      #F85149;
  --sl-warning:     #D29922;
  --sl-info:        #388BFD;
  --sl-online:      var(--sl-green);
  --sl-offline:     var(--sl-danger);
  --sl-unknown:     var(--sl-warning);

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --sidebar-w:  230px;
  --topbar-h:   56px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--sl-bg);
  color: var(--sl-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── APP SHELL ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-brand {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--sl-border);
  min-height: 64px;
  flex-shrink: 0;
}
.sidebar-brand svg { width: 32px; height: 32px; flex-shrink: 0; }
.sidebar-brand-text { font-size: 17px; font-weight: 800; color: var(--sl-text); }
.sidebar-brand-text span { color: var(--sl-green); }
.sidebar-close-btn { display: none; background: none; border: none; color: var(--sl-text-muted); cursor: pointer; margin-left: auto; padding: 4px; }

nav { padding: 12px 8px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sl-text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--sl-surface-2); color: var(--sl-text); }
.nav-item.active { background: var(--sl-green-soft); color: var(--sl-green); }

.sidebar-footer { padding: 8px; border-top: 1px solid var(--sl-border); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--sl-surface-2);
  border-radius: var(--radius);
  margin: 6px 0;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--sl-green-soft);
  border: 1.5px solid var(--sl-green);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--sl-green);
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--sl-text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  min-height: 100vh;
  max-width: calc(100% - var(--sidebar-w));
}

/* ── MOBILE TOPBAR ── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--sl-surface);
  border-bottom: 1px solid var(--sl-border);
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 150;
}
.mobile-topbar-brand { font-size: 17px; font-weight: 800; color: var(--sl-text); }
.mobile-topbar-brand span { color: var(--sl-green); }
.hamburger-btn { background: none; border: none; color: var(--sl-text-muted); cursor: pointer; padding: 6px; }
.hamburger-btn svg { width: 22px; height: 22px; display: block; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 199; }

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--sl-text); }
.page-subtitle { font-size: 13px; color: var(--sl-text-muted); margin-top: 2px; }

/* ── CARDS ── */
.card {
  background: var(--sl-surface);
  border: 1px solid var(--sl-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--sl-text); }

/* ── STATS GRID ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--sl-surface); border: 1px solid var(--sl-border); border-radius: var(--radius-lg); padding: 18px 20px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--sl-text-dim); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--sl-text); }
.stat-value.green { color: var(--sl-green); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--sl-green); color: #0D1117; }
.btn-primary:hover { background: var(--sl-green-dark); }

.btn-secondary { background: var(--sl-surface-2); color: var(--sl-text-muted); border: 1px solid var(--sl-border); }
.btn-secondary:hover { color: var(--sl-text); border-color: var(--sl-text-dim); }

.btn-danger { background: rgba(248,81,73,.12); color: var(--sl-danger); border: 1px solid rgba(248,81,73,.3); }
.btn-danger:hover { background: rgba(248,81,73,.2); }

.btn-block { width: 100%; display: flex; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 6px; }

/* ── FORMS ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--sl-text-muted); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field-hint { font-size: 12px; color: var(--sl-text-dim); margin-top: -6px; }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=url], input[type=datetime-local],
select, textarea {
  background: var(--sl-surface-2);
  border: 1px solid var(--sl-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--sl-text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--sl-green); }
input::placeholder, textarea::placeholder { color: var(--sl-text-dim); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B949E' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge-online  { background: rgba(34,209,124,.12); color: var(--sl-green);   border: 1px solid rgba(34,209,124,.3); }
.badge-online  .badge-dot { background: var(--sl-green); }
.badge-offline { background: rgba(248,81,73,.12);  color: var(--sl-danger);  border: 1px solid rgba(248,81,73,.3); }
.badge-offline .badge-dot { background: var(--sl-danger); }
.badge-unknown { background: rgba(210,153,34,.12); color: var(--sl-warning); border: 1px solid rgba(210,153,34,.3); }
.badge-unknown .badge-dot { background: var(--sl-warning); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { padding: 10px 14px; text-align: left; font-size: 11.5px; font-weight: 700; color: var(--sl-text-dim); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--sl-border); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--sl-border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.025); }

/* ── ALERTS ── */
.error-box   { background: rgba(248,81,73,.1);   border: 1px solid rgba(248,81,73,.3);  border-radius: var(--radius); padding: 12px 16px; color: var(--sl-danger);  font-size: 13.5px; margin-bottom: 16px; }
.success-box { background: rgba(34,209,124,.1);  border: 1px solid rgba(34,209,124,.3); border-radius: var(--radius); padding: 12px 16px; color: var(--sl-green);  font-size: 13.5px; margin-bottom: 16px; }
.flash { animation: slideIn .3s ease; }
@keyframes slideIn { from { opacity:0; transform: translateY(-8px); } to { opacity:1; transform: translateY(0); } }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--sl-text-dim); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; display: block; }
.empty-state p { font-size: 14px; }

/* ── MODALS ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--sl-surface);
  border: 1px solid var(--sl-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(.96) translateY(8px); } to { opacity:1; transform: scale(1) translateY(0); } }
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.modal-text  { font-size: 13.5px; color: var(--sl-text-muted); margin-bottom: 18px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── LOGIN PAGE ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(ellipse at top left, rgba(34,209,124,.06) 0%, transparent 60%), var(--sl-bg); }
.login-card { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; justify-content: center; }
.login-brand svg { width: 36px; height: 36px; }
.login-brand-name { font-size: 22px; font-weight: 800; color: var(--sl-text); }
.login-brand-name span { color: var(--sl-green); }
.login-slogan { text-align: center; color: var(--sl-text-muted); font-size: 14px; margin-bottom: 28px; }

/* ── PLANS PAGE ── */
.plan-card { position: relative; transition: border-color .2s; }
.plan-card-active { border-color: var(--sl-green); box-shadow: 0 0 0 1px var(--sl-green), 0 0 24px var(--sl-green-soft); }
.plan-featured { border-color: var(--sl-green); }
.plan-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--sl-green); color: #0D1117; font-size: 11px; font-weight: 700; padding: 3px 12px; border-radius: 20px; white-space: nowrap; }
.plan-name { font-size: 13px; font-weight: 700; color: var(--sl-text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.plan-price { font-size: 36px; font-weight: 900; color: var(--sl-text); line-height: 1; margin-bottom: 4px; }
.plan-period { font-size: 12.5px; color: var(--sl-text-dim); margin-bottom: 18px; }
.plan-features { list-style: none; margin: 0 0 22px; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.plan-current { text-align: center; font-size: 13px; font-weight: 600; color: var(--sl-green); padding: 10px; background: var(--sl-green-soft); border-radius: var(--radius-sm); }

/* ── CODE ── */
code { background: var(--sl-surface-2); border: 1px solid var(--sl-border); border-radius: 4px; padding: 1px 6px; font-family: monospace; font-size: 12px; color: var(--sl-green); }

/* ── TEXT UTILITIES ── */
.text-dim { color: var(--sl-text-dim); }
.text-muted { color: var(--sl-text-muted); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sl-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--sl-text-dim); }

/* ── MOBILE RESPONSIVE ── */
@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: block; }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; padding: 80px 16px 24px; max-width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; }
  .field-row { flex-direction: column; gap: 0; }
  .page-title { font-size: 18px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
