/* T-Rex S3 Central — identidade visual
   Escuro (padrão): fundo #161616/#222222, destaque laranja #e5a02c,
   ok verde #72c67c, superfície secundária #2d5048, vermelho só para erro/cota estourada. */

@font-face { font-family: "Chakra Petch"; font-weight: 500; font-display: swap; src: url("../fonts/chakra-petch-500.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 600; font-display: swap; src: url("../fonts/chakra-petch-600.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 700; font-display: swap; src: url("../fonts/chakra-petch-700.woff2") format("woff2"); }

:root {
  --bg: #161616;
  --surface: #222222;
  --surface-2: #2d5048;
  --surface-3: #2b2b2b;
  --border: #343434;
  --text: #ececec;
  --muted: #a3a3a3;
  --accent: #e5a02c;
  --accent-hover: #f0b44d;
  --accent-text: #161616;
  --ok: #72c67c;
  --error: #e5534b;
  --error-bg: rgba(229, 83, 75, .12);
  --warn: #e5a02c;
  --track: #333333;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --font-title: "Chakra Petch", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #dcebe6;
  --surface-3: #f0f0ee;
  --border: #dadad6;
  --text: #1c1c1c;
  --muted: #5d5d5d;
  --accent: #c9851a;
  --accent-hover: #b0730f;
  --accent-text: #ffffff;
  --ok: #2f8a3a;
  --error: #c62828;
  --error-bg: rgba(198, 40, 40, .08);
  --track: #e4e4e0;
  --shadow: 0 1px 2px rgba(0,0,0,.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font-body); min-height: 100vh; }
h1, h2, h3, .brand { font-family: var(--font-title); font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; margin: 0 0 .5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- Topo ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--surface);
  border-bottom: 2px solid var(--accent); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.25rem; font-weight: 700; }
.brand img { width: 40px; height: 40px; border-radius: 8px; }
.brand:hover { text-decoration: none; }
.topbar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.userbox form { margin: 0; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 62px); }
.sidenav { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; }
.sidenav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); margin-bottom: 2px;
  font-family: var(--font-title); font-weight: 500; }
.sidenav a:hover { background: var(--surface-3); text-decoration: none; }
.sidenav a.active { background: var(--surface-2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
:root[data-theme="light"] .sidenav a.active { color: var(--text); }
.content { padding: 24px; max-width: 1200px; width: 100%; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidenav { display: flex; overflow-x: auto; gap: 4px; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidenav a { white-space: nowrap; margin: 0; }
  .content { padding: 16px; }
  .topbar { padding: 8px 12px; }
  .brand span { font-size: 1rem; }
  .userbox .who { display: none; }
}

/* ---------- Cartões e grade ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin-bottom: 18px; }
.card.secondary { background: var(--surface-2); border-color: transparent; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); align-items: start; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.grid > * { min-width: 0; }
.card h3 { margin-top: 20px; }
.card > h3:first-child, .card > h2 + h3 { margin-top: 0; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-family: var(--font-title); font-size: 1.7rem; font-weight: 700; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-family: var(--font-title); font-weight: 600; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }

/* ---------- Formulários ---------- */
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: .92rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.hint.error { color: var(--error); }
.hint.ok { color: var(--ok); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-form label { margin-top: 0; }
.inline-form > div { flex: 1 1 180px; }
input.code-input { font-family: var(--font-mono); font-size: 1.5rem; letter-spacing: .3em; text-align: center; max-width: 240px; }

/* ---------- Botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid transparent; font: 600 .92rem var(--font-title); cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-text); }
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-3); }
.btn.danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn.danger:hover { background: var(--error-bg); }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn.link { background: none; border: 0; color: var(--accent); padding: 0; font: inherit; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Mensagens e selos ---------- */
.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; border-left: 4px solid var(--ok); background: var(--surface); }
.flash.error { border-left-color: var(--error); background: var(--error-bg); }
.flash.warn { border-left-color: var(--warn); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--border); }
.badge.ok { color: var(--ok); border-color: var(--ok); background: transparent; }
.badge.error { color: var(--error); border-color: var(--error); background: transparent; }
.badge.accent { color: var(--accent); border-color: var(--accent); background: transparent; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.error { background: var(--error); }

/* ---------- Barra de uso ---------- */
.usage { min-width: 140px; }
.usage .bar { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.usage .bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.usage.over .bar span { background: var(--error); }
.usage .txt { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.usage.over .txt { color: var(--error); }
/* larguras em passos de 2% (CSP não permite style inline) */
.w-0{width:0}.w-2{width:2%}.w-4{width:4%}.w-6{width:6%}.w-8{width:8%}.w-10{width:10%}.w-12{width:12%}.w-14{width:14%}.w-16{width:16%}.w-18{width:18%}.w-20{width:20%}.w-22{width:22%}.w-24{width:24%}.w-26{width:26%}.w-28{width:28%}.w-30{width:30%}.w-32{width:32%}.w-34{width:34%}.w-36{width:36%}.w-38{width:38%}.w-40{width:40%}.w-42{width:42%}.w-44{width:44%}.w-46{width:46%}.w-48{width:48%}.w-50{width:50%}.w-52{width:52%}.w-54{width:54%}.w-56{width:56%}.w-58{width:58%}.w-60{width:60%}.w-62{width:62%}.w-64{width:64%}.w-66{width:66%}.w-68{width:68%}.w-70{width:70%}.w-72{width:72%}.w-74{width:74%}.w-76{width:76%}.w-78{width:78%}.w-80{width:80%}.w-82{width:82%}.w-84{width:84%}.w-86{width:86%}.w-88{width:88%}.w-90{width:90%}.w-92{width:92%}.w-94{width:94%}.w-96{width:96%}.w-98{width:98%}.w-100{width:100%}

/* ---------- Segredo exibido uma vez ---------- */
.secret-box { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px dashed var(--accent);
  border-radius: 8px; padding: 10px 12px; margin: 6px 0 12px; }
.secret-box code { flex: 1; word-break: break-all; font-size: 1rem; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-family: var(--font-mono); font-size: 1.05rem; }
.codes span { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; text-align: center; }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { display: grid; grid-template-columns: 266px minmax(0, 380px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.45); max-width: 100%; }
.auth-card .art { background: #111; display: flex; align-items: center; justify-content: center; }
.auth-card .art img { display: block; width: 266px; height: auto; }
.auth-card .form { padding: 32px 30px; }
.auth-card .form h1 { display: flex; align-items: center; gap: 10px; }
.auth-card .form h1 img { width: 36px; height: 36px; border-radius: 6px; }
.qr { background: #fff; padding: 8px; border-radius: 8px; width: 200px; margin: 8px 0; }
.qr svg { display: block; width: 100%; height: auto; }
@media (max-width: 700px) {
  .auth-card { grid-template-columns: 1fr; }
  .auth-card .art img { width: 150px; }
  .auth-card .form { padding: 22px 18px; }
}

.theme-toggle { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: .85rem; }
.theme-toggle:hover { background: var(--surface-3); }
details summary { cursor: pointer; color: var(--accent); }
.danger-zone { border-color: var(--error); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- Navegador de arquivos ---------- */
.crumbs { color: var(--muted); font-size: .92rem; word-break: break-all; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center; margin-bottom: 14px; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: var(--surface-3); }
.dropzone p { margin: 4px 0; }
.form-actions.center { justify-content: center; }
.upload-queue { display: grid; gap: 8px; margin-bottom: 14px; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 240px) minmax(0, 200px); gap: 10px; align-items: center;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; }
.upload-row.ok { border-color: var(--ok); }
.upload-row.error { border-color: var(--error); }
.upload-row.error .upload-status { color: var(--error); }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 99px; background: var(--track); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--track); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
.upload-row.ok progress::-webkit-progress-value { background: var(--ok); }
.upload-row.ok progress::-moz-progress-bar { background: var(--ok); }
table.files td.num, table.files th.num { text-align: right; white-space: nowrap; }
table.files a.folder { font-weight: 600; }
details.share { display: inline-block; position: relative; }
details.share > summary { list-style: none; }
details.share > summary::-webkit-details-marker { display: none; }
.share-form { position: absolute; right: 0; z-index: 5; margin-top: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; display: grid; gap: 6px; min-width: 200px; text-align: left; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.share-form label { margin: 0; }
.share-result { margin-top: 6px; }
.share-result code { font-size: .78rem; }
.alert-banner { background: var(--error-bg); border: 2px solid var(--error); color: var(--text); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; }
.alert-banner strong { color: var(--error); }
@media (max-width: 800px) {
  .upload-row { grid-template-columns: minmax(0, 1fr); }
  .share-form { position: static; }
}
