:root {
  --bg: #0c0e12;
  --bg-glow: rgba(255, 122, 24, 0.07);
  --card: #15181f;
  --card-hover: #1a1e27;
  --line: #262b36;
  --text: #e8eaf0;
  --muted: #8b93a3;
  --tiger: #ff7a18;
  --tiger-bright: #ffa040;
  --tiger-dim: rgba(255, 122, 24, 0.12);
  --danger: #e5484d;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg) radial-gradient(ellipse 80% 40% at 50% -10%, var(--bg-glow), transparent);
  color: var(--text);
}
header {
  background: rgba(21, 24, 31, 0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1.1rem;
  padding: .8rem 1.4rem; position: sticky; top: 0;
}
header .brand {
  display: flex; align-items: center; gap: .6rem; text-decoration: none;
}
header .brand-logo {
  height: 26px; width: auto; display: block;
}
header .spacer { flex: 1; }
header a { color: var(--muted); text-decoration: none; font-size: .9rem;
           padding: .35rem .7rem; border-radius: 6px; transition: all .15s; }
header a:hover { color: var(--tiger-bright); background: var(--tiger-dim); }
main { max-width: 920px; margin: 2rem auto; padding: 0 1.2rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.4rem 1.6rem; margin-bottom: 1.2rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .35);
}
h2, h3 { margin-top: 0; letter-spacing: .01em; }
.flash {
  background: var(--tiger-dim); border: 1px solid rgba(255, 122, 24, .35);
  color: var(--tiger-bright); border-radius: 10px;
  padding: .65rem 1rem; margin-bottom: 1.1rem; font-size: .92rem;
}
input[type=text], input[type=email] {
  padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: 1rem; width: 100%; max-width: 340px;
  background: #0f1218; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, input[type=email]:focus {
  border-color: var(--tiger); box-shadow: 0 0 0 3px var(--tiger-dim);
}
input::placeholder { color: #5a6272; }
input[type=file] { color: var(--muted); font-size: .9rem; }
input[type=file]::file-selector-button {
  background: transparent; color: var(--tiger-bright);
  border: 1px solid var(--tiger); border-radius: 7px;
  padding: .45rem .8rem; margin-right: .7rem; cursor: pointer;
  transition: background .15s;
}
input[type=file]::file-selector-button:hover { background: var(--tiger-dim); }
button {
  background: linear-gradient(135deg, var(--tiger), #ff8f33);
  color: #14100b; font-weight: 650; border: 1px solid transparent; border-radius: 8px;
  padding: .55rem 1.1rem; font-size: .92rem; line-height: 1.2; cursor: pointer;
  transition: filter .15s, transform .1s;
}
button:hover { filter: brightness(1.12); }
button:active { transform: translateY(1px); }
button.danger {
  background: transparent; color: var(--danger);
  border: 1px solid rgba(229, 72, 77, .5); font-weight: 500;
  padding: .35rem .8rem; font-size: .85rem;
}
button.danger:hover { background: rgba(229, 72, 77, .12); filter: none; }
button.ghost {
  background: transparent; color: var(--tiger-bright);
  border: 1px solid var(--tiger); font-weight: 500;
}
button.ghost:hover { background: var(--tiger-dim); filter: none; }
a.btn {
  display: inline-block; text-decoration: none; background: transparent;
  color: var(--tiger-bright); border: 1px solid var(--tiger); border-radius: 8px;
  padding: .55rem 1.1rem; font-size: .92rem; line-height: 1.2; font-weight: 500;
}
a.btn:hover { background: var(--tiger-dim); text-decoration: none; }
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase;
     letter-spacing: .08em; font-weight: 600; }
th, td { text-align: left; padding: .6rem .55rem;
         border-bottom: 1px solid var(--line); font-size: .93rem; }
tr:last-child td { border-bottom: 0; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th .sort-arrow { color: var(--tiger-bright); font-size: .9em; }
tbody tr:hover td, table tr:hover td { background: var(--card-hover); }
table tr:first-child:hover th { background: transparent; }
td.actions { text-align: right; white-space: nowrap; }
a { color: var(--tiger-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
.crumbs { font-size: .92rem; margin-bottom: 1rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--tiger-bright); text-decoration: none; }
.crumbs .home-ico {
  width: 1em; height: 1em; fill: currentColor;
  vertical-align: -0.13em; margin-right: .3em;
}
.muted { color: var(--muted); font-size: .85rem; }
code { background: #0f1218; border: 1px solid var(--line); border-radius: 5px;
       padding: .1rem .35rem; font-size: .85em; color: var(--tiger-bright); }
form.inline { display: inline; }
.toolbar { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.badge {
  display: inline-block; font-size: .72rem; font-weight: 600;
  color: var(--tiger-bright); background: var(--tiger-dim);
  border: 1px solid rgba(255, 122, 24, .3); border-radius: 99px;
  padding: .12rem .6rem; letter-spacing: .04em;
}
.auth-wrap { max-width: 420px; margin: 8vh auto 0; }
.auth-wrap .card { padding: 2rem 2.2rem; }
.portal-name {
  font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; white-space: nowrap;
  background: linear-gradient(110deg, var(--tiger), var(--tiger-bright));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---- upload: drop overlay + progress panel (persistent shell) ---- */
#drop-overlay {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: rgba(12, 14, 18, 0.8); backdrop-filter: blur(2px); padding: 2rem;
}
#drop-overlay.active { display: block; }
#drop-overlay .drop-box {
  height: 100%; display: flex; align-items: center; justify-content: center;
  gap: .5rem; border: 2px dashed var(--tiger); border-radius: 18px;
  font-size: 1.3rem; color: var(--tiger-bright); background: var(--tiger-dim);
  pointer-events: none;
}
/* Blocking modal (mirrors #zip-panel / #confirm-modal): the full-screen backdrop
   intercepts pointer events to the file grid and nav, so once an upload starts
   the user waits it out instead of queuing more work onto the server. */
#upload-panel {
  position: fixed; inset: 0; z-index: 70; display: none;
  align-items: center; justify-content: center; padding: 1.5rem;
  background: rgba(8, 9, 12, 0.72); backdrop-filter: blur(3px);
  font-size: .9rem;
}
#upload-panel:not([hidden]) { display: flex; }
#upload-panel .modal-box { padding: 0; overflow: hidden; border-color: var(--tiger); }
.up-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem .9rem; border-bottom: 1px solid var(--line);
  background: var(--tiger-dim); color: var(--tiger-bright); font-weight: 500;
}
#up-cancel-all {
  background: transparent; border: none; color: var(--muted);
  font-size: .82rem; cursor: pointer; padding: .15rem .4rem;
}
#up-cancel-all:hover { color: var(--danger); filter: none; }
#up-list { max-height: 300px; overflow-y: auto; padding: .3rem 0; }
.up-row { padding: .45rem .9rem; }
.up-row + .up-row { border-top: 1px solid rgba(255,255,255,.04); }
.up-row-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.up-name {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text);
}
.up-pct { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .82rem; }
.up-cancel {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .2rem;
}
.up-cancel:hover { color: var(--danger); filter: none; }
.up-track { height: 6px; border-radius: 3px; background: var(--tiger-dim); overflow: hidden; }
.up-fill {
  height: 100%; width: 0; border-radius: 3px;
  background: var(--tiger-bright); transition: width .15s linear;
}
.up-row.error .up-fill, .up-row.cancelled .up-fill { background: var(--danger); }
.up-row.error .up-pct { color: var(--danger); }
.up-row.done .up-cancel, .up-row.error .up-cancel, .up-row.cancelled .up-cancel {
  visibility: hidden;
}

/* ---- coded confirmation dialog (replaces window.confirm) ---- */
#confirm-modal, #prompt-modal {
  position: fixed; inset: 0; z-index: 70; display: none;
  align-items: center; justify-content: center; padding: 1.5rem;
  background: rgba(8, 9, 12, 0.72); backdrop-filter: blur(3px);
}
#confirm-modal:not([hidden]), #prompt-modal:not([hidden]) { display: flex; }
.modal-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .6);
  padding: 1.5rem 1.6rem; max-width: 420px; width: 100%;
}
.modal-box p { margin: 0 0 1.3rem; font-size: 1rem; line-height: 1.5; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: .7rem; }
#confirm-ok { padding: .5rem 1.1rem; }
#confirm-ok.danger {
  background: var(--danger); color: #fff; border: 0; font-weight: 600; border-radius: 8px;
}
#confirm-ok:hover { filter: brightness(1.1); }

/* ---- selection + zip-download ---- */
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
button.ghost:disabled:hover { background: transparent; color: var(--tiger-bright); }
/* Delete-selected: danger colours but normal button sizing (matches the
   ghost buttons), unlike the small .danger pill used elsewhere. */
#delete-selected {
  background: transparent; color: var(--danger);
  border: 1px solid rgba(229, 72, 77, .5); font-weight: 500;
}
#delete-selected:hover:not(:disabled) { background: rgba(229, 72, 77, .12); filter: none; }
#prompt-input {
  width: 100%; margin: 0 0 1.3rem; padding: .55rem .8rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: #0f1218; color: var(--text); font-size: 1rem; outline: none;
}
#prompt-input:focus { border-color: var(--tiger); box-shadow: 0 0 0 3px var(--tiger-dim); }
.cbcol { width: 1%; white-space: nowrap; text-align: center; }
.cbcol input { cursor: pointer; }
#file-table td { cursor: pointer; user-select: none; }
#file-table tr.selected td { background: var(--tiger-dim); }
/* Blocking modal (mirrors #confirm-modal): the full-screen backdrop intercepts
   pointer events to the file grid and nav, so the zip build can't be raced by
   more uploads/zips that would pile work onto the single worker. */
#zip-panel {
  position: fixed; inset: 0; z-index: 70; display: none;
  align-items: center; justify-content: center; padding: 1.5rem;
  background: rgba(8, 9, 12, 0.72); backdrop-filter: blur(3px);
  font-size: .9rem;
}
#zip-panel:not([hidden]) { display: flex; }
#zip-panel .modal-box { padding: 0; overflow: hidden; border-color: var(--tiger); }
#zip-panel .zip-body { padding: .8rem .95rem 1rem; }
#zip-status { margin-top: .45rem; }
#zip-cancel {
  background: transparent; border: none; color: var(--muted);
  font-size: .82rem; cursor: pointer; padding: .15rem .4rem;
}
#zip-cancel:hover { color: var(--danger); filter: none; }

/* ---- toast notifications ---- */
#toast-container {
  position: fixed; top: 1rem; right: 1rem; z-index: 80;
  display: flex; flex-direction: column; gap: .5rem; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: var(--card); border: 1px solid var(--tiger); color: var(--text);
  border-radius: 10px; padding: .6rem 1rem; font-size: .9rem; max-width: 340px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  pointer-events: auto; cursor: pointer;
  animation: toast-in .2s ease-out;
}
.toast.out { animation: toast-out .3s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ---- version badge ---- */
#version-badge {
  position: fixed; bottom: .5rem; right: .6rem; z-index: 70;
  color: var(--muted); font-size: .72rem; opacity: .6;
  pointer-events: none; user-select: none;
}
