:root {
  --bg: #0e1117;
  --bg2: #161b22;
  --bg3: #1c2330;
  --line: #262d3a;
  --txt: #e6edf3;
  --mut: #8b98a9;
  --acc: #3d8bfd;
  --ok: #2ea043;
  --warn: #d29922;
  --err: #f85149;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--acc); }
.hidden { display: none !important; }
.muted { color: var(--mut); }
.err { color: var(--err); min-height: 18px; font-size: 13px; margin-top: 6px; }

/* ---------------------------------------------------------------- login */
.login-body { display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, #17233a, var(--bg)); }
.login-card {
  width: min(380px, 92vw); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px 28px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo { font-size: 40px; color: var(--acc); line-height: 1; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0 0 8px; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--mut); }
.login-card input, .modal input, .modal select, .modal textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; outline: none; width: 100%;
}
.login-card input:focus, .modal input:focus { border-color: var(--acc); }
.login-card button {
  margin-top: 6px; background: var(--acc); border: 0; color: #fff; font-weight: 600;
  padding: 11px; border-radius: 8px; cursor: pointer;
}
.login-card button:disabled { opacity: .6; }

/* ----------------------------------------------------------------- app */
#app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; height: 100dvh; }
aside {
  background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
.brand { padding: 14px 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.brand span { color: var(--acc); font-size: 18px; }
.side-scroll { overflow-y: auto; flex: 1; padding: 10px 8px; }
.side-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mut); padding: 12px 8px 6px; }
.side-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-item:hover { background: var(--bg3); }
.side-item.active { background: #1e3252; color: #cfe2ff; }
.side-item .x { margin-left: auto; opacity: 0; color: var(--mut); }
.side-item:hover .x { opacity: 1; }
.disk { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--mut); }
.bar { height: 6px; background: var(--bg3); border-radius: 4px; overflow: hidden; margin: 6px 0 4px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--ok), var(--warn)); }

main { display: flex; flex-direction: column; overflow: hidden; }
header {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); background: var(--bg2); flex-wrap: wrap;
}
.icon-btn {
  background: var(--bg3); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.icon-btn:hover { background: #232c3b; border-color: #33405a; }
.icon-btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.icon-btn.danger { background: #3a1c1e; border-color: #6b2b2f; color: #ffb4b0; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
#menuBtn { display: none; }

.crumbs { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 160px; overflow-x: auto; scrollbar-width: none; }
.crumbs::-webkit-scrollbar { display: none; }
.crumb { padding: 5px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.crumb:hover { background: var(--bg3); }
.crumb.last { color: var(--mut); }
.sep { color: var(--mut); }

.search { position: relative; }
.search input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 190px; outline: none;
}
.search input:focus { border-color: var(--acc); width: 240px; }

.toolbar {
  display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--bg2); align-items: center; flex-wrap: wrap;
}
.selinfo { color: var(--acc); font-size: 13px; margin-right: auto; }

.listwrap { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; background: var(--bg); z-index: 2;
  text-align: left; font-size: 12px; color: var(--mut); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap;
}
thead th:hover { color: var(--txt); }
tbody tr { border-bottom: 1px solid #1a202b; cursor: default; }
tbody tr:hover { background: var(--bg2); }
tbody tr.sel { background: #17273f; }
td { padding: 7px 10px; vertical-align: middle; }
td.nm { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ic { width: 20px; text-align: center; flex: 0 0 20px; }
.nmtxt { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nmtxt:hover { text-decoration: underline; }
.sz, .dt, .md { color: var(--mut); font-size: 12px; white-space: nowrap; }
.md { font-family: ui-monospace, Menlo, Consolas, monospace; }
.rowact { display: flex; gap: 4px; justify-content: flex-end; }
.rowact button { background: none; border: 0; cursor: pointer; color: var(--mut); padding: 4px 5px; border-radius: 6px; }
.rowact button:hover { background: var(--bg3); color: var(--txt); }
.linkto { color: var(--mut); font-size: 12px; }
.mobonly { display: none; }

.empty { padding: 60px 20px; text-align: center; color: var(--mut); }

/* --------------------------------------------------------------- modais */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(2px);
}
.sheet {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.sheet.wide { width: min(1100px, 100%); height: 88vh; }
.sheet header { border-bottom: 1px solid var(--line); background: transparent; padding: 14px 16px; }
.sheet header h3 { margin: 0; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .body { padding: 16px; overflow: auto; flex: 1; }
.sheet .body.pad0 { padding: 0; }
.sheet footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--mut); }
.row { display: flex; gap: 10px; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; color: var(--txt); font-size: 13px; }
.check input { width: auto; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.kv b { color: var(--mut); font-weight: 500; }
.kv span { word-break: break-all; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.preview-box { display: grid; place-items: center; background: #08090c; height: 100%; overflow: auto; }
.preview-box img, .preview-box video { max-width: 100%; max-height: 100%; }
.preview-box iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.CodeMirror { height: 100% !important; font-size: 13px; }
#edwrap { height: 100%; }

.logline { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid #1a202b; }
.logline b { color: var(--acc); font-weight: 600; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; pointer-events: none;
}
.toast {
  background: var(--bg3); border: 1px solid var(--line); border-left: 3px solid var(--acc);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  max-width: 90vw;
}
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--err); }

#drop {
  position: fixed; inset: 0; background: rgba(61,139,253,.12); border: 3px dashed var(--acc);
  z-index: 70; display: grid; place-items: center; font-size: 20px; font-weight: 600; pointer-events: none;
}
progress { width: 100%; height: 6px; }

/* -------------------------------------------------------------- mobile */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  aside {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40;
    transform: translateX(-100%); transition: transform .2s; border-right: 1px solid var(--line);
  }
  aside.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.7); }
  #menuBtn { display: inline-flex; }
  #scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 39; }
  .search input, .search input:focus { width: 130px; }
  .dt, .md, th.dt, th.md { display: none; }
  .deskonly { display: none; }
  .mobonly { display: inline-block; font-size: 20px; line-height: 1; padding: 2px 10px; }
  td { padding: 10px 8px; }
  td.nm { max-width: 52vw; }
  .sz { font-size: 11px; }
  .sheet.wide { height: 92vh; }
  .toolbar { overflow-x: auto; flex-wrap: nowrap; }
}
