* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f8f9fb;
  color: #1a1a2e;
  min-height: 100vh;
}

.view {
  min-height: 100vh;
}

/* Loading */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Login */
.login-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 60px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  justify-content: center;
}

.suite-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.suite-logo-icon {
  font-size: 30px;
  color: white;
}

.suite-title {
  font-size: 2rem;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.02em;
}

.suite-subtitle {
  color: #6b7280;
  margin-top: 6px;
  margin-bottom: 32px;
  font-size: 0.95rem;
}

.login-form {
  width: 100%;
  background: white;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-primary {
  width: 100%;
  padding: 11px;
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-primary:hover {
  background: #4338ca;
}

.btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.error-text {
  color: #dc2626;
  font-size: 0.875rem;
  text-align: center;
  padding: 8px;
  background: #fef2f2;
  border-radius: 6px;
  margin-bottom: 16px;
}

.info-banner {
  color: #92400e;
  font-size: 0.875rem;
  text-align: center;
  padding: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  margin-bottom: 16px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
}

.suite-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.suite-header-icon {
  font-size: 22px;
  color: #4f46e5;
}

.suite-title-sm {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a1a2e;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-display {
  font-size: 0.9rem;
  color: #6b7280;
  font-weight: 500;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #374151;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-logout:hover {
  background: #f3f4f6;
}

.btn-logout .material-symbols-outlined {
  font-size: 18px;
}

/* Dashboard */
.dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.app-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 28px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.03);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid transparent;
}

.app-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.app-icon {
  font-size: 36px;
  margin-bottom: 16px;
  padding: 10px;
  border-radius: 12px;
}

.app-card--kotoba .app-icon {
  background: #ede9fe;
  color: #7c3aed;
}

.app-card--chrono .app-icon {
  background: #dbeafe;
  color: #2563eb;
}

.app-card--plachta .app-icon {
  background: #d1fae5;
  color: #059669;
}

.app-card--grafana .app-icon {
  background: #ffedd5;
  color: #ea580c;
}

.app-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.app-card p {
  font-size: 0.9rem;
  color: #6b7280;
  line-height: 1.5;
}

/* Health Dashboard */
.health-dashboard {
  margin-top: 40px;
}

.health-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.health-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.health-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.health-summary {
  font-size: 0.8rem;
  font-weight: 500;
  color: #9ca3af;
  padding: 2px 10px;
  border-radius: 99px;
  background: #f3f4f6;
  transition: all 0.3s;
}

.health-summary--good {
  color: #15803d;
  background: #dcfce7;
}

.health-summary--warn {
  color: #b45309;
  background: #fef3c7;
}

.health-refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: #9ca3af;
  transition: background 0.15s, color 0.15s;
}

.health-refresh-btn:hover {
  background: #f3f4f6;
  color: #6b7280;
}

.health-refresh-btn .material-symbols-outlined {
  font-size: 18px;
}

.health-refresh-btn.spinning .material-symbols-outlined {
  animation: spin-inline 0.7s linear infinite;
}

@keyframes spin-inline {
  to { transform: rotate(360deg); }
}

/* ========== Service Topology ========== */

.topo-wrap {
  position: relative;
  width: 100%;
  min-height: 300px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fafbfc;
  overflow: hidden;
}

.topo-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.topo-edge {
  fill: none;
  stroke: #d1d5db;
  stroke-width: 1.5;
  transition: stroke 0.2s, stroke-width 0.2s, opacity 0.2s;
}

.topo-edge--gateway {
  stroke: #c4b5fd;
}

.topo-edge--highlight {
  stroke: #7c3aed !important;
  stroke-width: 2.5;
}

.topo-edge--dim {
  opacity: 0.12;
}

.topo-nodes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Base node */
.topo-node {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 10px;
  background: white;
  border: 1px solid #e5e7eb;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: box-shadow 0.15s, border-color 0.15s, opacity 0.15s;
  z-index: 1;
}

.topo-node:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 10;
}

.topo-node--dragging {
  cursor: grabbing;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 100;
  transition: none;
}

.topo-node--dim {
  opacity: 0.3;
}

.topo-node-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #f3f4f6;
}

.topo-node-icon .material-symbols-outlined {
  font-size: 16px;
  color: #6b7280;
}

.topo-node-name {
  line-height: 1;
}

/* Health dot */
.topo-health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #d1d5db;
  transition: background 0.3s, box-shadow 0.3s;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.topo-health-dot--checking {
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.topo-health-dot--up {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.4);
}

.topo-health-dot--down {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239,68,68,0.4);
}

/* Gateway accent */
.topo-node[data-id="gateway"] {
  border-color: #c4b5fd;
}
.topo-node[data-id="gateway"] .topo-node-icon {
  background: #ede9fe;
}
.topo-node[data-id="gateway"] .topo-node-icon .material-symbols-outlined {
  color: #7c3aed;
}

/* Database nodes */
.topo-node--database {
  background: #f0f7ff;
  border-color: #bfdbfe;
}
.topo-node--database .topo-node-icon {
  background: #dbeafe;
}
.topo-node--database .topo-node-icon .material-symbols-outlined {
  color: #2563eb;
}

/* External API nodes */
.topo-node--external {
  background: #fafafa;
  border: 1px dashed #d1d5db;
  font-size: 0.72rem;
  font-weight: 500;
  color: #6b7280;
  padding: 5px 10px;
  gap: 6px;
}
.topo-node--external .topo-node-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: #f3f4f6;
}
.topo-node--external .topo-node-icon .material-symbols-outlined {
  font-size: 13px;
  color: #9ca3af;
}

/* Disabled external node (feature flag off) */
.topo-node--disabled {
  opacity: 0.45;
  border-color: #fca5a5 !important;
  border-style: dashed !important;
}
.topo-node--disabled .topo-node-icon {
  background: #fef2f2 !important;
}
.topo-node--disabled .topo-node-icon .material-symbols-outlined {
  color: #d1d5db !important;
}

/* Toggle switch (inline in external nodes) */
.topo-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  margin-left: 2px;
  flex-shrink: 0;
}
.topo-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.topo-toggle-track {
  position: relative;
  width: 26px;
  height: 14px;
  background: #d1d5db;
  border-radius: 7px;
  transition: background 0.2s;
}
.topo-toggle input:checked + .topo-toggle-track {
  background: #22c55e;
}
.topo-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.topo-toggle input:checked + .topo-toggle-track .topo-toggle-thumb {
  transform: translateX(12px);
}

/* Mobile toggle variant */
.topo-toggle--mobile {
  margin-left: auto;
}
.topo-mobile-ext--disabled {
  opacity: 0.45;
}

/* Tooltip */
.topo-tooltip {
  position: absolute;
  z-index: 1000;
  background: #1f2937;
  color: #f3f4f6;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.75rem;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 260px;
  white-space: normal;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.topo-tooltip--visible {
  opacity: 1;
}

.topo-tooltip-title {
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.topo-tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.topo-tooltip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.topo-tooltip-deps {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #374151;
  color: #9ca3af;
  font-size: 0.7rem;
}

/* ========== Mobile Health List ========== */

.topo-mobile {
  display: none;
}

.topo-mobile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.topo-mobile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: white;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  transition: border-color 0.3s;
}

.topo-mobile-card--up {
  border-color: #bbf7d0;
}

.topo-mobile-card--down {
  border-color: #fecaca;
}

.topo-mobile-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #d1d5db;
  transition: background 0.3s;
}

.topo-mobile-dot--checking {
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.topo-mobile-dot--up {
  background: #22c55e;
}

.topo-mobile-dot--down {
  background: #ef4444;
}

.topo-mobile-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #f3f4f6;
}

.topo-mobile-icon .material-symbols-outlined {
  font-size: 16px;
  color: #6b7280;
}

.topo-mobile-info {
  flex: 1;
  min-width: 0;
}

.topo-mobile-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  line-height: 1.3;
}

.topo-mobile-deps {
  display: block;
  font-size: 0.68rem;
  color: #9ca3af;
  line-height: 1.3;
}

.topo-mobile-ms {
  font-size: 0.72rem;
  color: #9ca3af;
  flex-shrink: 0;
}

.topo-mobile-ms--up {
  color: #16a34a;
}

.topo-mobile-ms--down {
  color: #dc2626;
}

.topo-mobile-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.topo-mobile-section-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.topo-mobile-ext-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.topo-mobile-ext {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #fafafa;
  border: 1px dashed #e5e7eb;
  border-radius: 8px;
  font-size: 0.72rem;
  color: #6b7280;
}

.topo-mobile-ext .material-symbols-outlined {
  font-size: 14px;
  color: #9ca3af;
}

/* ========== Responsive ========== */

@media (max-width: 768px) {
  .topo-wrap {
    display: none;
  }
  .topo-mobile {
    display: block;
  }
}

@media (max-width: 640px) {
  .header {
    padding: 12px 16px;
  }
  .dashboard {
    padding: 24px 16px;
  }
  .app-grid {
    grid-template-columns: 1fr;
  }
  .topo-mobile-ext-grid {
    grid-template-columns: 1fr;
  }
}

/* Bug Reports card */
.app-card--bugs .app-icon {
  background: #fef2f2;
  color: #dc2626;
}

.bugs-open-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 9999px;
  background: #dc2626;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
}
