:root {
  --bg: #0b1120;
  --bg2: #0f172a;
  --card: #111c33;
  --card2: #0d1628;
  --border: #22304c;
  --border-soft: #1a2740;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --muted2: #64748b;
  --accent: #38bdf8;
  --accent2: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, .12);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, .12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, .12);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: radial-gradient(1200px 600px at 80% -10%, #122342 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.hidden { display: none !important; }

/* ------------------------------------------------------------------ login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, #121e37 0%, #0e1729 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 38px 34px 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
.login-logo {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; color: #03121f;
  margin-bottom: 20px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.2px; }
.login-card .sub { color: var(--muted); margin: 0 0 26px; font-size: 13px; }
.login-card .sub .host { color: var(--accent); font-family: var(--mono); font-size: 12px; }
.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; }
.login-card .note { margin-top: 22px; font-size: 11.5px; color: var(--muted2); line-height: 1.6; }

/* ------------------------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 228px;
  flex: 0 0 228px;
  background: rgba(10, 17, 31, .92);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(8px);
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.brand .mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: #03121f; font-weight: 800; font-size: 16px;
}
.brand > div:last-child { min-width: 0; }
.brand .name { font-weight: 700; font-size: 15px; letter-spacing: -.2px; }
.brand .host { color: var(--muted); font-size: 11.5px; font-family: var(--mono); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--muted); cursor: pointer; border: 0; background: none;
  text-align: left; width: 100%; font-weight: 500; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(148, 163, 184, .07); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; font-size: 15px; }
.nav-item .count {
  margin-left: auto; font-size: 11px; background: #1e293b; color: var(--muted);
  padding: 1px 7px; border-radius: 20px; font-family: var(--mono);
}
.nav-sep { height: 1px; background: var(--border-soft); margin: 10px 8px; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--border-soft); font-size: 11px; color: var(--muted2); }
.sidebar-foot .ver { font-family: var(--mono); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex: 0 0 58px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 17, 32, .78);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.2px; }
.topbar .spacer { flex: 1; }
.pill {
  font-size: 11.5px; font-family: var(--mono);
  background: #111d33; border: 1px solid var(--border);
  color: var(--muted); padding: 4px 10px; border-radius: 20px;
}
.content { padding: 26px; max-width: 1400px; width: 100%; }

/* ------------------------------------------------------------------ bits */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: #16223c; color: var(--text);
  border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 550;
  font-size: 13px; transition: background .12s, border-color .12s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: #1c2b4a; border-color: #2f4166; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #03121f; font-weight: 700; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.danger { background: transparent; border-color: rgba(248, 113, 113, .4); color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn.icon { padding: 6px 9px; }

.input, .select, .textarea {
  width: 100%;
  background: #0c1526; border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 12px; color: var(--text);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(14, 165, 233, .15);
}
.input::placeholder { color: var(--muted2); }
.textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--muted2); margin-top: 5px; }

.card {
  background: linear-gradient(180deg, #111c33 0%, #0e1829 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
}
.card h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 650; }
.card .card-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
  background: #1a2740; color: var(--muted);
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

.stat { display: flex; flex-direction: column; gap: 8px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 23px; font-weight: 700; letter-spacing: -.5px; }
.stat .sub { color: var(--muted2); font-size: 11.5px; }
.bar { height: 5px; background: #1a2740; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 4px; }
.bar.warn > span { background: linear-gradient(90deg, #f59e0b, var(--amber)); }
.bar.crit > span { background: linear-gradient(90deg, #dc2626, var(--red)); }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); font-size: 12px; text-align: right; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ files */
.fm-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.fm-path {
  display: flex; align-items: center; gap: 2px; flex: 1; min-width: 240px;
  background: #0c1526; border: 1px solid var(--border); border-radius: 9px;
  padding: 4px 8px; font-family: var(--mono); font-size: 12.5px; overflow-x: auto;
  white-space: nowrap; min-height: 38px;
}
.crumb { color: var(--muted); padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.crumb:hover { background: #16223c; color: var(--text); }
.crumb.last { color: var(--accent); cursor: default; background: none; }
.crumb.sep { color: var(--muted2); padding: 0 1px; }

.fm-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.fm-actions .selinfo { color: var(--muted); font-size: 12px; margin-right: 4px; }
.fm-check { color: var(--green); font-size: 12px; font-family: var(--mono); }

table.files { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.files th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted2); font-weight: 600; padding: 9px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.files th.sortable { cursor: pointer; user-select: none; }
table.files th.sortable:hover { color: var(--text); }
table.files td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
table.files tr.frow:hover td { background: rgba(148, 163, 184, .045); }
table.files tr.frow { cursor: default; }
table.files td.cb, table.files th.cb { width: 34px; padding-right: 0; }
table.files td.size, table.files th.size { text-align: right; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
table.files td.modified, table.files th.modified { font-family: var(--mono); font-size: 11.5px; color: var(--muted2); white-space: nowrap; }
table.files td.perm, table.files th.perm { font-family: var(--mono); font-size: 11.5px; color: var(--muted2); }
table.files td.actions { text-align: right; white-space: nowrap; }
table.files td.actions .act { opacity: 0; transition: opacity .1s; }
table.files tr.row:hover td.actions .act { opacity: 1; }
.fname { display: flex; align-items: center; gap: 9px; min-width: 0; }
.fname .ico { font-size: 16px; width: 20px; text-align: center; flex: 0 0 20px; }
.fname .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.fname .nm.dir { color: var(--accent); }
.fname .nm:hover { text-decoration: underline; }
.fname .lnk { color: var(--amber); font-size: 10px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted2); }

input[type="checkbox"] { accent-color: var(--accent2); width: 15px; height: 15px; cursor: pointer; }

.dropzone.dragover { outline: 2px dashed var(--accent); outline-offset: -8px; background: rgba(56, 189, 248, .04); border-radius: 12px; }
.upload-panel { margin-top: 14px; }
.upload-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 12.5px; }
.upload-item .un { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.upload-item .up { width: 160px; }
.upload-item .pct { width: 44px; text-align: right; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------------ sites */
.site-card { display: flex; flex-direction: column; gap: 12px; }
.site-card .head { display: flex; align-items: flex-start; gap: 10px; }
.site-card .dom { font-size: 16px; font-weight: 700; letter-spacing: -.2px; overflow-wrap: anywhere; }
.site-card .links { display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.site-card .links .row { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.site-card .links .row a { font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
.site-card .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.site-card .actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; padding-top: 4px; }

/* ------------------------------------------------------------------ logs */
.log-view {
  background: #060d1a; border: 1px solid var(--border); border-radius: 10px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
  padding: 14px; max-height: 62vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
  color: #cbd5e1;
}
.log-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.log-bar .grow { flex: 1; min-width: 160px; }

/* ------------------------------------------------------------------ modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(3, 8, 17, .72);
  backdrop-filter: blur(3px); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 22px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh;
  background: #101b30; border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { max-width: 980px; }
.modal.tall { max-height: 88vh; }
.modal .m-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 12px; }
.modal .m-head h3 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; overflow-wrap: anywhere; }
.modal .m-body { padding: 20px 22px; overflow: auto; }
.modal .m-foot { padding: 14px 22px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 9px; }
.modal .m-close { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal .m-close:hover { background: #1a2740; color: var(--text); }
.editor-area { width: 100%; min-height: 46vh; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; background: #060d1a; border: 1px solid var(--border); border-radius: 10px; padding: 12px; color: #dbe7f5; resize: vertical; outline: none; tab-size: 4; }
.editor-area:focus { border-color: var(--accent2); }
.preview-box { text-align: center; }
.preview-box img { max-width: 100%; max-height: 62vh; border-radius: 8px; }
.preview-box video, .preview-box audio { max-width: 100%; }
.preview-box pre { text-align: left; background: #060d1a; border: 1px solid var(--border); border-radius: 10px; padding: 14px; max-height: 62vh; overflow: auto; font-size: 12px; }

/* ------------------------------------------------------------------ misc */
.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(148, 163, 184, .3);
  border-top-color: var(--accent); border-radius: 50%; display: inline-block;
  animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px; justify-content: center; }

.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: 420px; }
.toast {
  background: #12203a; border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 11px 15px; font-size: 12.5px; color: var(--text);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .45); animation: slidein .18s ease-out;
  overflow-wrap: anywhere;
}
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--amber); }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.notice {
  display: flex; gap: 11px; align-items: flex-start;
  border: 1px solid rgba(251, 191, 36, .28); background: var(--amber-soft);
  border-radius: 10px; padding: 12px 15px; font-size: 12.5px; color: #fde68a; line-height: 1.55;
  margin-bottom: 16px;
}
.notice.info { border-color: rgba(56, 189, 248, .28); background: var(--accent-soft); color: #bae6fd; }
.notice .n-ico { font-size: 15px; line-height: 1.2; }

.section-title { display: flex; align-items: center; gap: 12px; margin: 26px 0 14px; }
.section-title:first-child { margin-top: 0; }
.section-title h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.2px; }
.section-title .sp { flex: 1; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }

@media (max-width: 900px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .sidebar { width: 68px; flex: 0 0 68px; }
  .brand .name, .brand .host, .nav-item span:not(.ico):not(.count), .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .nav-item .count { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
