:root {
  /* Collibra-inspired palette from temp_ingestion */
  --forest-90: #0d4f3c;
  --forest-80: #2d8f7f;
  --forest-60: #0d4f3c;
  --lime-90: #7cb342;
  --lime-80: #9ccc65;
  --lime-60: #cddc39;
  --lime-40: #e8f5e8;
  --lemon-60: #ffd700;

  /* Mapped app tokens */
  --bg: var(--forest-90);
  --panel: rgba(0,0,0,0.25);
  --muted: #cfe6d8;
  --text: #f1f7f4;
  --accent: var(--lemon-60);
  --accent-2: var(--lime-60);
  --danger: #ff5d5d;
  --gold: #ffcc4d;
  --silver: #c0cbdc;
  --bronze: #d9a36a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Calibri, "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, var(--forest-90) 0%, var(--forest-80) 60%, var(--forest-60) 100%);
  color: var(--text);
}

/* Headers use Calibri */
h1, h2, h3, h4, h5, h6 {
  font-family: Calibri, "Segoe UI", system-ui, sans-serif;
}

.app { min-height: 100%; display: flex; flex-direction: column; }
.app-header, .app-footer { padding: 16px 24px; background: #0d142a; border-bottom: 1px solid #1e2748; }
.app-footer { border-top: 1px solid #1e2748; border-bottom: none; margin-top: auto; color: var(--muted); }
.app-header h1 { margin: 0; font-size: 18px; letter-spacing: 0.3px; font-family: Calibri, "Segoe UI", system-ui, sans-serif; }

.app-main { padding: 24px; display: flex; flex-direction: column; gap: 16px; }



.lock-screen { display: grid; place-items: center; padding: 40px 0; }
.lock-card { background: var(--panel); border: 1px solid #24305b; border-radius: 12px; padding: 24px; width: 100%; max-width: 420px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
.lock-card h2 { margin: 0 0 6px; }
.lock-card p { margin: 0 0 16px; color: var(--muted); }
#pin-form { display: flex; gap: 8px; }
#pin-input { flex: 1; padding: 12px 14px; border-radius: 8px; border: 1px solid #2b386b; background: #0f1530; color: var(--text); outline: none; font-size: 16px; letter-spacing: 6px; text-align: center; }
#pin-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,124,255,0.25); }
button { padding: 10px 14px; border-radius: 8px; border: 1px solid #2b386b; background: var(--accent); color: white; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.05); }
.error { margin-top: 10px; min-height: 20px; color: var(--danger); }

.hidden { display: none !important; }

.tabs, .subtabs { display: flex; gap: 8px; }
.tabs { border-bottom: 1px solid #1e2748; padding-bottom: 8px; }
.tab, .subtab { 
  background: transparent; 
  border: 1px solid #2b386b; 
  color: var(--text); 
  font-family: Calibri, "Segoe UI", system-ui, sans-serif;
  transition: all 0.2s;
}
.tab.active, .subtab.active { 
  background: linear-gradient(135deg, #87CEEB 0%, var(--lime-60) 100%); 
  border-color: var(--lime-60); 
  color: var(--forest-90);
}
.tab:hover, .subtab:hover {
  background: rgba(255,255,255,0.1);
}

.tab-panel { margin-top: 16px; }
.subtab-panels { margin-top: 12px; background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 16px; backdrop-filter: blur(6px); }
/* Questions CRUD Interface */
.questions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.question-form-card, .questions-list-card { background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 16px; backdrop-filter: blur(6px); height: 700px; display: flex; flex-direction: column; }
.question-form-card h3, .questions-list-card h3 { margin: 0 0 16px; color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label { color: var(--muted); font-size: 14px; font-weight: 500; }
.field input, .field textarea, .field select { background: #0f1530; border: 1px solid rgba(255,255,255,0.15); color: var(--text); border-radius: 8px; padding: 10px; font-size: 14px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,215,0,0.2); }
.answers-grid { display: flex; flex-direction: column; gap: 8px; }
.answer-row { display: flex; align-items: center; gap: 8px; }
.answer-label { color: var(--muted); font-weight: 600; min-width: 20px; }
.answer-row input { flex: 1; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.questions-list { height: calc(100% - 60px); overflow-y: auto; }
.question-item { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.question-item:hover { background: rgba(255,255,255,0.1); }
.question-preview { font-size: 14px; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.question-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.question-actions { display: flex; gap: 6px; }
.question-actions button { padding: 4px 8px; font-size: 12px; }
.empty-state { text-align: center; color: var(--muted); padding: 20px; font-style: italic; }
.devices-list .empty-state { margin: 20px 0; }

/* CSV Controls */
.csv-controls .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.csv-controls label { color: var(--muted); font-size: 14px; }
.csv-controls input[type="password"],
.csv-controls input[type="file"],
.csv-controls textarea { background: #0f1530; border: 1px solid rgba(255,255,255,0.15); color: var(--text); border-radius: 8px; padding: 10px; }
.csv-controls .actions { display: flex; gap: 8px; margin-top: 8px; }
.csv-result { margin-top: 8px; color: var(--muted); font-size: 14px; }
.export-controls { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 768px) {
  .questions-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}

.devices-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.poll-status { color: var(--muted); font-size: 14px; }
.devices-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.device-card { background: var(--panel); border: 1px solid #24305b; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.device-info { display: flex; align-items: baseline; justify-content: space-between; }
.device-name { font-weight: 700; }
.device-meta { color: var(--muted); font-size: 13px; }
.device-actions { display: flex; gap: 8px; }
.device-actions .btn { flex: 1; min-width: 0; }
/* Button Styles */
.btn { 
  background: linear-gradient(135deg, var(--lime-60) 0%, #87CEEB 100%); 
  color: var(--forest-90); 
  border: none; 
  padding: 8px 16px; 
  border-radius: 6px; 
  cursor: pointer; 
  font-weight: 500; 
  font-family: Calibri, "Segoe UI", system-ui, sans-serif;
  transition: all 0.2s; 
}
.btn:hover { 
  background: linear-gradient(135deg, #a4d65e 0%, #98d8e8 100%); 
  transform: translateY(-1px);
}
.btn-secondary { 
  background: transparent; 
  color: var(--text); 
  border: 1px solid var(--lime-60); 
}
.btn-secondary:hover { 
  background: linear-gradient(135deg, var(--lime-60) 0%, #87CEEB 100%); 
  color: var(--forest-90); 
}
.btn-danger { 
  background: var(--danger); 
  color: white; 
}
.btn-danger:hover { 
  background: #ff4444; 
}

/* Optional: use gold/silver/bronze utility classes if needed in admin UI */
.tone-gold { background: var(--gold); color: #2b2100; }
.tone-silver { background: var(--silver); color: #101521; }
.tone-bronze { background: var(--bronze); color: #2d1806; }

@media (max-width: 520px) {
  .app-main { padding: 16px; }
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--panel);
  border: 1px solid #24305b;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.modal-header h3 {
  margin: 0;
  color: var(--text);
  font-family: Calibri, "Segoe UI", system-ui, sans-serif;
}

.close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.close-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

.modal-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.validation-errors {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 16px;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.1);
}

.validation-errors::-webkit-scrollbar {
  width: 8px;
}

.validation-errors::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
}

.validation-errors::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.3);
  border-radius: 4px;
}

.validation-errors::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.5);
}

.validation-warning {
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 93, 93, 0.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  text-align: center;
  color: var(--danger);
  font-size: 16px;
}

.error-message {
  color: var(--danger);
  font-size: 16px;
  line-height: 1.5;
  padding: 16px;
  background: rgba(255, 93, 93, 0.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  white-space: pre-wrap;
}

.import-summary {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  padding: 16px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}

.import-errors {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 16px;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.1);
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}


