:root {
  --primary: #fa5c00;
  --primary-dark: #d94e00;
  --primary-light: #ff7b2e;
  --secondary: #2c3e50;
  --secondary-light: #34495e;
  --secondary-dark: #1a252f;
  --bg-dark: #1e272e;
  --bg-darker: #151b20;
  --bg-panel: #263238;
  --bg-input: #37474f;
  --bg-hover: #455a64;
  --text-primary: #ecf0f1;
  --text-secondary: #b0bec5;
  --text-muted: #78909c;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #3498db;
  --border-color: #455a64;
  --border-radius: 6px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.5);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --header-height: 50px;
  --statusbar-height: 28px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  padding-top: var(--header-height);
  padding-bottom: var(--statusbar-height);
  background:
    radial-gradient(circle at 92% 0%, rgba(250, 92, 0, 0.08), transparent 26rem),
    var(--bg-darker);
  color: var(--text-primary);
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
a { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-decoration: none; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 80;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: linear-gradient(90deg, var(--secondary-dark), var(--secondary));
  border-bottom: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.header-left,
.header-right,
.brand-copy,
.hero-stats,
.filter-group,
.app-title-row,
.meta-row,
.card-actions,
.repository-note,
.status-bar,
.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
}

.header-left { gap: 10px; min-width: 0; }
.header-right { gap: 8px; }

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--border-radius);
  color: #fff;
  background: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
  flex: 0 0 auto;
}

.brand-copy { gap: 9px; min-width: 0; }
.brand-title { font-size: 18px; font-weight: 700; white-space: nowrap; }
.brand-subtitle {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  padding-left: 9px;
  border-left: 1px solid rgba(255,255,255,.18);
}

.access-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  background: rgba(0,0,0,.14);
  font-size: 12px;
}

.access-badge i { color: var(--primary-light); }

.btn-icon {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

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

.main-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding: 12px 0 26px;
  border-bottom: 1px solid rgba(69, 90, 100, .72);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--primary-light);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -.02em;
}

.hero p {
  max-width: 720px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.hero-stats {
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--border-color);
  box-shadow: var(--shadow-sm);
}

.stat {
  min-width: 100px;
  padding: 11px 16px;
  text-align: center;
  background: var(--bg-panel);
}

.stat-value { display: block; font-size: 20px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }

.toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0;
}

.search-box {
  width: min(460px, 100%);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-input);
  color: var(--text-secondary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(250, 92, 0, .12);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  background: transparent;
}

.search-box input::placeholder { color: var(--text-muted); }
.search-box kbd {
  min-width: 24px;
  height: 23px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-muted);
  background: var(--bg-dark);
  font: 11px Consolas, monospace;
}

.filter-group { gap: 6px; }

.filter-btn,
.btn {
  border: 0;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.filter-btn {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  background: var(--bg-panel);
  font-size: 12px;
  font-weight: 500;
}

.filter-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.filter-btn.active { border-color: var(--primary); color: #fff; background: var(--primary); }

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 310px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(55, 71, 79, .35), rgba(38, 50, 56, .96) 92px), var(--bg-panel);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.app-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--primary);
  opacity: .9;
}

.app-card:hover {
  transform: translateY(-2px);
  border-color: #607d8b;
  box-shadow: var(--shadow-md);
}

.app-card.is-empty::before { background: var(--text-muted); }

.card-main { padding: 20px 20px 16px 22px; flex: 1; }
.app-title-row { justify-content: space-between; gap: 14px; align-items: flex-start; }

.app-identity { display: flex; gap: 13px; min-width: 0; }
.app-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  color: var(--primary-light);
  background: rgba(250, 92, 0, .11);
  border: 1px solid rgba(250, 92, 0, .28);
  font-size: 20px;
}

.is-empty .app-icon {
  color: var(--text-secondary);
  background: rgba(176,190,197,.06);
  border-color: rgba(176,190,197,.18);
}

.app-name { margin: 1px 0 2px; font-size: 18px; line-height: 1.2; font-weight: 700; }
.app-category { color: var(--text-muted); font-size: 11px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.status-pill.available { color: #d8ffe9; background: rgba(46, 204, 113, .13); border: 1px solid rgba(46, 204, 113, .34); }
.status-pill.empty { color: var(--text-secondary); background: rgba(120, 144, 156, .10); border: 1px solid rgba(120, 144, 156, .26); }

.app-description { min-height: 42px; margin: 18px 0 16px; color: var(--text-secondary); }

.version-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-top: 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--border-color);
}

.version-panel .metric { padding: 10px 11px; background: rgba(21, 27, 32, .45); }
.metric-label { display: block; margin-bottom: 2px; color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.metric-value { display: block; overflow: hidden; color: var(--text-primary); font-size: 12px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.metric-value.mono { font-family: Consolas, monospace; }

.empty-panel {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 4px;
  padding: 12px 14px;
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-muted);
  background: rgba(55, 71, 79, .28);
}

.empty-panel i { color: var(--text-secondary); font-size: 18px; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 14px 22px;
  border-top: 1px solid var(--border-color);
  background: rgba(30, 39, 46, .88);
}

.meta-row { min-width: 0; gap: 12px; color: var(--text-muted); font-size: 11px; }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }
.card-actions { gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 500;
}

.btn:active { transform: translateY(1px); }
.btn-primary { color: #fff; background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { color: var(--text-primary); background: var(--bg-input); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-quiet { color: var(--text-secondary); background: transparent; border: 1px solid var(--border-color); }
.btn-quiet:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.repository-note {
  gap: 16px;
  margin-top: 18px;
  padding: 15px 17px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-dark);
}

.note-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--border-radius);
  color: var(--primary-light);
  background: rgba(250, 92, 0, .1);
  font-size: 18px;
}

.repository-note > div:nth-child(2) { flex: 1; }
.repository-note h2 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.repository-note p { margin: 0; color: var(--text-secondary); font-size: 12px; }

.status-bar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 75;
  height: var(--statusbar-height);
  justify-content: space-between;
  gap: 16px;
  padding: 0 12px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  background: var(--bg-dark);
  font-size: 10px;
}

.status-bar i { color: var(--success); margin-right: 5px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .8);
  animation: fadeIn .2s ease;
}

.modal-overlay.open { display: grid; }

.modal {
  width: min(900px, 90vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
  animation: slideUp .3s ease;
}

.modal-header {
  min-height: 66px;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px 10px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-dark);
}

.modal-kicker { display: block; color: var(--primary-light); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.modal-header h2 { margin: 1px 0 0; font-size: 16px; font-weight: 600; }
.modal-body { min-height: 0; padding: 16px 20px 20px; overflow-y: auto; }
.modal-footer {
  justify-content: space-between;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-dark);
}
.modal-count { color: var(--text-muted); font-size: 11px; }

.version-table-wrap { overflow-x: auto; }
.version-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.version-table th,
.version-table td { padding: 10px 11px; border-bottom: 1px solid rgba(69,90,100,.65); text-align: left; vertical-align: middle; }
.version-table th { position: sticky; top: 0; z-index: 1; color: var(--text-secondary); background: var(--bg-panel); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.version-table tbody tr:hover td { background: rgba(69,90,100,.18); }
.version-table .align-right { text-align: right; }
.version-cell { font-family: Consolas, monospace; font-weight: 700; color: var(--text-primary); }
.current-tag { display: inline-block; margin-left: 7px; padding: 2px 6px; border-radius: 999px; color: #fff; background: var(--primary); font: 10px Roboto, sans-serif; }
.file-name { max-width: 290px; overflow: hidden; color: var(--text-secondary); white-space: nowrap; text-overflow: ellipsis; }
.table-action { text-align: right !important; }
.table-action a { min-width: 34px; }

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 48px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-left: 4px solid var(--primary);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
  animation: slideIn .3s ease;
}

.toast i { color: var(--primary); }
.toast.success { border-left-color: var(--success); }
.toast.success i { color: var(--success); }

.empty-result {
  grid-column: 1 / -1;
  min-height: 260px;
  display: grid;
  place-items: center;
  padding: 30px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  color: var(--text-muted);
  background: rgba(38,50,56,.5);
  text-align: center;
}

.empty-result i { display: block; margin-bottom: 12px; font-size: 42px; opacity: .3; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { border-radius: 4px; background: var(--border-color); }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }

@media (max-width: 1024px) {
  .brand-subtitle { display: none; }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .main-shell { width: min(100% - 24px, 1180px); padding-top: 22px; }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-stats { width: 100%; }
  .stat { flex: 1; min-width: 0; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .filter-group { overflow-x: auto; padding-bottom: 2px; }
  .app-title-row { gap: 8px; }
  .version-panel { grid-template-columns: 1fr; }
  .card-footer { align-items: stretch; flex-direction: column; }
  .meta-row { justify-content: space-between; }
  .card-actions { justify-content: stretch; }
  .card-actions .btn { flex: 1; }
  .repository-note { align-items: flex-start; flex-wrap: wrap; }
  .repository-note .btn { width: 100%; }
  .modal-overlay { padding: 10px; }
  .modal { width: 95vw; max-height: 95vh; }
  .modal-body { padding: 10px; }
  .version-table th:nth-child(4),
  .version-table td:nth-child(4) { display: none; }
}

@media (max-width: 640px) {
  .app-header { padding: 0 10px; }
  .brand-copy { display: none; }
  .access-badge span { display: none; }
  .access-badge { width: 34px; justify-content: center; padding: 0; }
  .main-shell { width: min(100% - 16px, 1180px); }
  .hero { padding-top: 4px; }
  .hero p { font-size: 12px; }
  .hero-stats { border-radius: 8px; }
  .stat { padding: 9px 8px; }
  .stat-value { font-size: 17px; }
  .card-main { padding: 16px 14px 14px 17px; }
  .card-footer { padding: 12px 14px 12px 17px; }
  .app-icon { width: 42px; height: 42px; }
  .app-name { font-size: 16px; }
  .status-pill { padding: 0 7px; }
  .status-bar { padding: 0 8px; }
  .status-bar span:last-child { display: none; }
  .toast-container { left: 10px; right: 10px; bottom: 42px; }
  .toast { min-width: 0; max-width: none; width: 100%; }
}

@media print {
  .app-header,
  .toolbar,
  .status-bar,
  .card-actions,
  .repository-note,
  .modal-overlay,
  .toast-container { display: none !important; }
  body { padding: 0; color: #111; background: #fff; }
  .main-shell { width: 100%; }
  .app-card { break-inside: avoid; color: #111; background: #fff; box-shadow: none; }
}

/* Sincronización dinámica */
#refresh-repository.is-loading i { animation: spin 1s linear infinite; }

.loading-repository,
.repository-error {
  grid-column: 1 / -1;
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 34px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  color: var(--text-muted);
  background: rgba(38, 50, 56, .50);
  text-align: center;
}

.loading-repository i,
.repository-error > i {
  margin-bottom: 7px;
  color: var(--primary);
  font-size: 34px;
}

.loading-repository strong,
.repository-error strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.loading-repository span,
.repository-error span {
  max-width: 620px;
  font-size: 12px;
}

.repository-error > i { color: var(--warning); }
.repository-error .btn { margin-top: 10px; }

.repo-status.ok i { color: var(--success); }
.repo-status.loading i { color: var(--primary-light); }
.repo-status.warning i { color: var(--warning); }
.repo-status.error i { color: var(--danger); }

.access-badge.warning i { color: var(--warning); }
.access-badge.error i { color: var(--danger); }

.toast.warning { border-left-color: var(--warning); }
.toast.warning i { color: var(--warning); }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
