* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #1f2328;
    min-height: 100vh;
}

/* Login Screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f0f2f5;
}

.login-card {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.login-logo-img {
    width: 180px;
    margin-bottom: 12px;
}

.login-card h2 {
    font-size: 1.2rem;
    font-weight: 500;
    color: #1f2328;
    margin-bottom: 4px;
}

.login-subtitle {
    color: #656d76;
    font-size: 0.85rem;
    margin-bottom: 28px;
}

.login-field {
    text-align: left;
    margin-bottom: 16px;
}

.login-field label {
    display: block;
    font-size: 0.8rem;
    color: #656d76;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-field input {
    width: 100%;
    background: #f6f8fa;
    border: 1px solid #d1d5db;
    color: #1f2328;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.95rem;
}

.login-field input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.login-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #dc2626;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.login-submit {
    width: 100%;
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 4px;
}

.login-submit:hover { background: #1d4ed8; }
.login-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Header */
header {
    background: #ffffff;
    border-bottom: 1px solid #d1d5db;
    padding: 24px 32px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    background: #eff6ff;
    color: #2563eb;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.logout-btn {
    background: transparent;
    color: #656d76;
    border: 1px solid #d1d5db;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
}

.logout-btn:hover {
    color: #1f2328;
    border-color: #9ca3af;
    background: #f6f8fa;
}

.header-content h1 {
    font-size: 1.6rem;
    font-weight: 600;
    color: #1f2328;
}

.subtitle {
    color: #656d76;
    font-size: 0.9rem;
    margin-top: 4px;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* Controls Bar */
.controls-bar {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-group label {
    font-size: 0.75rem;
    color: #656d76;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group select,
.control-group input {
    background: #f6f8fa;
    border: 1px solid #d1d5db;
    color: #1f2328;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    min-width: 140px;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

#refresh-btn {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    height: 36px;
}

#refresh-btn:hover { background: #1d4ed8; }
#refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.card-label {
    font-size: 0.8rem;
    color: #656d76;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.total-card .card-value { color: #2563eb; }
.start-card .card-value { color: #16a34a; }
.stop-card .card-value { color: #ea580c; }
.anomaly-card .card-value { color: #dc2626; }
.anomaly-card.clean .card-value { color: #16a34a; }

/* Anomalies Panel */
.anomalies-panel {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.anomalies-panel h2 {
    font-size: 1.1rem;
    color: #dc2626;
    margin-bottom: 12px;
}

.anomaly-summary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.anomaly-badge {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.8rem;
    color: #991b1b;
}

.anomaly-badge.warning {
    background: #fefce8;
    border-color: #fde047;
    color: #854d0e;
}

.anomaly-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.anomaly-item {
    background: #ffffff;
    border-left: 3px solid #dc2626;
    padding: 10px 14px;
    border-radius: 0 6px 6px 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.anomaly-item.warning { border-left-color: #ca8a04; }

.anomaly-item .anomaly-type {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.anomaly-item.warning .anomaly-type { color: #ca8a04; }
.anomaly-item .anomaly-type { color: #dc2626; }

.anomaly-item .anomaly-ts {
    color: #656d76;
    font-size: 0.75rem;
}

/* Table */
.table-container {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.table-container h2 {
    font-size: 1.1rem;
    padding: 16px 20px;
    border-bottom: 1px solid #d1d5db;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead th {
    background: #f6f8fa;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #656d76;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #d1d5db;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

tbody tr:hover { background: #f6f8fa; }

/* Row highlighting for anomalies */
tbody tr.anomaly-row { background: #fee2e2; border-left: 4px solid #dc2626; }
tbody tr.anomaly-row:hover { background: #fecaca; }
tbody tr.warning-row { background: #fef9c3; border-left: 4px solid #ca8a04; }
tbody tr.warning-row:hover { background: #fef08a; }

/* Action badges */
.action-start {
    color: #16a34a;
    font-weight: 600;
}

.action-stop {
    color: #ea580c;
    font-weight: 600;
}

.endpoint-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.endpoint-write {
    background: #dcfce7;
    color: #15803d;
}

.endpoint-batch {
    background: #dbeafe;
    color: #1d4ed8;
}

.cmd-id {
    font-family: monospace;
    font-size: 0.75rem;
    color: #656d76;
}

.empty-state {
    text-align: center;
    color: #656d76;
    padding: 40px 20px !important;
    font-style: italic;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #656d76;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
footer {
    text-align: center;
    padding: 24px;
    color: #9ca3af;
    font-size: 0.8rem;
    border-top: 1px solid #e5e7eb;
    margin-top: 40px;
}

/* Anomaly Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2328;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover { color: #1f2328; }

.modal-body {
    padding: 20px;
}

.modal-anomaly {
    margin-bottom: 20px;
}

.modal-anomaly:last-child { margin-bottom: 0; }

.modal-anomaly-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.modal-severity {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 4px;
}

.modal-severity-error {
    background: #fee2e2;
    color: #dc2626;
}

.modal-severity-warning {
    background: #fef9c3;
    color: #a16207;
}

.modal-anomaly-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2328;
}

.modal-anomaly-detail {
    background: #f6f8fa;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.85rem;
    margin-bottom: 12px;
    color: #1f2328;
}

.modal-anomaly-section {
    margin-bottom: 10px;
}

.modal-anomaly-section strong {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #656d76;
    margin-bottom: 4px;
}

.modal-anomaly-section p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #1f2328;
}

.modal-anomaly-guid {
    margin-top: 8px;
    font-size: 0.8rem;
    color: #656d76;
}

.modal-anomaly-guid code {
    background: #e5e7eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.78rem;
    color: #1f2328;
    word-break: break-all;
}

.modal-anomaly-meta {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

/* Responsive */
@media (max-width: 768px) {
    main { padding: 16px; }
    .controls-bar { flex-direction: column; }
    .control-group select,
    .control-group input { min-width: 100%; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
}
