/* NetInteraction Uploads */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cdd5df;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff4ff;
  --success: #15803d;
  --success-soft: #ecfdf3;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --warn-soft: #fffbeb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 650; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding-inline: 20px; }
.page { padding-block: 28px 40px; flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.strong { font-weight: 600; color: var(--text); }
.inline { display: inline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack { display: grid; gap: 14px; }
.stack-lg { display: grid; gap: 20px; align-content: start; }
.back { margin-bottom: 10px; font-size: .9rem; }

/* ---- top bar ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand-name b { color: var(--accent); font-weight: 650; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent);
  display: inline-grid; place-items: center; flex: none;
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark-lg { width: 48px; height: 48px; border-radius: 12px; }
.brand-mark-lg svg { width: 28px; height: 28px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .nav .linklike {
  color: var(--muted); padding: 6px 10px; border-radius: 6px; font: inherit; font-size: .93rem;
}
.nav a:hover, .nav .linklike:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.linklike { background: none; border: 0; cursor: pointer; }

.footer { padding-block: 0 28px; color: var(--muted); font-size: .85rem; }

/* ---- page head ---- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin-top: 4px; }

/* ---- cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.card > h2 { margin-bottom: 14px; }
.card > h2 + p { margin-top: -6px; margin-bottom: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card.narrow { max-width: 480px; }
.card-danger { border-color: #f3c7c7; }
.card-danger h2 { color: var(--danger); }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
@media (max-width: 900px) {
  .admin-grid, .settings-grid { grid-template-columns: 1fr; }
}

/* ---- forms ---- */
label > span { display: block; font-weight: 550; font-size: .9rem; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=search] {
  width: 100%; font: inherit; color: inherit; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
}
input:focus-visible, .btn:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input:focus { border-color: var(--accent); }
label small { display: block; margin-top: 4px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: .93rem; }
.check input { margin-top: 4px; }
.check span { font-weight: 400; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 550; font-size: .9rem; margin-bottom: 5px; padding: 0; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; }
.segmented legend { grid-column: 1 / -1; }
.segmented label {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
}
.segmented label:first-of-type { border-radius: 8px 0 0 8px; }
.segmented label:last-of-type { border-radius: 0 8px 8px 0; border-left: 0; }
.segmented label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 550; }
.segmented label:last-of-type:has(input:checked) { box-shadow: -1px 0 0 var(--accent); }
.search { max-width: 240px; padding: 7px 11px !important; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: .93rem; font-weight: 550; line-height: 1.2;
  padding: 9px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-small { padding: 6px 11px; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn {
  font: inherit; font-size: .83rem; color: var(--muted); background: none; border: 0;
  padding: 4px 8px; border-radius: 6px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---- badges & flashes ---- */
.badge {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: #92400e;
  vertical-align: middle; margin-left: 4px;
}
.badge-muted { background: #f1f5f9; color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.flash {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: .93rem;
  border: 1px solid transparent;
}
.flash-success { background: var(--success-soft); border-color: #bbf0cf; color: #14532d; }
.flash-error { background: var(--danger-soft); border-color: #f6caca; color: #7f1d1d; }
.flash-credentials { background: var(--accent-soft); border-color: #c9d8fb; color: var(--text); }
.credentials {
  background: var(--surface); border: 1px solid #c9d8fb; border-radius: 8px;
  padding: 12px 14px; margin: 10px 0; font: .9rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto; user-select: all;
}

/* ---- auth ---- */
.auth-page { flex: 1; display: grid; place-items: center; padding: 40px 20px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 10px 30px rgba(15, 23, 42, .06); padding: 32px 28px;
  display: grid; gap: 20px;
}
.auth-card .flash { margin: 0; }
.auth-brand { text-align: center; display: grid; justify-items: center; gap: 8px; }
.auth-brand h1 { font-size: 1.35rem; margin-top: 6px; }
.auth-brand h1 b { color: var(--accent); }

/* ---- uploader ---- */
.uploader { margin-bottom: 20px; }
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: 14px; background: var(--surface);
  padding: 34px 20px; text-align: center; display: grid; justify-items: center; gap: 6px;
  transition: border-color .15s, background .15s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon {
  width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft);
  display: grid; place-items: center; margin-bottom: 4px;
}
.dropzone-icon svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dropzone-title { font-size: 1.1rem; font-weight: 600; }
.dropzone-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }

.queue { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 12px; overflow: hidden; }
.queue-head { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.queue-overall { flex: 1; min-width: 120px; }
.queue-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.queue-item { display: grid; grid-template-columns: minmax(0, 1fr) 140px 90px; gap: 12px; align-items: center; padding: 8px 16px; font-size: .88rem; border-bottom: 1px solid var(--border); }
.queue-item:last-child { border-bottom: 0; }
.queue-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-status { text-align: right; color: var(--muted); font-size: .82rem; white-space: nowrap; }
.queue-item.is-done .queue-status { color: var(--success); }
.queue-item.is-error .queue-status { color: var(--danger); white-space: normal; }
.queue-item.is-error { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.queue-item.is-error .bar { display: none; }
.bar { height: 6px; border-radius: 999px; background: #e8edf4; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .2s; }
.is-done .bar span { background: var(--success); }
@media (max-width: 600px) {
  .queue-item { grid-template-columns: minmax(0, 1fr) 70px; }
  .queue-item .bar { grid-column: 1 / -1; grid-row: 2; }
}

/* ---- file browser ---- */
.browser { padding: 0; overflow: visible; }
.browser-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.crumbs a { color: var(--text); }
.crumbs a:last-child { color: var(--accent); }
.crumbs .sep { color: var(--border-strong); }
.browser-actions { display: flex; gap: 8px; align-items: center; }

.popover { position: relative; }
.popover summary { list-style: none; }
.popover summary::-webkit-details-marker { display: none; }
.popover-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 280px; max-width: calc(100vw - 40px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .12); padding: 12px; display: flex; gap: 8px;
}
.popover-body input { padding: 6px 10px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
td { font-size: .92rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.files td:nth-child(3), .list td:nth-child(n+5) { white-space: nowrap; color: var(--muted); }
.files .name { display: flex; align-items: center; gap: 10px; min-width: 260px; }
.files .name a { color: var(--text); font-weight: 500; word-break: break-word; }
.files .name .muted { white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; width: 1%; }
.empty { padding: 44px 20px; text-align: center; display: grid; gap: 4px; }

.ficon { width: 28px; height: 28px; border-radius: 6px; flex: none; display: inline-block; background: #eef2f7 center / 16px no-repeat; }
.ficon-folder { background-color: #fef6e0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23d4a017'%3E%3Cpath d='M3 6a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E"); }
.ficon-image { background-color: #ecfdf3; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2315803d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-5-5L5 21'/%3E%3C/svg%3E"); }
.ficon-media { background-color: #f5f0ff; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%237c3aed'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E"); }
.ficon-archive { background-color: #fff4ec; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c2410c' stroke-width='2' stroke-linecap='round'%3E%3Crect x='4' y='3' width='16' height='18' rx='2'/%3E%3Cpath d='M12 3v2m0 3v2m0 3v2'/%3E%3C/svg%3E"); }
.ficon-doc { background-color: var(--accent-soft); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d4ed8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5M9 13h6M9 17h6'/%3E%3C/svg%3E"); }

@media (max-width: 600px) {
  .wrap { padding-inline: 16px; }
  h1 { font-size: 1.35rem; }
  .card { padding: 18px; }
  .dropzone { padding: 26px 16px; }
  th, td { padding: 9px 12px; }
  .files th:nth-child(3), .files td:nth-child(3) { display: none; }
}

.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.notify-check { margin-top: 6px; font-size: .88rem; color: var(--muted); }
.notify-check input { margin-top: 3px; }
