/* Portal R2 — CSS próprio, sem framework/build. Tema escuro. */
:root {
  --bg: #020617;
  --surface: #0f172a;
  --surface-2: #1e293b;
  --border: #1e293b;
  --border-2: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;
  --brand: #ea580c;
  --brand-hover: #f97316;
  --brand-soft: rgba(234, 88, 12, 0.15);
  --red: #ef4444;
  --green: #10b981;
  --amber: #f59e0b;
  --sky: #38bdf8;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { padding: 4rem; text-align: center; color: var(--muted); }

/* ---------- Layout ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
}
.app-header__inner {
  max-width: 1120px; margin: 0 auto; padding: 0.75rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.5rem; }
.brand__logo {
  width: 32px; height: 32px; border-radius: 8px; background: var(--brand);
  color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13px;
}
.brand__title { font-size: 0.875rem; font-weight: 600; line-height: 1; }
.brand__sub { font-size: 0.75rem; color: var(--faint); }
.nav { display: flex; gap: 0.25rem; }
.nav a {
  color: var(--muted); padding: 0.5rem 0.75rem; border-radius: 8px;
  font-size: 0.875rem; font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand); color: #fff; }
.header-user { display: flex; align-items: center; gap: 0.75rem; }
.header-user__name { color: var(--muted); font-size: 0.875rem; }
@media (max-width: 640px) { .header-user__name { display: none; } }
main.container { max-width: 1120px; margin: 0 auto; padding: 2rem 1rem; }

/* ---------- Tipografia ---------- */
h1 { font-size: 1.5rem; font-weight: 600; margin: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.subtitle { color: var(--muted); font-size: 0.875rem; margin: 0.25rem 0 0; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  border-radius: 8px; padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent; transition: background-color .15s, border-color .15s;
  font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-ghost { background: transparent; border-color: var(--border-2); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.link-btn { background: none; border: none; cursor: pointer; font: inherit; font-size: 0.75rem; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.link-sky { color: var(--sky); }
.link-red { color: #f87171; }
.link-green { color: #34d399; }
.link-amber { color: #fbbf24; }

/* ---------- Form ---------- */
.field { margin-bottom: 1rem; }
.label { display: block; margin-bottom: 0.25rem; font-size: 0.7rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.input {
  width: 100%; border: 1px solid var(--border-2); background: var(--surface);
  border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.875rem; color: var(--text);
  font-family: inherit;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; margin: 0 0 1rem; }
legend { padding: 0 0.25rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-bottom: 1.5rem; }
.toolbar .field { margin: 0; }

/* ---------- Cards / Stats ---------- */
.card { border: 1px solid var(--border); background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); margin-bottom: 1.5rem; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stats--6 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 1024px) { .stats--6 { grid-template-columns: repeat(6, 1fr); } }
.stats--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .stats--4 { grid-template-columns: repeat(4, 1fr); } }
.stat__label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat__value { font-size: 1.5rem; font-weight: 600; margin-top: 0.25rem; }
.stat__sub { font-size: 0.75rem; color: var(--faint); margin-top: 0.25rem; }

/* ---------- Tabela ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead { background: rgba(15, 23, 42, 0.8); }
th { text-align: left; padding: 0.75rem 1rem; font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
td { padding: 0.75rem 1rem; border-top: 1px solid var(--border); }
tbody tr:hover { background: rgba(30, 41, 59, 0.4); }
.t-right { text-align: right; }
tfoot td { border-top: 2px solid var(--border-2); background: rgba(15, 23, 42, 0.6); font-weight: 600; }
.row-actions { display: flex; justify-content: flex-end; gap: 0.75rem; }

/* ---------- Badge / status ---------- */
.badge { display: inline-flex; align-items: center; border-radius: 999px;
  padding: 0.125rem 0.625rem; font-size: 0.75rem; font-weight: 500; }
.badge--active { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.badge--provisioning { background: rgba(245,158,11,0.15); color: #fcd34d; }
.badge--suspended { background: rgba(249,115,22,0.15); color: #fdba74; }
.badge--canceled { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge--default { background: var(--surface-2); color: var(--muted); }

/* ---------- Alert / toast ---------- */
.alert { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  border: 1px solid; border-radius: 8px; padding: 0.75rem 1rem; font-size: 0.875rem; margin-bottom: 1rem; }
.alert--error { border-color: #7f1d1d; background: rgba(127,29,29,0.4); color: #fecaca; }
.alert--success { border-color: #065f46; background: rgba(6,95,70,0.4); color: #a7f3d0; }
.alert--info { border-color: #075985; background: rgba(7,89,133,0.4); color: #bae6fd; }
.alert__close { background: none; border: none; color: inherit; cursor: pointer; opacity: 0.7; font-size: 1rem; }
.alert__close:hover { opacity: 1; }

/* ---------- Estados ---------- */
.empty { border: 1px dashed var(--border-2); border-radius: var(--radius);
  padding: 3rem 1.5rem; text-align: center; }
.empty__title { color: var(--text); }
.empty__hint { color: var(--faint); font-size: 0.875rem; margin-top: 0.25rem; }
.loading { display: flex; align-items: center; gap: 0.75rem; padding: 2.5rem 0; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 3px solid var(--border-2);
  border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner--sm { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(0,0,0,0.6); padding: 1rem; }
.modal { width: 100%; max-width: 32rem; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--radius); padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5); max-height: 90vh; overflow-y: auto; }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal__title { font-size: 1.125rem; font-weight: 600; }
.modal__close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.125rem; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-box { width: 100%; max-width: 28rem; }
.login-head { text-align: center; margin-bottom: 2rem; }
.login-head__logo { width: 48px; height: 48px; border-radius: 12px; background: var(--brand);
  color: #fff; font-weight: 700; font-size: 1.125rem; display: grid; place-items: center; margin: 0 auto 0.75rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; padding: 0.25rem;
  background: rgba(30,41,59,0.6); border-radius: 8px; margin-bottom: 1.25rem; }
.tab { border: none; background: none; padding: 0.5rem; border-radius: 6px; cursor: pointer;
  color: var(--muted); font-size: 0.875rem; font-weight: 500; font-family: inherit; }
.tab.active { background: var(--brand); color: #fff; }
.login-foot { text-align: center; font-size: 0.75rem; color: var(--faint); margin-top: 1.5rem; }
.w-full { width: 100%; }

/* ---------- Barras (consumo) ---------- */
.bar-row { display: flex; align-items: center; gap: 0.75rem; font-size: 0.75rem; margin-bottom: 0.5rem; }
.bar-row__date { width: 5rem; flex-shrink: 0; color: var(--faint); }
.bar-track { flex: 1; height: 16px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 4px; }
.bar-row__val { width: 5rem; flex-shrink: 0; text-align: right; color: var(--muted); }

/* ---------- Upload progress ---------- */
.upload-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.upload-item { display: flex; align-items: center; justify-content: space-between; font-size: 0.875rem; gap: 1rem; }
.upload-item__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.upload-item__status { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.st-amber { color: var(--amber); }
.st-green { color: #34d399; }
.st-red { color: #f87171; }
.st-faint { color: var(--faint); }

.pager { display: flex; align-items: center; justify-content: space-between;
  font-size: 0.875rem; color: var(--muted); margin-top: 1.5rem; }
.truncate { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-strong { color: var(--text); font-weight: 500; }
.cell-sub { font-size: 0.75rem; color: var(--faint); }
