/* Design Tokens & CSS Variables */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  
  --border-color: #e2e8f0;
  --border-focus: #10b981;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-primary: #059669;
  --accent-hover: #047857;
  --accent-light: #ecfdf5;
  --accent-text: #ffffff;
  
  --danger-color: #ef4444;
  --danger-light: #fef2f2;
  --danger-text: #991b1b;
  
  --warn-color: #f59e0b;
  --warn-light: #fffbeb;
  --warn-text: #92400e;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* Header & Brand */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
}

.header-container {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}

.sub {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Tabs Navigation */
.tabs-nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.tabs-container {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  padding: 0 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.875rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 600;
}

/* Main Container & Layout */
.main-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Panels & Cards */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.config-panel {
  max-width: 960px;
  margin: 1rem auto 0;
  background: var(--bg-subtle);
  border-color: #cbd5e1;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Form Grid & Inputs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  align-items: end;
}

.col-span-2 {
  grid-column: span 2;
}

@media (max-width: 640px) {
  .col-span-2 {
    grid-column: span 1;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field label {
  font-size: 0.78125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="date"],
select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  padding: 0.625rem 1.125rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: all var(--transition-fast);
  min-height: 42px;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--accent-text);
}

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

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-color);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  min-height: 34px;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  width: 100%;
}

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

/* Checklist Box */
.checklist-box {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.check-row:hover {
  background: var(--accent-light);
  border-color: #a7f3d0;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

th {
  padding: 0.75rem 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  font-size: 0.78125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 0.875rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

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

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.badge-neutral {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.badge-info {
  background: #e0f2fe;
  color: #0369a1;
}

.tag-status {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.tag-status.on {
  background: var(--accent-light);
  color: var(--accent-primary);
}

.tag-status.off {
  background: var(--danger-light);
  color: var(--danger-text);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;

}
.status-dot.on { background: var(--accent-primary); }
.status-dot.off { background: var(--warn-color); }

/* Messages & Empty States */
.msg-container {
  margin-top: 1rem;
}

.msg {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
}

.msg.ok {
  background: var(--accent-light);
  color: var(--accent-primary);
  border: 1px solid #a7f3d0;
}

.msg.err {
  background: var(--danger-light);
  color: var(--danger-text);
  border: 1px solid #fecaca;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.action-bar {
  margin-top: 1.25rem;
}

/* ==========================================================================
   Autenticação & Tela de Login
   ========================================================================== */
.hidden {
  display: none !important;
}

.login-wrapper {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at top, #ecfdf5 0%, #f8fafc 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  padding: 2.25rem;
  animation: loginFadeIn 0.3s ease-out;
}

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

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--accent-light);
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.login-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.login-form .field {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  text-align: left;
}

.login-form .field label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  height: 44px;
  padding: 0 0.875rem;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all var(--transition-fast);
}

.login-form input[type="email"]:focus,
.login-form input[type="password"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
  background: #ffffff;
}

.password-field-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.password-field-wrapper input {
  padding-right: 2.75rem !important;
}

.btn-toggle-password {
  position: absolute;
  right: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.btn-toggle-password:hover {
  color: var(--text-primary);
}

.remember-field {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: -0.25rem;
  margin-bottom: 1.25rem !important;
}

.remember-label {
  display: inline-flex !important;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  color: var(--text-secondary) !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  cursor: pointer;
  user-select: none;
}

.remember-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary);
  cursor: pointer;
  margin: 0;
}

.login-btn {
  width: 100%;
  height: 46px;
  padding: 0 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
  transition: all var(--transition-fast);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(5, 150, 105, 0.25);
}

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

.user-session-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.user-avatar {
  width: 22px;
  height: 22px;
  background: var(--accent-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.btn-logout {
  color: var(--danger-color);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-logout:hover {
  background: var(--danger-light);
  border-color: var(--danger-color);
}

