:root {
  color-scheme: dark;
  --bg: #0f1114;
  --panel: #171a1f;
  --panel-2: #1f2329;
  --line: #2b3038;
  --text: #eceef1;
  --muted: #98a0ac;
  --accent: #ff6a3d;
  --accent-ink: #1b0f0a;
  --danger: #ff5c5c;
  --ok: #4cd08a;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, p { margin: 0; }
a { color: inherit; }

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 8px 14px;
  white-space: nowrap;
}
button:hover { border-color: #454c57; }
button:focus-visible, input:focus-visible, a:focus-visible, .repo-card:focus-visible, .dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.small { padding: 4px 10px; font-size: 13px; }
button.ghost { background: none; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); }

input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

label { display: block; color: var(--muted); font-size: 13px; }
label input { margin-top: 4px; color: var(--text); font-size: 15px; }

/* Entrada */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.auth form {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1.5em; }
.hint { color: var(--muted); font-size: 14px; }

/* Estrutura */
header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
}
.top-actions { display: flex; align-items: center; gap: 4px; }
main { max-width: 1040px; margin: 0 auto; padding: 28px 24px 120px; }

.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.title-row h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.015em; overflow-wrap: anywhere; }
.title-row .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.title-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { color: var(--muted); font-size: 14px; text-decoration: none; display: inline-block; margin-bottom: 8px; }
.back:hover { color: var(--text); }

/* Repositórios */
.repos { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.repo-card {
  display: block;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}
.repo-card:hover { border-color: var(--accent); }
.repo-card strong { display: block; font-size: 16px; overflow-wrap: anywhere; }
.repo-card span { color: var(--muted); font-size: 14px; }

.empty {
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px 20px;
}

/* Arquivos */
.dropzone {
  display: block;
  width: 100%;
  text-align: center;
  background: var(--panel);
  border: 1.5px dashed #414955;
  border-radius: var(--radius);
  padding: 28px 16px;
  margin-bottom: 18px;
  color: var(--muted);
  white-space: normal;
}
.dropzone strong { color: var(--text); }
.dropzone:hover, body.dragging .dropzone { border-color: var(--accent); }

.search { margin-bottom: 12px; }

/* Cota e usuários */
.top-link { color: var(--muted); font-size: 13px; text-decoration: none; padding: 4px 10px; }
.top-link:hover { color: var(--text); }
.repo-card .owner { display: block; font-size: 13px; }

.quota { margin-bottom: 18px; }
.quota-text { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 14px; }
.quota.full .bar i { background: var(--danger); }

select {
  width: 100%;
  margin-top: 4px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}
fieldset { display: grid; gap: 8px; margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; }
legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--accent); }
.files.users .name { width: auto; min-width: 120px; }
.files.users .actions { width: 1%; }

.files { width: 100%; border-collapse: collapse; }
.files th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--line);
}
.files td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.files tr:hover td { background: #ffffff05; }
.files .name { width: 100%; word-break: break-word; }
.files .name a { text-decoration: none; }
.files .name a:hover { color: var(--accent); }
.files .num { color: var(--muted); white-space: nowrap; font-size: 14px; }
.files .actions { white-space: nowrap; text-align: right; }
.files .actions button + button { margin-left: 6px; }

/* Bandeja de envio */
#tray {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(400px, calc(100vw - 32px));
  max-height: 55vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px #0009;
  overflow: hidden;
}
.tray-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tray-head strong { font-size: 14px; }
.tray-speed { font: 13px var(--mono); color: var(--accent); margin-left: auto; }
.tray-list { overflow-y: auto; }
.tray-item { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.tray-item:last-child { border-bottom: 0; }
.tray-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.tray-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-status { color: var(--muted); font-size: 12px; margin-top: 4px; }
.tray-item.done .tray-status { color: var(--ok); }
.tray-item.failed .tray-status { color: var(--danger); }
.bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
.tray-item.done .bar i { background: var(--ok); }
.tray-item.failed .bar i { background: var(--danger); }

/* Diálogos e avisos */
dialog {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
dialog::backdrop { background: #0009; }
dialog form { display: grid; gap: 14px; }
dialog h2 { font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 10; }
.toast { background: var(--text); color: var(--bg); border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 500; }
.toast.error { background: var(--danger); color: #240606; }

@media (max-width: 640px) {
  header.top { padding: 12px 16px; }
  main { padding: 20px 16px 120px; }
  .auth form { padding: 22px; }
  .files thead, .files .date { display: none; }
  .files tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .files td { border: 0; padding: 2px; }
  .files .name { grid-column: 1 / -1; }
  .files .actions { text-align: right; }
  .files.users td { grid-column: 1 / -1; }
  .files.users .actions { width: auto; text-align: left; padding-top: 6px; }
  #tray { right: 16px; bottom: 16px; }
}
