/* ==========================================================================
   VARIÁVEIS
   ========================================================================== */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2128;
  --border: #30363d;
  --border-light: #21262d;

  --entrada: #3fb950;
  --saida: #58a6ff;
  --indef: #d29922;
  --accent: #58a6ff;

  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #484f58;

  --font-ui: "Sora", sans-serif;
  --font-mono: "DM Mono", monospace;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border-light) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-light) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

.wrapper {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--entrada), var(--saida));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 20px rgba(88, 166, 255, 0.25);
}

.logo-text h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1;
}

.logo-text span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.version-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 20px;
}

.import-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--surface);
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.import-zone::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(88, 166, 255, 0.06) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.import-zone:hover,
.import-zone.drag-over {
  border-color: var(--accent);
  background: var(--surface2);
}

.import-zone:hover::after,
.import-zone.drag-over::after {
  opacity: 1;
}

.import-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.import-icon {
  font-size: 36px;
  margin-bottom: 12px;
  display: block;
}

.import-zone h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.import-zone p {
  font-size: 13px;
  color: var(--text-muted);
}

.import-zone p strong {
  color: var(--accent);
}

.import-zone.loaded {
  border-style: solid;
  border-color: var(--entrada);
  background: rgba(63, 185, 80, 0.06);
}

.import-zone.loaded::after {
  opacity: 1;
  background: radial-gradient(ellipse at center, rgba(63, 185, 80, 0.08) 0%, transparent 70%);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--accent));
}

.stat-card.entrada { --card-color: var(--entrada); }
.stat-card.saida { --card-color: var(--saida); }
.stat-card.total { --card-color: var(--text-muted); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  color: var(--card-color, var(--text));
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #0d1117;
}

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

.btn-success {
  background: var(--entrada);
  color: #0d1117;
}

.btn-success:hover {
  background: #56d364;
  transform: translateY(-1px);
}

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

.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

.status-bar {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.tabs-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  padding: 13px 24px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: color 0.2s;
}

.tab-btn::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--tab-color, var(--accent));
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--tab-color, var(--accent)); }
.tab-btn.active::after { transform: scaleX(1); }

.tab-btn.entrada-tab { --tab-color: var(--entrada); }
.tab-btn.saida-tab { --tab-color: var(--saida); }
.tab-btn.indef-tab { --tab-color: var(--indef); }

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 6px;
  background: var(--surface2);
  color: var(--text-muted);
  transition: all 0.2s;
}

.tab-btn.active .tab-count {
  background: var(--tab-color, var(--accent));
  color: #0d1117;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.search-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-dim); }

.copy-btn {
  font-size: 12px;
  padding: 8px 14px;
}

.key-table-wrap {
  overflow-y: auto;
  max-height: 440px;
}

.key-table-wrap::-webkit-scrollbar { width: 6px; }
.key-table-wrap::-webkit-scrollbar-track { background: var(--surface); }
.key-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.key-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

thead th:first-child {
  width: 60px;
  text-align: center;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

tbody tr:hover { background: var(--surface2); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 9px 16px;
  color: var(--text);
}

tbody td:first-child {
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
}

.key-cell {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.5px;
  color: var(--text);
  word-break: break-all;
}

.highlight {
  background: rgba(88, 166, 255, 0.3);
  border-radius: 2px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state .icon { font-size: 32px; opacity: 0.4; }
.empty-state p { font-size: 13px; }

.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 12px;
  display: none;
}

.progress-bar.active { display: block; }

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--entrada), var(--saida));
  border-radius: 2px;
  animation: progress-anim 1.2s ease-in-out infinite;
}

@keyframes progress-anim {
  0% { width: 0%; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 13px;
  box-shadow: var(--shadow);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1000;
  max-width: 360px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-left: 3px solid var(--entrada); }
.toast.error { border-left: 3px solid #f85149; }
.toast.info { border-left: 3px solid var(--saida); }

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 32px; }
  header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .panel-toolbar { flex-direction: column; align-items: stretch; }
  .status-bar { margin-left: 0; width: 100%; }
}
