:root {
  --primary: #00ffcc;
  --primary-glow: rgba(0, 255, 204, 0.4);
  --bg-dark: #0f1115;
  --surface: #1e2025;
  --surface-light: #2a2d35;
  --text-main: #ffffff;
  --text-muted: #a0a5b1;
  --danger: #ff4757;
  --danger-glow: rgba(255, 71, 87, 0.4);
  --success: #2ed573;
  --border: rgba(255, 255, 255, 0.1);
  --glass: rgba(30, 32, 37, 0.7);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

header {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

main {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.card {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  animation: slideUp 0.4s ease-out;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

input, select {
  width: 100%;
  padding: 1rem;
  border-radius: 12px;
  background: var(--surface-light);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 1rem;
  transition: all 0.3s ease;
  appearance: none;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.file-upload {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-light);
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.file-upload:hover {
  border-color: var(--primary);
  background: rgba(0, 255, 204, 0.05);
}

.file-upload input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-icon {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.file-upload-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

#preview-container {
  display: none;
  margin-top: 1rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#preview-image {
  width: 100%;
  height: auto;
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 1rem;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: var(--primary);
  color: #000;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
  background: #00e6b8;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  z-index: 100;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger-glow);
}

.dot.online {
  background: var(--success);
  box-shadow: 0 0 10px rgba(46, 213, 115, 0.4);
}

#ocr-feedback {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--primary);
  display: none;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(0, 255, 204, 0.1);
  border: 1px solid rgba(0, 255, 204, 0.2);
}

#ocr-feedback.error {
  color: var(--danger);
  background: rgba(255, 71, 87, 0.1);
  border-color: rgba(255, 71, 87, 0.2);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0,0,0,0.2);
  border-radius: 50%;
  border-top-color: #000;
  animation: spin 1s ease-in-out infinite;
  display: none;
  margin-left: 10px;
}

.btn.loading .spinner {
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface-light);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.readings-list {
  margin-top: 2rem;
}

.reading-item {
  background: var(--surface-light);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
}

.reading-info h4 {
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.reading-info p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Fechamento UI */
.tabs-container { display: flex; gap: 10px; margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 10px; border: none; background: #2A2A2A; color: #fff; border-radius: 8px; font-weight: 600; cursor: pointer; }
.tab-btn.active { background: #4F46E5; }
.config-card { background: rgba(255, 255, 255, 0.05); padding: 20px; border-radius: 16px; margin-bottom: 20px; border: 1px solid rgba(255, 255, 255, 0.1); }
.results-card { background: rgba(255, 255, 255, 0.05); padding: 15px; border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.1); }
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 1rem; }
.table-responsive table { min-width: 500px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.1); }
th { font-weight: 600; color: #a5b4fc; }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }


/* Invoice Receipt CSS */
.invoice-box { width: 800px; background: #fff; padding: 20px; border: 2px solid #000; font-family: 'Arial', sans-serif; color: #000; box-sizing: border-box; }
.inv-header { display: flex; gap: 20px; margin-bottom: 20px; }
.inv-logo { width: 250px; }
.inv-title-box { flex: 1; }
.inv-title { border: 1px solid #000; padding: 10px; text-align: center; font-size: 24px; font-weight: bold; margin: 0 0 10px 0; }
.inv-meta { width: 100%; border-collapse: collapse; }
.inv-meta td { padding: 4px; font-size: 14px; }
.inv-meta td mark { background: #ffff00; font-weight: bold; padding: 2px 5px; }
.inv-table-blue { width: 100%; border-collapse: collapse; border: 1px solid #000; margin-bottom: 20px; }
.inv-table-blue th { background: #96c4e6; color: #000; font-weight: bold; border-bottom: 1px solid #000; padding: 5px; text-align: center; }
.inv-table-blue td { border: 1px solid #000; padding: 5px; text-align: center; font-size: 14px; }
.inv-items th { text-align: left; }
.inv-items td { text-align: left; }
.inv-total-section { text-align: right; margin-bottom: 20px; font-size: 24px; font-weight: bold; color: #2e74b5; }
.total-label { margin-right: 20px; }
.inv-payment-box { border: 1px solid #000; margin-bottom: 20px; }
.inv-payment-header { background: #bce6c6; color: #000; font-weight: bold; padding: 5px; border-bottom: 1px solid #000; font-size: 14px; }
.inv-payment-body { padding: 10px; font-size: 14px; }
.inv-payment-body td { padding: 3px 0; }
.inv-footer { text-align: center; font-size: 14px; }
/* Modal Styles */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.8); }
.modal-content { background-color: #fefefe; margin: 10% auto; padding: 20px; border: 1px solid #888; width: 90%; border-radius: 10px; }


.app-view {
  flex: 1;
  padding: 1.5rem;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
  display: none; /* Default hidden */
}

.badge {
  background: var(--danger);
  color: white;
  border-radius: 50%;
  padding: 2px 6px;
  font-size: 0.7rem;
  font-weight: bold;
  margin-left: 5px;
  vertical-align: super;
}
