* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #1a1a2e; color: #e0e0e0; padding: 16px; max-width: 960px; margin: 0 auto; }

h1 { text-align: center; color: #00d4ff; margin-bottom: 4px; font-size: 1.5em; }
.subtitle { text-align: center; color: #888; margin-bottom: 20px; font-size: 0.85em; }

/* Connection status bar */
.status-bar { display: flex; justify-content: center; gap: 16px; margin-bottom: 16px; font-size: 0.85em; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
.dot-green { background: #4ade80; }
.dot-red { background: #f87171; }
.dot-yellow { background: #fbbf24; }

/* Device state banner */
.device-banner { background: #16213e; border: 1px solid #0f3460; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: 0.85em; }
.device-status { display: flex; align-items: center; gap: 8px; }
.device-icon { font-size: 1.3em; }
.device-detail { color: #888; margin-left: auto; }
.device-banner.sleeping { border-color: #854d0e; background: #1a1a0e; }
.device-banner.sleeping .device-icon { color: #fbbf24; }
.device-banner.awake { border-color: #166534; background: #0a1a0e; }
.device-banner.awake .device-icon { color: #4ade80; }
.device-banner.unknown { border-color: #0f3460; }
.pending-cmd { margin-top: 6px; padding-top: 6px; border-top: 1px solid #0f3460; color: #fbbf24; display: flex; align-items: center; gap: 6px; }
.pending-icon { font-size: 1.1em; }

/* Cards */
.card { background: #16213e; border-radius: 8px; padding: 16px; margin-bottom: 12px; border: 1px solid #0f3460; }
.card h2 { color: #00d4ff; font-size: 1em; margin-bottom: 12px; border-bottom: 1px solid #0f3460; padding-bottom: 6px; }

/* Live monitor gauges */
.gauges { display: flex; gap: 12px; margin-bottom: 12px; }
.gauge { flex: 1; text-align: center; background: #0f3460; border-radius: 8px; padding: 16px; }
.gauge .value { font-size: 2em; font-weight: bold; color: #00d4ff; }
.gauge .label { font-size: 0.8em; color: #aaa; margin-top: 4px; }

/* Readings table */
.readings-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.readings-table th { text-align: left; color: #aaa; padding: 6px 8px; border-bottom: 1px solid #0f3460; }
.readings-table td { padding: 5px 8px; border-bottom: 1px solid #0f346033; }
.readings-wrap { max-height: 200px; overflow-y: auto; }

/* Forms */
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 0.8em; color: #aaa; margin-bottom: 3px; }
.field input, .field select { width: 100%; padding: 8px; background: #0f3460; border: 1px solid #1a4080; border-radius: 4px; color: #fff; font-size: 0.9em; }
.field input:focus, .field select:focus { outline: none; border-color: #00d4ff; }
.row { display: flex; gap: 10px; }
.row .field { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; }
.check input[type="checkbox"] { width: 18px; height: 18px; accent-color: #00d4ff; }

/* Buttons */
.btn { display: block; width: 100%; padding: 12px; border: none; border-radius: 6px; font-size: 1em; font-weight: bold; cursor: pointer; margin-top: 8px; }
.btn-primary { background: #00d4ff; color: #1a1a2e; }
.btn-secondary { background: #0f3460; color: #00d4ff; border: 1px solid #00d4ff; }
.btn-danger { background: #7f1d1d; color: #f87171; border: 1px solid #f87171; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { display: inline-block; width: auto; padding: 6px 16px; font-size: 0.85em; margin-top: 0; }

/* File upload */
.upload-area { border: 2px dashed #0f3460; border-radius: 8px; padding: 24px; text-align: center; color: #888; cursor: pointer; margin-bottom: 12px; transition: border-color 0.2s; }
.upload-area:hover { border-color: #00d4ff; }
.upload-area.drag-over { border-color: #00d4ff; background: #0f346033; }
.upload-area input { display: none; }
.file-name { color: #00d4ff; font-weight: bold; }

/* Status messages */
.msg { padding: 10px; border-radius: 4px; margin-top: 10px; font-size: 0.9em; display: none; }
.msg.ok { display: block; background: #0a3d2a; color: #4ade80; border: 1px solid #166534; }
.msg.err { display: block; background: #3d0a0a; color: #f87171; border: 1px solid #7f1d1d; }
.msg.info { display: block; background: #1a3050; color: #60a5fa; border: 1px solid #1e40af; }

/* Event log */
.event-log { max-height: 120px; overflow-y: auto; font-family: monospace; font-size: 0.8em; background: #0a0a1a; border-radius: 4px; padding: 8px; }
.event-log div { padding: 2px 0; border-bottom: 1px solid #1a1a2e; }
.event-log .ts { color: #666; }

/* Spinner */
.spinner { display: inline-block; width: 16px; height: 16px; border: 3px solid rgba(26,26,46,0.3); border-top-color: #1a1a2e; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab { flex: 1; padding: 10px; text-align: center; background: #0f3460; border: 1px solid #1a4080; border-radius: 6px 6px 0 0; cursor: pointer; color: #aaa; font-size: 0.9em; }
.tab.active { background: #16213e; border-bottom-color: #16213e; color: #00d4ff; font-weight: bold; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal { background: #16213e; border: 1px solid #0f3460; border-radius: 12px; padding: 24px; max-width: 420px; width: 90%; text-align: center; animation: modalIn 0.2s ease-out; }
.modal-icon { font-size: 2.5em; margin-bottom: 8px; }
.modal h3 { color: #00d4ff; margin-bottom: 10px; font-size: 1.1em; }
.modal p { color: #ccc; font-size: 0.9em; line-height: 1.5; margin-bottom: 12px; }
.modal-detail { color: #fbbf24; font-size: 0.85em; margin-bottom: 16px; padding: 8px; background: #1a1a0e; border: 1px solid #854d0e; border-radius: 6px; display: none; }
.modal-detail.active { display: block; }
.modal .btn { max-width: 200px; margin: 0 auto; }
@keyframes modalIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
