:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2128;
  --muted: #667085;
  --border: #e3e6ea;
  --accent: #2f6f5e;
  --accent-text: #ffffff;
  --danger: #b42318;
  --ok-bg: #e7f4ee;
  --ok-text: #1e6b4a;
  --err-bg: #fdecea;
  --err-text: #b42318;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1f25;
    --text: #e6e8eb;
    --muted: #98a2b3;
    --border: #2b323a;
    --accent: #4fa88e;
    --accent-text: #0d1512;
    --danger: #f97066;
    --ok-bg: #12291f;
    --ok-text: #6ce0a8;
    --err-bg: #2d1514;
    --err-text: #f97066;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 1rem; }
.muted { color: var(--muted); }

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; color: var(--text); }
.topbar .nav { margin-left: auto; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.topbar .crumb { color: var(--muted); }
.topbar.slim { padding: 0 1rem; font-size: .9rem; flex-wrap: nowrap; min-height: 44px; }
.topbar.slim .brand, .topbar.slim .nav { flex-shrink: 0; white-space: nowrap; }

/* Abas com os sistemas liberados (topo do visualizador) */
.app-tabs {
  display: flex; align-self: stretch; gap: 1.5rem; min-width: 0; margin-left: 1.5rem;
  overflow-x: auto; scrollbar-width: none;
}
.app-tabs::-webkit-scrollbar { display: none; }
.app-tab {
  display: flex; align-items: center; gap: .55rem; padding: 0 1.25rem; white-space: nowrap;
  color: var(--muted); border-bottom: 2px solid transparent;
}
.app-tab-icon { width: 18px; height: 18px; object-fit: contain; border-radius: 4px; flex-shrink: 0; }
.app-tab:hover { color: var(--text); text-decoration: none; background: var(--bg); }
.app-tab.current { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }

.container { max-width: 760px; margin: 2rem auto; padding: 0 16px; }
.container.wide { max-width: 1100px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin: 1.5rem 0; }
.card.narrow { max-width: 420px; margin: 4rem auto; }

.stack { display: flex; flex-direction: column; gap: .9rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url], input:not([type]), textarea {
  font: inherit; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset.checks { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; display: grid; gap: .4rem; }
legend { padding: 0 .3rem; font-weight: 500; }

button { font: inherit; cursor: pointer; }
button.primary {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px;
  padding: .65rem 1rem; font-weight: 600; align-self: flex-start;
}
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
button.link.danger { color: var(--danger); }
form.inline { display: inline; }

.flash { padding: .7rem 1rem; border-radius: 8px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; display: flex; gap: .8rem; }
td.url-cell { max-width: 280px; word-break: break-all; }
.tag { font-size: .78rem; padding: .1rem .5rem; border-radius: 99px; background: var(--border); }
.tag.ok { background: var(--ok-bg); color: var(--ok-text); }
.tag.public { background: #e8effc; color: #2a5bb8; }
@media (prefers-color-scheme: dark) { .tag.public { background: #172440; color: #8fb3f5; } }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-all; }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.app-card {
  display: flex; align-items: center; gap: .75rem; padding: 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-weight: 600;
}
.app-card:hover { border-color: var(--accent); text-decoration: none; }
.share-card { display: flex; flex-direction: column; max-width: 420px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); margin-bottom: .75rem; }
.share-card img { width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; display: block; }
.share-noimg { padding: 2rem; text-align: center; }
.share-text { display: flex; flex-direction: column; gap: .2rem; padding: .7rem .9rem; }
.share-text span { font-size: .9rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
textarea { resize: vertical; }
.app-icon { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; flex-shrink: 0; }

/* Visualizador do app */
body.viewer { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.app-frame { flex: 1; width: 100%; border: 0; display: block; background: #fff; }

@media (max-width: 600px) {
  .app-tabs { gap: .5rem; margin-left: .5rem; }
  .app-tab { padding: 0 .75rem; }
}
