/* ============================================================
   OTA Control Panel - Dark Mode (estilo Vercel/AWS Cloud)
   ============================================================ */

:root {
  --bg-0:        #0b0e14;
  --bg-1:        #11151f;
  --bg-2:        #161b27;
  --bg-3:        #1c2330;
  --border:      #232a37;
  --border-soft: #1a2030;
  --text:        #e6e9ef;
  --text-dim:    #9aa4b2;
  --text-mute:   #6b7280;
  --brand:       #3b82f6;
  --brand-2:     #6366f1;
  --green:       #22c55e;
  --green-bg:    rgba(34,197,94,.12);
  --red:         #ef4444;
  --red-bg:      rgba(239,68,68,.12);
  --yellow:      #eab308;
  --yellow-bg:   rgba(234,179,8,.12);
  --orange:      #f97316;
  --radius:      10px;
  --shadow:      0 4px 18px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}
.brand .logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center;
  font-weight: 700; color: #fff;
}
.brand .name { font-weight: 600; font-size: 15px; }
.brand .sub  { font-size: 11px; color: var(--text-mute); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  color: var(--text-dim);
  border-radius: 8px;
  font-size: 13.5px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--bg-3); color: var(--text); }
.nav a .ico { width: 18px; text-align: center; opacity: .85; }

.sidebar .footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-mute);
}

.main {
  padding: 26px 32px 60px;
  max-width: 1280px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.topbar h1 { font-size: 22px; margin: 0; font-weight: 600; }
.topbar .sub { color: var(--text-mute); font-size: 13px; margin-top: 2px; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
}
.user-chip .avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 12px;
}

/* ---------- Cards ---------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 980px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card .label { color: var(--text-mute); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.card .delta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.card.stats-green  { border-left: 3px solid var(--green); }
.card.stats-red    { border-left: 3px solid var(--red); }
.card.stats-yellow { border-left: 3px solid var(--yellow); }
.card.stats-blue   { border-left: 3px solid var(--brand); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .02em;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.green  { color: var(--green);  background: var(--green-bg); }
.badge.red    { color: var(--red);    background: var(--red-bg); }
.badge.yellow { color: var(--yellow); background: var(--yellow-bg); }
.badge.gray   { color: var(--text-dim); background: var(--bg-3); }
.badge.blue   { color: var(--brand);  background: rgba(59,130,246,.12); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.tbl th, table.tbl td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
table.tbl th {
  color: var(--text-mute);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--bg-2);
}
table.tbl tr:hover td { background: var(--bg-2); }
table.tbl td.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }

/* ---------- Form ---------- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.input, .select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
textarea { min-height: 90px; resize: vertical; }
.hint { font-size: 11.5px; color: var(--text-mute); margin-top: 4px; }

.checkbox-row { display: flex; align-items: center; gap: 10px; }
.switch {
  position: relative; width: 38px; height: 22px;
  background: var(--bg-3); border-radius: 999px; cursor: pointer;
  transition: background .15s; flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(16px); }
.switch input { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--bg-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #2f6fe0; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #d33b3b; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
  min-width: 240px;
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warn    { border-left-color: var(--yellow); }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(59,130,246,.15), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(99,102,241,.12), transparent 40%),
    var(--bg-0);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.login-card .logo {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px;
  margin-bottom: 18px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 22px; color: var(--text-mute); font-size: 13px; }
.alert {
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
  background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,.25);
}

/* ---------- Chart container ---------- */
.chart-box { position: relative; height: 280px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 12px; }
.chart-legend .item { display: flex; align-items: center; gap: 6px; color: var(--text-dim); }
.chart-legend .sw { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- Misc ---------- */
.muted { color: var(--text-mute); }
.mono  { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 6px; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.section-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--text); }
.divider { height: 1px; background: var(--border-soft); margin: 18px 0; }
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-mute); font-size: 13px;
}
.kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: var(--bg-3); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 4px; font-size: 12px;
}
code.inline {
  background: var(--bg-3); padding: 1px 6px; border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px;
}

/* ---------- Upload Progress Overlay ---------- */
.upload-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 14, 20, .82);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: grid; place-items: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.upload-modal {
  width: 100%; max-width: 440px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.upload-modal .icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff;
  font-size: 22px; margin: 0 auto 16px;
}
.upload-modal h3 { margin: 0 0 4px; font-size: 17px; }
.upload-modal .filename {
  font-size: 12.5px; color: var(--text-mute);
  margin-bottom: 20px; word-break: break-all;
}
.upload-modal .pct {
  font-size: 28px; font-weight: 700; color: var(--brand);
  margin-bottom: 12px; font-variant-numeric: tabular-nums;
}
.upload-bar {
  width: 100%; height: 8px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.upload-bar .fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px;
  transition: width .2s ease;
}
.upload-modal .detail {
  font-size: 12px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.upload-modal .cancel-btn {
  margin-top: 18px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .15s;
}
.upload-modal .cancel-btn:hover {
  border-color: var(--red); color: var(--red);
}
