/* ServerX - shared styles for dashboard, login and public file pages */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --line: #e4e7ec;
  --text: #101319;
  --muted: #667085;
  --accent: #2f6bff;
  --accent-ink: #ffffff;
  --accent-soft: #eaf1ff;
  --ok: #12a150;
  --ok-soft: #e6f6ec;
  --warn: #b26a00;
  --warn-soft: #fdf3e0;
  --bad: #e5484d;
  --bad-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 19, 25, .06), 0 8px 24px rgba(16, 19, 25, .06);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0d1014;
  --panel: #151a21;
  --panel-2: #1c222b;
  --line: #262e39;
  --text: #e9edf3;
  --muted: #93a0b1;
  --accent: #5b8cff;
  --accent-ink: #0b1220;
  --accent-soft: #182339;
  --ok: #3ecf8e;
  --ok-soft: #12281f;
  --warn: #e8b04b;
  --warn-soft: #2a2113;
  --bad: #ff6369;
  --bad-soft: #2c1618;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- shell */
.shell {
  display: grid;
  grid-template-columns: 236px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 22px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }

.logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: .5px;
  flex: none;
}

.brand-txt { display: flex; flex-direction: column; line-height: 1.25; }
.brand-txt strong { font-size: 14.5px; letter-spacing: -.2px; }
.brand-txt small { color: var(--muted); font-size: 11.5px; }

nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  color: var(--muted);
  font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.side-stat {
  font-size: 11.5px;
  color: var(--muted);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  line-height: 1.45;
}

/* ----------------------------------------------------------------- main */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }

.topbar {
  height: 60px;
  flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar-title { font-size: 15px; font-weight: 650; letter-spacing: -.2px; }

.pills { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
}
.pill b { color: var(--text); font-weight: 600; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.pill.on { border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.pill.on .dot { background: var(--ok); }
.pill.off { background: var(--panel-2); }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.warn .dot { background: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.bad .dot { background: var(--bad); }

.content { flex: 1; overflow-y: auto; padding: 24px; }
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }

.tab { display: none; animation: fade .18s ease; }
.tab.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- pieces */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 13.5px; font-weight: 650; letter-spacing: -.1px; }
.card p.hint { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }

.search { flex: 1; position: relative; }
.search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search::before {
  content: "";
  position: absolute; left: 12px; top: 50%;
  width: 13px; height: 13px;
  margin-top: -6px;
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center/contain no-repeat;
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn-danger { color: var(--bad); border-color: var(--line); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad-soft); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------ file list */
.filelist { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }

.group-label {
  padding: 8px 14px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 84px 132px auto;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--panel-2); text-decoration: none; }

.row-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-name .ext { color: var(--muted); }
.row-meta { font-size: 12px; color: var(--muted); text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
.row:hover .row-actions, .row:focus-within .row-actions { opacity: 1; }

.row-ico {
  width: 18px; height: 18px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  flex: none;
  position: relative;
}
.row-ico.ico-html { background: var(--accent-soft); border-color: transparent; }
.row-ico.ico-html::after {
  content: "<>";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font: 700 8px/1 var(--mono);
  color: var(--accent);
}
.row-ico.ico-dir { background: var(--warn-soft); border-color: transparent; }
.row-ico.ico-dir::after {
  content: "";
  position: absolute; left: 3px; right: 3px; top: 5px; bottom: 4px;
  border: 1.5px solid var(--warn);
  border-radius: 2px;
}
.row-ico.ico-image { background: var(--ok-soft); border-color: transparent; }
.row-ico.ico-image::after {
  content: "";
  position: absolute; inset: 4px;
  border-radius: 50%;
  background: var(--ok);
  opacity: .75;
}
.row-ico.ico-code::after, .row-ico.ico-pdf::after, .row-ico.ico-media::after, .row-ico.ico-file::after {
  content: "";
  position: absolute; inset: 4px;
  border: 1.5px solid var(--muted);
  border-radius: 2px;
  opacity: .5;
}
.row-ico.ico-up::after {
  content: "\2191";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 11px; color: var(--muted);
}

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.empty strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 14px; }

/* ------------------------------------------------------------- drop zone */
.dropzone {
  margin-top: 14px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--panel);
  transition: border-color .12s, background .12s;
}
.dropzone.hot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

body.dragging .dropzone { border-color: var(--accent); }

/* ---------------------------------------------------------------- share */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 14px;
}
.seg-btn {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 19, 25, .1);
}

.url-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  margin-bottom: 8px;
}
.url-label { font-size: 11.5px; color: var(--muted); width: 74px; flex: none; text-transform: uppercase; letter-spacing: .05em; }
.url-value {
  font-family: var(--mono);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.url-value a { color: var(--text); }

.secret {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: .06em;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.secret .dots { letter-spacing: .18em; color: var(--muted); }

/* -------------------------------------------------------------- toggles */
.setting {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.setting:last-of-type { border-bottom: 0; }
.setting-body { flex: 1; min-width: 0; }
.setting-title { font-size: 13.5px; font-weight: 550; }
.setting-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.switch {
  position: relative;
  width: 42px; height: 24px;
  border-radius: 999px;
  background: var(--line);
  border: 0;
  cursor: pointer;
  flex: none;
  transition: background .15s;
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .15s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* -------------------------------------------------------------- activity */
.log-row {
  display: grid;
  grid-template-columns: 128px 108px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.log-row:last-child { border-bottom: 0; }
.log-time { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.log-ip { color: var(--muted); font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.log-detail { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.tag.serve { background: var(--panel-2); color: var(--muted); }
.tag.auth { background: var(--accent-soft); color: var(--accent); }
.tag.upload { background: var(--ok-soft); color: var(--ok); }
.tag.delete { background: var(--bad-soft); color: var(--bad); }
.tag.denied { background: var(--bad-soft); color: var(--bad); }
.tag.tunnel { background: var(--warn-soft); color: var(--warn); }

/* ---------------------------------------------------------------- toasts */
.toasts {
  position: fixed;
  right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 340px;
  animation: slide .2s ease;
}
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------- public listing */
.page-body { background: var(--bg); }

.pub-wrap { max-width: 780px; margin: 0 auto; padding: 40px 20px 60px; }

.pub-head { margin-bottom: 18px; }
.pub-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 10px;
}
.pub-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.pub-crumbs { font-size: 20px; font-weight: 650; letter-spacing: -.3px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pub-crumbs a { color: var(--muted); font-weight: 500; }
.pub-crumbs a:hover { color: var(--accent); }
.pub-crumbs .sep { color: var(--line); font-weight: 400; }
.pub-crumbs span { color: var(--text); }

.pub-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.pub-list .row { grid-template-columns: 22px 1fr 84px; }
.pub-list .row-up .row-name { color: var(--muted); }

.pub-empty { padding: 28px 18px; color: var(--muted); text-align: center; margin: 0; }
.pub-foot { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

.err { padding: 44px 28px; text-align: center; }
.err-code { font-size: 44px; font-weight: 750; letter-spacing: -.03em; color: var(--line); line-height: 1; }
.err h1 { font-size: 17px; margin: 10px 0 8px; }
.err .link-btn {
  display: inline-block; margin-top: 8px;
  padding: 9px 14px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 600;
}
.err .link-btn:hover { text-decoration: none; filter: brightness(1.06); }

/* ----------------------------------------------------------------- login */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 366px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px 26px 26px;
  box-shadow: var(--shadow);
}
.login-card .logo { width: 40px; height: 40px; font-size: 14px; margin-bottom: 16px; }
.login-card h1 { font-size: 18px; margin: 0 0 6px; letter-spacing: -.3px; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 550; }
.field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-family: var(--mono);
  letter-spacing: .04em;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; padding: 11px; }
.login-err {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--bad);
  background: var(--bad-soft);
  border-radius: 8px;
  padding: 8px 10px;
  display: none;
}
.login-err.show { display: block; }
.login-foot { margin-top: 18px; font-size: 11.5px; color: var(--muted); text-align: center; }

/* --------------------------------------------------------------- editor */
.editor {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 110px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}
.editor[hidden] { display: none; }

.editor-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.editor-title { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.editor-name {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-meta { font-size: 11px; color: var(--muted); }

.editor-dirty {
  font-size: 11px;
  font-weight: 600;
  color: var(--warn);
  background: var(--warn-soft);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.editor-dirty[hidden] { display: none; }

.editor-body { flex: 1; display: flex; min-height: 0; }

.editor-gutter {
  flex: none;
  width: 54px;
  padding: 14px 10px 14px 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
  background: var(--panel-2);
  border-right: 1px solid var(--line);
  overflow: hidden;
  white-space: pre;
  user-select: none;
}

.editor-body textarea {
  flex: 1;
  height: 100%;
  border: 0;
  outline: none;
  resize: none;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  background: var(--panel);
  color: var(--text);
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

.editor-foot {
  flex: none;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
}
.editor-foot.warn { color: var(--bad); background: var(--bad-soft); }
.editor-foot.ok { color: var(--ok); background: var(--ok-soft); }

.row-name.linkable { cursor: pointer; }
.row-name.linkable:hover { color: var(--accent); text-decoration: underline; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand-txt, .side-foot, .brand { display: none; }
  nav { flex-direction: row; }
  .nav-item span { display: none; }
  .nav-item { padding: 8px; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; height: 54px; }
  .row { grid-template-columns: 22px minmax(0,1fr) auto; }
  .row-meta { display: none; }
  .row-actions { opacity: 1; }
  .url-row { flex-wrap: wrap; }
  .url-label { width: 100%; }
}
