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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  color: #333;
  min-height: 100vh;
}

.header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 20px; font-weight: 600; }

.header-right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: #64748b; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.mcp-badge { background: #ede9fe; color: #7c3aed; }

.last-check, .check-interval { font-size: 12px; color: #94a3b8; }
.page-indicator { font-weight: 600; color: #475569; }

.btn {
  padding: 6px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}

.btn:hover { background: #f1f5f9; }
.btn-primary { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.btn-primary:hover { background: #2563eb; }
.btn-add { margin-top: 12px; display: block; }
.btn-danger { color: #ef4444; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }

.btn-settings {
  background: #f1f5f9;
  border-color: #e2e8f0;
  font-weight: 500;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px 8px;
}

.btn-close:hover { color: #475569; }

/* Summary bar */
.summary-bar {
  display: flex;
  gap: 16px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
}

.summary-item.ok { background: #f0fdf4; color: #16a34a; }
.summary-item.warn { background: #fefce8; color: #ca8a04; }
.summary-item.error { background: #fef2f2; color: #dc2626; }
.summary-item.total { background: #f1f5f9; color: #475569; }
.summary-count { font-weight: 700; font-size: 18px; }
.summary-label { font-size: 12px; }

/* Status sections */
.status-section {
  padding: 0 24px 16px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  padding: 12px 0 8px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.error-section .section-title { color: #dc2626; }
.warn-section .section-title { color: #ca8a04; }
.ok-section .section-title { color: #16a34a; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* Status card */
.status-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  border-left: 4px solid #e2e8f0;
  position: relative;
  transition: transform .15s;
}

.status-card:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.status-card.error { border-left-color: #dc2626; background: #fef2f2; }
.status-card.warn { border-left-color: #ca8a04; background: #fefce8; }
.status-card.ok { border-left-color: #16a34a; }

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

.card-name { font-weight: 600; font-size: 14px; }

.card-type {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 500;
}

.card-message { font-size: 12px; color: #64748b; margin-bottom: 4px; word-break: break-all; }
.card-time { font-size: 11px; color: #94a3b8; }

.card-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.card-status-dot.ok { background: #16a34a; }
.card-status-dot.warn { background: #ca8a04; animation: blink 1.5s infinite; }
.card-status-dot.error { background: #dc2626; animation: blink 1s infinite; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

.status-card.error { animation: pulse-error 2s infinite; }
.status-card.warn { animation: pulse-warn 2s infinite; }

@keyframes pulse-error {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.15); }
  50% { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(202,138,4,.15); }
  50% { box-shadow: 0 0 0 6px rgba(202,138,4,0); }
}

.docker-extra { font-size: 11px; color: #94a3b8; margin-top: 4px; }

/* Page rotation */
.page { display: none; }
.page.active { display: block; }

/* Trends page */
.trends-header {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.trends-header h2 { font-size: 18px; }
.trends-header h2 small { font-size: 13px; color: #94a3b8; font-weight: 400; }

.trends-grid { padding: 16px 24px; }

.trends-top, .trends-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.trends-chart-container, .trends-table-container, .trends-incidents-container {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  border: 1px solid #e2e8f0;
}

.trends-chart-container h3, .trends-table-container h3, .trends-incidents-container h3 {
  font-size: 14px; font-weight: 600; margin-bottom: 12px; color: #475569;
}

.chart { width: 100%; height: 280px; }

.table-wrapper { max-height: 300px; overflow-y: auto; }

#availability-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#availability-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 2px solid #e2e8f0;
  color: #64748b;
  font-weight: 600;
  font-size: 12px;
}

#availability-table td {
  padding: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.avail-red { color: #dc2626; font-weight: 700; }
.avail-yellow { color: #ca8a04; font-weight: 600; }
.avail-green { color: #16a34a; }

.incidents-list { max-height: 300px; overflow-y: auto; }

.incident-card {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 6px;
  font-size: 13px;
  border-left: 3px solid;
}

.incident-card.error { border-left-color: #dc2626; background: #fef2f2; }
.incident-card.warn { border-left-color: #ca8a04; background: #fefce8; }

.incident-name { font-weight: 600; }
.incident-time { font-size: 11px; color: #94a3b8; }
.incident-msg { font-size: 12px; color: #64748b; margin-top: 2px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 { font-size: 16px; }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 20px;
}

.modal-tabs .tab {
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: #64748b;
  border-bottom: 2px solid transparent;
  transition: all .15s;
}

.modal-tabs .tab.active { color: #3b82f6; border-bottom-color: #3b82f6; font-weight: 600; }
.modal-tabs .tab:hover { color: #475569; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Config forms */
label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
}

label input[type="text"],
label input[type="number"],
label input[type="password"] {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-top: 4px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}

label input[type="checkbox"] { margin-left: 8px; }

.config-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.config-item-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.config-item-fields input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
}

.config-item .btn-remove {
  background: none;
  border: 1px solid #fecaca;
  color: #ef4444;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.config-item .btn-remove:hover { background: #fef2f2; }

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  transition: opacity .3s;
}

.toast.success { background: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; }
.toast.error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* Responsive */
@media (max-width: 768px) {
  .trends-top, .trends-bottom { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .summary-bar { flex-wrap: wrap; }
}
