:root {
  --primary: #1e3a8a;
  --primary-rgb: 30, 58, 138;
  --primary-hover: #1e40af;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --bg-color: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(203, 213, 225, 0.6);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
  --border-radius: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(30, 58, 138, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(56, 189, 248, 0.08) 0%, transparent 40%);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Glassmorphism Card Base */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--glass-shadow);
}

.kpi-grid .glass-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 180px;
}

/* Layout */
#app-container {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
  justify-content: center;
}

.view {
  width: 100%;
  animation: fadeIn 0.4s ease-out;
}

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

/* --- Login View --- */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  text-align: center;
}

.logo h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.logo p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

/* Forms & Inputs */
.input-group {
  margin-bottom: 20px;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.2);
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 16px;
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-block {
  width: 100%;
  padding: 12px;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.outline-btn {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
}

.outline-btn:hover {
  background: rgba(0,0,0,0.03);
}

.danger-btn {
  background: var(--danger);
  color: #fff;
}

.danger-btn:hover {
  background: var(--danger-hover);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  transition: var(--transition);
}

.icon-btn:hover {
  color: var(--danger);
}

/* --- Admin View --- */
#admin-view {
  display: flex; /* removed !important to allow .hidden to work */
}

#admin-view.hidden {
  display: none !important;
}

/* Sidebar */
.sidebar {
  width: 280px;
  min-height: calc(100vh - 40px);
  margin: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.sidebar .logo h2 {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  background: rgba(30, 58, 138, 0.15);
  color: #1e3a8a;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.nav-links {
  list-style: none;
  flex: 1;
}

.nav-links li {
  margin-bottom: 8px;
}

.nav-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn:hover {
  background: rgba(0,0,0,0.03);
  color: var(--text-main);
}

.nav-btn.active {
  background: rgba(30, 58, 138, 0.1);
  color: #1e3a8a;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
}

/* Content Area */
.content {
  flex: 1;
  padding: 40px 40px 40px 20px;
  overflow-y: auto;
  height: 100vh;
}

.tab-content {
  animation: fadeIn 0.3s ease-out;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.section-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Tables */
.table-container {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.05);
}

table {
  width: 100%;
  min-width: 900px; /* Garantir que a tabela não esprema demais em telas pequenas */
  border-collapse: collapse;
  text-align: left;
  table-layout: auto;
}

th {
  background: #f8fafc;
  padding: 16px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

td {
  padding: 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.input-light {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

td {
  padding: 16px;
  font-size: 0.95rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(0,0,0,0.015);
}

.text-right {
  text-align: right;
}

/* Action Buttons inside Table */
.action-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.action-btns .btn {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.badge-id {
  background: rgba(0,0,0,0.05);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.8rem;
}

.truncate {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal {
  width: 90%;
  max-width: 500px;
  padding: 32px;
  transform: translateY(0);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-sm {
  max-width: 400px;
  text-align: center;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 1.25rem;
}

.modal-body p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
}

.modal-sm .modal-actions {
  justify-content: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-weight: 500;
  z-index: 2000;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
/* History Table Dashboard */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th {
  background: rgba(30, 58, 138, 0.05);
  color: var(--primary);
  padding: 12px 16px;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--glass-border);
}

.history-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
  text-align: center;
}

.history-table .row-label {
  text-align: left;
  font-weight: 600;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.02);
  width: 240px;
}

.history-table tr:hover {
  background: rgba(var(--primary-rgb), 0.02);
}

#history-table-container {
  overflow-x: auto;
  margin-top: 1rem;
}

/* Business Parameters Table */
.business-table th {
  background: #cbd5e1 !important;
  color: #0f172a !important;
  font-size: 0.7rem !important;
  padding: 10px 8px !important;
  line-height: 1.2;
}

.business-table td {
  padding: 8px;
  font-size: 0.85rem;
}

.yellow-input {
  background-color: #fef08a !important;
  border: 1px solid #eab308 !important;
  text-align: right;
  width: 100%;
  padding: 6px;
  border-radius: 4px;
  font-weight: 500;
}

.calc-cell {
  background: rgba(30, 58, 138, 0.03);
  font-weight: 600;
  text-align: right;
  padding: 8px;
  border-radius: 4px;
}

.grey-input {
  background-color: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  text-align: right;
  width: 100%;
  padding: 6px;
  border-radius: 4px;
  font-weight: 500;
  color: #64748b;
}
