:root {
  --bg: #0f172a;
  --bg-soft: #111827;
  --panel: #111c31;
  --panel-2: #17233b;
  --border: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-2: #38bdf8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.28), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.13), transparent 32rem),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
code {
  background: rgba(15, 23, 42, .75);
  color: #bfdbfe;
  padding: .18rem .4rem;
  border-radius: .45rem;
}
input, button, textarea { font: inherit; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  padding: .78rem 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: 0 12px 30px rgba(37, 99, 235, .32);
}
.button-download {
  width: 100%;
  margin-top: 1rem;
  background: rgba(37, 99, 235, .18);
  border: 1px solid rgba(59, 130, 246, .35);
  color: #dbeafe;
}
.button-download:hover { background: rgba(37, 99, 235, .28); }
.full { width: 100%; }

.alert {
  padding: .9rem 1rem;
  border-radius: 14px;
  margin: 1rem 0;
  border: 1px solid var(--border);
}
.alert-danger { background: rgba(239, 68, 68, .13); border-color: rgba(239, 68, 68, .35); color: #fecaca; }
.alert-success { background: rgba(34, 197, 94, .13); border-color: rgba(34, 197, 94, .35); color: #bbf7d0; }
.alert-warning { background: rgba(245, 158, 11, .13); border-color: rgba(245, 158, 11, .35); color: #fde68a; }
.muted { color: var(--muted); }

.brand-block {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.brand-block.center { justify-content: center; text-align: left; }
.brand-logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 16px 32px rgba(37, 99, 235, .32);
  font-size: 1.5rem;
}
.brand-logo.big { width: 64px; height: 64px; font-size: 1.9rem; }
.brand-block h1 { margin: 0; font-size: 1.6rem; line-height: 1.1; }
.brand-block p { margin: .25rem 0 0; color: var(--muted); }

.login-page, .install-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-card, .install-card {
  width: min(100%, 440px);
  background: linear-gradient(180deg, rgba(17, 28, 49, .95), rgba(15, 23, 42, .95));
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.install-card { width: min(100%, 820px); }
.login-form, .form-grid { display: grid; gap: 1rem; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
label { color: #cbd5e1; font-weight: 650; font-size: .92rem; }
input, textarea {
  width: 100%;
  margin-top: .45rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, .74);
  color: var(--text);
  border-radius: 14px;
  padding: .86rem .95rem;
  outline: none;
}
input:focus, textarea:focus { border-color: rgba(56, 189, 248, .75); box-shadow: 0 0 0 4px rgba(56, 189, 248, .08); }
.config-output { min-height: 220px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.5rem;
  background: rgba(2, 6, 23, .52);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(14px);
}
.sidebar-brand { display: flex; gap: .85rem; align-items: center; margin-bottom: 2rem; }
.sidebar-brand strong { display: block; font-size: 1.1rem; }
.sidebar-brand span { display: block; color: var(--muted); font-size: .88rem; }
.sidebar-nav { display: grid; gap: .5rem; }
.sidebar-nav a {
  color: #cbd5e1;
  padding: .8rem 1rem;
  border-radius: 14px;
  border: 1px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(37, 99, 235, .16);
  border-color: rgba(59, 130, 246, .22);
  color: white;
}
.main { padding: 2rem; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.topbar h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.6rem); }
.topbar p { margin: .35rem 0 0; color: var(--muted); }
.user-pill {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(15, 23, 42, .55);
  white-space: nowrap;
}
.user-pill a { color: #93c5fd; font-weight: 700; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card, .panel, .file-card {
  background: linear-gradient(180deg, rgba(17, 28, 49, .88), rgba(15, 23, 42, .84));
  border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(0,0,0,.2);
}
.stat-card { border-radius: var(--radius); padding: 1.25rem; }
.stat-card span { color: var(--muted); display: block; margin-bottom: .55rem; }
.stat-card strong { font-size: 1.65rem; }
.panel { border-radius: 24px; padding: 1.5rem; }
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.panel-header h2 { margin: 0; }
.panel-header p { margin: .3rem 0 0; color: var(--muted); }
.search-input { max-width: 380px; margin: 0; }
.empty-state {
  padding: 3rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 22px;
}
.category-block { margin-top: 1.6rem; }
.category-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: .75rem;
  margin-bottom: 1rem;
}
.category-title h3 { margin: 0; font-size: 1.25rem; }
.category-title span { color: var(--muted); }
.files-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.file-card {
  display: flex;
  gap: 1rem;
  border-radius: 20px;
  padding: 1rem;
  min-width: 0;
}
.file-icon {
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  font-size: .78rem;
  letter-spacing: .04em;
  background: linear-gradient(135deg, #475569, #64748b);
}
.file-icon-app { background: linear-gradient(135deg, #2563eb, #38bdf8); }
.file-icon-disc { background: linear-gradient(135deg, #7c3aed, #c084fc); }
.file-icon-archive { background: linear-gradient(135deg, #16a34a, #86efac); }
.file-icon-pdf { background: linear-gradient(135deg, #dc2626, #fb7185); }
.file-icon-doc { background: linear-gradient(135deg, #0891b2, #67e8f9); }
.file-icon-driver { background: linear-gradient(135deg, #f97316, #fdba74); }
.file-icon-mobile { background: linear-gradient(135deg, #059669, #5eead4); }
.file-content { min-width: 0; flex: 1; }
.file-title-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.file-title-row h4 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-real-name { margin: .35rem 0 .75rem; color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { display: flex; flex-wrap: wrap; gap: .45rem; }
.file-meta span {
  background: rgba(148, 163, 184, .1);
  border: 1px solid rgba(148, 163, 184, .12);
  color: #cbd5e1;
  padding: .23rem .45rem;
  border-radius: 999px;
  font-size: .75rem;
}
.badge-new {
  flex: 0 0 auto;
  background: rgba(34, 197, 94, .16);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, .35);
  border-radius: 999px;
  padding: .22rem .48rem;
  font-size: .7rem;
  font-weight: 900;
  text-transform: uppercase;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .files-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .main, .sidebar { padding: 1rem; }
  .topbar, .panel-header { flex-direction: column; align-items: stretch; }
  .stats-grid, .files-grid, .form-grid { grid-template-columns: 1fr; }
  .search-input { max-width: none; }
  .file-card { flex-direction: column; }
  .file-icon { width: 52px; height: 52px; }
  .login-page, .install-page { padding: 1rem; }
}

/* v1.1.0 - dashboard, download counters and activity panels */
.sidebar-note {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(15, 23, 42, .48);
  color: var(--muted);
  font-size: .84rem;
}
.sidebar-note strong { display: block; color: #e2e8f0; margin-bottom: .4rem; }
.sidebar-note span { display: block; line-height: 1.45; }
.nav-refresh {
  background: rgba(34, 197, 94, .11) !important;
  border-color: rgba(34, 197, 94, .22) !important;
}
.stats-grid-v11 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-card small {
  display: block;
  color: var(--muted);
  margin-top: .35rem;
  font-size: .82rem;
}
.quick-panels {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.mini-panel {
  min-width: 0;
  background: linear-gradient(180deg, rgba(17, 28, 49, .88), rgba(15, 23, 42, .84));
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.1rem;
  box-shadow: 0 18px 50px rgba(0,0,0,.18);
}
.mini-panel-header {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: .8rem;
  margin-bottom: .8rem;
}
.mini-panel-header h2 { margin: 0; font-size: 1rem; }
.mini-panel-header span { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.compact-list { display: grid; gap: .55rem; }
.compact-item {
  display: flex;
  gap: .7rem;
  align-items: center;
  min-width: 0;
  padding: .55rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .10);
  background: rgba(15, 23, 42, .38);
}
.compact-item:hover { background: rgba(37, 99, 235, .10); }
.compact-item strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .88rem;
}
.compact-item small {
  display: block;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: .15rem;
  font-size: .76rem;
}
.compact-icon {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: .65rem;
}
.rank-badge {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #dbeafe;
  background: rgba(37, 99, 235, .18);
  border: 1px solid rgba(59, 130, 246, .35);
  font-weight: 900;
}
.activity-dot {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, .12);
  margin-left: .6rem;
}
.search-wrap { display: grid; gap: .45rem; min-width: 280px; }
.search-counter { color: var(--muted); font-size: .82rem; text-align: right; }
.file-badges { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; }
.badge-count {
  flex: 0 0 auto;
  background: rgba(59, 130, 246, .14);
  color: #bfdbfe;
  border: 1px solid rgba(59, 130, 246, .30);
  border-radius: 999px;
  padding: .22rem .48rem;
  font-size: .7rem;
  font-weight: 800;
}
.file-icon-script { background: linear-gradient(135deg, #0f766e, #5eead4); }
.file-icon-firmware { background: linear-gradient(135deg, #b45309, #facc15); }

@media (max-width: 1280px) {
  .stats-grid-v11 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-panels { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .stats-grid-v11 { grid-template-columns: 1fr; }
  .search-wrap { min-width: 0; width: 100%; }
  .search-counter { text-align: left; }
  .mini-panel-header { flex-direction: column; }
}

/* v1.1.1 - correção de nomes longos nos painéis rápidos */
.quick-panels {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
}
.mini-panel,
.compact-list,
.compact-item {
  min-width: 0;
}
.mini-panel {
  overflow: hidden;
}
.compact-item {
  width: 100%;
  overflow: hidden;
}
.compact-item > span:last-child {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.compact-item strong,
.compact-item small {
  max-width: 100%;
}
.file-title-row,
.file-content {
  min-width: 0;
}
.file-title-row h4 {
  min-width: 0;
  flex: 1 1 auto;
}
.file-badges {
  flex: 0 0 auto;
}

/* v1.2.0 - upload pelo navegador */
.button-inline {
  width: auto;
  margin-top: 0;
  padding-left: 1rem;
  padding-right: 1rem;
}
.upload-panel { margin-bottom: 1.5rem; }
.upload-form { display: block; }
.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 1.25rem;
  align-items: stretch;
}
.upload-box,
.upload-options {
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, .14);
  background: rgba(15, 23, 42, .35);
  border-radius: 20px;
  padding: 1rem;
}
.upload-drop {
  position: relative;
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: .35rem;
  cursor: pointer;
  border: 1px dashed rgba(56, 189, 248, .45);
  background: linear-gradient(180deg, rgba(37, 99, 235, .10), rgba(15, 23, 42, .22));
  border-radius: 18px;
  padding: 2rem;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.upload-drop:hover,
.upload-drop.drag-active {
  border-color: rgba(56, 189, 248, .95);
  background: linear-gradient(180deg, rgba(37, 99, 235, .18), rgba(15, 23, 42, .34));
  transform: translateY(-1px);
}
.upload-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}
.upload-drop-icon {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 18px 40px rgba(37, 99, 235, .28);
  font-size: 2rem;
}
.upload-drop strong { display: block; font-size: 1.2rem; }
.upload-drop small { color: var(--muted); }
.selected-files {
  margin-top: .8rem;
  padding: .8rem;
  border-radius: 14px;
  background: rgba(2, 6, 23, .34);
  border: 1px solid rgba(148, 163, 184, .10);
  max-height: 150px;
  overflow: auto;
  font-size: .86rem;
  line-height: 1.55;
}
.upload-options {
  display: grid;
  gap: 1rem;
  align-content: start;
}
.form-group { display: grid; gap: .55rem; }
.radio-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}
.radio-card,
.check-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0;
  padding: .75rem;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 14px;
  background: rgba(15, 23, 42, .42);
  color: #cbd5e1;
  cursor: pointer;
}
.radio-card input,
.check-row input {
  width: auto;
  margin: 0;
}
.select-input {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, .74);
  color: var(--text);
  border-radius: 14px;
  padding: .86rem .95rem;
  outline: none;
}
.select-input:focus { border-color: rgba(56, 189, 248, .75); box-shadow: 0 0 0 4px rgba(56, 189, 248, .08); }
.field-help { color: var(--muted); font-size: .78rem; }
.hidden { display: none !important; }
.upload-details {
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 16px;
  background: rgba(2, 6, 23, .45);
  color: #cbd5e1;
  white-space: pre-wrap;
  overflow: auto;
}
.upload-help-panels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.info-list { display: grid; gap: .6rem; }
.info-list span {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  padding: .55rem;
  border: 1px solid rgba(148, 163, 184, .10);
  border-radius: 12px;
  background: rgba(15, 23, 42, .38);
}
.info-list strong { color: #e2e8f0; }

@media (max-width: 1100px) {
  .upload-grid { grid-template-columns: 1fr; }
  .upload-help-panels { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .radio-row { grid-template-columns: 1fr; }
  .upload-drop { min-height: 210px; }
}

/* v1.2.1 - aviso inteligente de limite de upload */
.selected-file-row {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-width: 0;
}
.selected-file-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selected-file-error strong { color: #fecaca; }
.selected-file-total {
  margin-top: .55rem;
  padding-top: .55rem;
  border-top: 1px solid rgba(148, 163, 184, .12);
  color: var(--muted);
}
.file-warning-badge {
  flex: 0 0 auto;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #fee2e2;
  background: rgba(239, 68, 68, .20);
  border: 1px solid rgba(248, 113, 113, .35);
  border-radius: 999px;
  padding: .2rem .45rem;
}
.upload-size-warning {
  margin-top: .75rem;
  border-radius: 14px;
  padding: .85rem .95rem;
  font-size: .88rem;
  line-height: 1.45;
}
.upload-size-error {
  color: #fee2e2;
  background: rgba(127, 29, 29, .35);
  border: 1px solid rgba(248, 113, 113, .38);
}
.upload-size-advice {
  color: #dbeafe;
  background: rgba(30, 64, 175, .24);
  border: 1px solid rgba(96, 165, 250, .32);
}
.button:disabled,
.button[disabled] {
  opacity: .55;
  cursor: not-allowed;
  transform: none !important;
}
