/* MidiaDash app / tema escuro. */
:root {
  --bg: #0a0b0e; --surface: #111318; --surface-2: #161922; --surface-3: #1c2029;
  --line: #262a34; --line-soft: #1d2129;
  --text: #f3f1ea; --muted: #9095a1; --muted-2: #5f6470;
  --accent: #ffb347; --accent-2: #ff7a45; --accent-3: #ffd166;
  --grad: linear-gradient(120deg, #ff7a45 0%, #ffb347 55%, #ffd166 100%);
  --good: #57c98a; --bad: #e8705d;
  --display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, system-ui, sans-serif;
  --ease: cubic-bezier(.16,1,.3,1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--sans);
  -webkit-font-smoothing: antialiased; line-height: 1.5;
}
.hidden { display: none !important; }
button { font-family: var(--sans); cursor: pointer; }
a { color: var(--accent); }

/* logo */
.logo { display: inline-flex; align-items: center; gap: 11px; }
.logo svg { width: 34px; height: 34px; }
.logo .word { font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -.5px; }
.logo .word b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- AUTH ---------- */
#auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(800px 440px at 80% -10%, rgba(255,140,70,.1), transparent 62%),
    radial-gradient(640px 360px at 6% 8%, rgba(255,200,90,.05), transparent 58%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: linear-gradient(170deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: 20px; padding: 34px 30px;
  box-shadow: 0 30px 70px -34px rgba(0,0,0,.9);
}
.auth-card .logo { margin-bottom: 26px; }
.auth-card h1 { font-family: var(--display); font-weight: 600; font-size: 22px; margin: 0 0 5px; letter-spacing: -.4px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .02em; }
.field input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 14.5px; outline: none; transition: border-color .2s var(--ease);
}
.field input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%; background: var(--grad); color: #1a1205; font-weight: 700; font-size: 15px;
  border: none; border-radius: 10px; padding: 13px; margin-top: 6px; transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  box-shadow: 0 8px 22px -10px rgba(255,140,70,.6);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -10px rgba(255,140,70,.7); }
.btn-primary:disabled { opacity: .6; cursor: wait; transform: none; }
.auth-foot { margin-top: 18px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-foot button { background: none; border: none; color: var(--accent); font-size: 13.5px; font-weight: 600; padding: 0; }
.msg { margin-top: 14px; padding: 11px 14px; border-radius: 10px; font-size: 13.5px; display: none; }
.msg.show { display: block; }
.msg.err { background: rgba(232,112,93,.12); border: 1px solid rgba(232,112,93,.3); color: #f0a392; }
.msg.ok { background: rgba(87,201,138,.1); border: 1px solid rgba(87,201,138,.3); color: #8fe0b0; }

/* ---------- APP ---------- */
#app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line-soft); background: var(--surface);
}
.topbar .right { display: flex; align-items: center; gap: 16px; }
.tenant-pick {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 12px; font-size: 13.5px; outline: none;
}
.who { font-size: 13px; color: var(--muted); text-align: right; }
.who b { color: var(--text); }
.logout { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); border-radius: 9px; padding: 8px 14px; font-size: 13px; }
.logout:hover { border-color: var(--bad); color: var(--text); }

.shell { flex: 1; display: flex; min-height: 0; }
.side { width: 248px; border-right: 1px solid var(--line-soft); padding: 18px 14px; background: var(--surface); overflow-y: auto; }
.side .cap { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2); margin: 4px 8px 12px; }
.dash-item {
  display: block; width: 100%; text-align: left; background: none; border: 1px solid transparent;
  color: var(--muted); border-radius: 10px; padding: 11px 13px; font-size: 14px; margin-bottom: 4px; transition: all .18s var(--ease);
}
.dash-item:hover { background: var(--surface-2); color: var(--text); }
.dash-item.active { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); color: var(--text); border-color: rgba(255,179,71,.3); font-weight: 600; }
.viewer { flex: 1; min-width: 0; background: var(--bg); }
.viewer iframe { width: 100%; height: 100%; border: none; display: block; }
.empty { height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 30px; }
.empty .big { font-family: var(--display); font-size: 19px; color: var(--text); margin-bottom: 8px; }

/* estado pendente / loading */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.gate .card { max-width: 420px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; padding: 36px 30px; }
.gate .logo { margin-bottom: 22px; }
.gate h2 { font-family: var(--display); font-weight: 600; margin: 0 0 10px; }
.gate p { color: var(--muted); font-size: 14.5px; margin: 0 0 20px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .side { width: 180px; }
  .who { display: none; }
}

/* ---------- ADMIN (owner) ---------- */
.topbtn { background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); border: 1px solid rgba(255,179,71,.35); color: var(--accent-3); border-radius: 9px; padding: 8px 16px; font-size: 13px; font-weight: 600; transition: all .2s var(--ease); }
.topbtn:hover { background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); }
.admin { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 26px 60px; max-width: 1100px; margin: 0 auto; width: 100%; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 22px; border-bottom: 1px solid var(--line-soft); padding-bottom: 0; }
.atab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; font-weight: 600; padding: 10px 14px; cursor: pointer; transition: all .18s var(--ease); margin-bottom: -1px; }
.atab:hover { color: var(--text); }
.atab.active { color: var(--accent-3); border-bottom-color: var(--accent); }
.apanel.hidden { display: none; }
.apanel h2 { font-family: var(--display); font-weight: 600; font-size: 18px; margin: 0 0 4px; }
.apanel .psub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.atable { width: 100%; border-collapse: collapse; font-size: 13px; }
.atable th { text-align: left; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); font-weight: 600; padding: 0 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.atable td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.atable tr:hover td { background: var(--surface-2); }
.atable .em { color: var(--text); font-weight: 600; }
.atable .mut { color: var(--muted-2); }
.tagpill { display: inline-block; font-size: 11px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; margin: 2px 3px 2px 0; color: var(--muted); }

.urow { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface); margin-bottom: 10px; }
.urow .uinfo .un { font-weight: 600; }
.urow .uinfo .ue { font-size: 12.5px; color: var(--muted); }
.urow .uactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.urow select { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 8px 10px; font-size: 13px; outline: none; }
.ubtn { border-radius: 9px; padding: 8px 13px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); cursor: pointer; transition: all .18s var(--ease); }
.ubtn.ok { background: var(--grad); color: #1a1205; border-color: transparent; }
.ubtn.ok:hover { filter: brightness(1.06); }
.ubtn.no { background: var(--surface-2); color: var(--muted); }
.ubtn.no:hover { border-color: var(--bad); color: var(--text); }
.ubtn:disabled { opacity: .5; cursor: default; }
.ustatus { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.ustatus.approved { color: var(--good); background: rgba(87,201,138,.12); }
.ustatus.pending { color: var(--warn); background: rgba(232,181,77,.12); }
.ustatus.rejected { color: var(--bad); background: rgba(232,112,93,.12); }

.tenant-add { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 22px; padding: 16px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface); }
.tenant-add .fld { display: flex; flex-direction: column; gap: 5px; }
.tenant-add label { font-size: 11px; color: var(--muted); }
.tenant-add input { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 9px 12px; font-size: 13px; outline: none; }
.tenant-add input:focus { border-color: var(--accent); }
.tlist .trow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: 11px; background: var(--surface); margin-bottom: 8px; }
.tlist .tslug { font-size: 11px; color: var(--muted-2); background: var(--surface-3); border-radius: 6px; padding: 2px 8px; }
.amsg { font-size: 13px; padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; display: none; }
.amsg.show { display: block; }
.amsg.ok { background: rgba(87,201,138,.1); border: 1px solid rgba(87,201,138,.3); color: #8fe0b0; }
.amsg.err { background: rgba(232,112,93,.12); border: 1px solid rgba(232,112,93,.3); color: #f0a392; }
.aempty { color: var(--muted); font-size: 14px; padding: 30px 0; text-align: center; }
@media (max-width: 640px) { .urow { grid-template-columns: 1fr; } .urow .uactions { justify-content: flex-start; } }
