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

:root {
  --bg:           #F0F4F8;
  --surface:      #FFFFFF;
  --surface-2:    #F8FAFC;
  --border:       #E2E8F0;
  --accent:       #6366F1;
  --accent-dark:  #4F46E5;
  --accent-light: #EEF2FF;
  --toggle-off:   #CBD5E1;
  --green:        #22C55E;
  --green-bg:     #DCFCE7;
  --red:          #EF4444;
  --gray:         #94A3B8;
  --amber:        #F59E0B;
  --amber-bg:     #FEF3C7;
  --text-1:       #1E293B;
  --text-2:       #64748B;
  --text-3:       #94A3B8;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:    0 20px 60px rgba(0,0,0,0.15), 0 8px 24px rgba(0,0,0,0.08);
  --radius:       14px;
  --radius-sm:    8px;
  --radius-xs:    6px;
}

html, body {
  height: 100%;
}

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

[hidden] { display: none !important; }

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-title h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.01em;
}

.header-host {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
}

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

.header-live {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--green);
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.85); }
}

/* ── Main ── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* ── Grid ── */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Left accent stripe by status */
.card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--gray);
  transition: background 0.3s;
}

.card[data-status="online"]::before     { background: var(--green); }
.card[data-status="offline"]::before    { background: var(--red); }
.card[data-status="undeployed"]::before { background: var(--amber); }

/* ── Card Header ── */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title-wrap { flex: 1; min-width: 0; }

.card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.45;
}

/* ── Status Badge ── */
.status-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge.online {
  background: var(--green-bg);
  color: #166534;
}
.status-badge.offline {
  background: #FEE2E2;
  color: #991B1B;
}
.status-badge.undeployed {
  background: var(--amber-bg);
  color: #92400E;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-badge.online   .status-dot { background: var(--green); }
.status-badge.offline  .status-dot { background: var(--red); }
.status-badge.undeployed .status-dot { background: var(--amber); }

/* ── Toggle Row ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.toggle-label-group { display: flex; flex-direction: column; gap: 1px; }

.toggle-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
}

.toggle-sublabel {
  font-size: 11px;
  color: var(--text-3);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 46px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--toggle-off);
  border-radius: 13px;
  transition: background 0.25s ease;
}

.toggle input:checked ~ .toggle-track {
  background: var(--accent);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toggle input:checked ~ .toggle-thumb {
  transform: translateX(20px);
}

.toggle:has(input:disabled) {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Toggle loading state */
.toggle.loading .toggle-thumb {
  background: linear-gradient(90deg, #e0e0e0 25%, #f5f5f5 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: shimmer 1s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Card Footer ── */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.card-type-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
}

.card-type-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s, opacity 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 3px rgba(99,102,241,0.3);
}
.btn-primary:hover  { background: var(--accent-dark); }

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

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

.btn-icon {
  background: transparent;
  color: var(--text-2);
  padding: 6px;
  border-radius: var(--radius-xs);
}
.btn-icon:hover { background: var(--bg); color: var(--text-1); }

.btn-full { width: 100%; padding: 10px 14px; font-size: 14px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.service-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  transition: background 0.15s;
}
.service-link:hover { background: var(--accent-light); }

/* ── Login ── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  margin-bottom: 20px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-3);
  font-size: 13px;
  margin-bottom: 28px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-1);
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  background: var(--surface);
  color: var(--text-1);
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.error-msg {
  color: var(--red);
  font-size: 12px;
  margin-top: 10px;
  text-align: center;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}

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

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

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

.modal-header h2 {
  font-size: 14px;
  font-weight: 600;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.log-output {
  font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.65;
  color: #1E293B;
  background: #F8FAFC;
  padding: 18px 22px;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 280px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Loading ── */
.loading-state {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 13px;
  padding: 48px 0;
  grid-column: 1 / -1;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Responsive ── */
@media (max-width: 600px) {
  .main { padding: 20px 16px 40px; }
  .services-grid { grid-template-columns: 1fr; gap: 14px; }
  .header-inner { padding: 0 16px; }
  .login-card { padding: 28px 24px; }
  .header-host { display: none; }
}
