:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2b313c;
  --text: #e7eaf0;
  --muted: #9aa3b2;
  --accent: #4cff8f;
  --accent-2: #6dffa6;
  --green: #3ecf8e;
  --red: #ff6b6b;
  --orange: #ffb84d;
  --blue: #5aa9ff;
  --radius: 14px;
  --maxw: 760px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Vazirmatn, Tahoma, system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body { direction: ltr; }

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

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15,17,21,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem .9rem;
}
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .4rem; }
.brand .dot { color: var(--accent); }
.nav { margin-inline-start: auto; display: flex; gap: .25rem; align-items: center; }
.nav a {
  color: var(--muted); padding: .45rem .6rem; border-radius: 10px;
  font-size: .9rem; white-space: nowrap;
}
.nav a.active, .nav a:hover { color: var(--text); background: var(--surface-2); }
.nav .user { color: var(--muted); font-size: .8rem; padding-inline: .4rem; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 1rem .9rem 4rem; }

h1 { font-size: 1.3rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.card > .card-title {
  font-weight: 600; font-size: .95rem; margin: 0 0 .8rem;
  display: flex; align-items: center; gap: .45rem;
}
.hint { color: var(--muted); font-size: .8rem; margin-top: .35rem; }

/* ---------- forms ---------- */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
input[type=text], input[type=password], input[type=url], textarea, select {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: .7rem .8rem; font-size: 1rem; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.field { margin-bottom: .9rem; }
.row { display: flex; gap: .7rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 200px; }

/* segmented toggle */
.seg { display: flex; gap: .4rem; flex-wrap: wrap; }
.seg label {
  flex: 1 1 auto; margin: 0; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: .6rem .5rem; text-align: center;
  color: var(--text); font-size: .9rem; transition: .15s;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: #06210f; }
.seg label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #06210f; font-weight: 600; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--accent); color: #06210f; border: none; cursor: pointer;
  border-radius: 11px; padding: .8rem 1.1rem; font-size: 1rem; font-weight: 600;
  font-family: inherit;
}
.btn:hover { background: var(--accent-2); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---------- log console ---------- */
.console {
  background: #0a0c10; border: 1px solid var(--border); border-radius: 12px;
  padding: .8rem; font-family: "SF Mono", Consolas, monospace; font-size: .82rem;
  line-height: 1.5; height: 60vh; overflow-y: auto; direction: ltr; text-align: left;
  white-space: pre-wrap; word-break: break-word;
}
.console .l-error { color: var(--red); }
.console .l-success { color: var(--green); }
.console .l-warn { color: var(--orange); }
.console .l-info { color: var(--blue); }

/* ---------- badges & lists ---------- */
.badge {
  font-size: .72rem; padding: .2rem .55rem; border-radius: 999px; font-weight: 600;
  border: 1px solid var(--border);
}
.badge.queued { color: var(--muted); }
.badge.running { color: var(--accent); border-color: var(--accent); }
.badge.done { color: var(--green); border-color: var(--green); }
.badge.error { color: var(--red); border-color: var(--red); }
.badge.stopped { color: var(--orange); border-color: var(--orange); }
.badge.interrupted { color: var(--red); border-color: var(--red); }

.job-item {
  display: flex; align-items: center; gap: .7rem; padding: .8rem .2rem;
  border-bottom: 1px solid var(--border);
}
.job-item:last-child { border-bottom: none; }
.job-item .meta { flex: 1; min-width: 0; }
.job-item .meta .f { font-weight: 600; }
.job-item .meta .t { color: var(--muted); font-size: .78rem; }

.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 360px; }
.alert { background: rgba(255,107,107,.12); border: 1px solid var(--red); color: #ffd0d0;
  border-radius: 10px; padding: .6rem .8rem; font-size: .85rem; margin-bottom: .9rem; }
.notice { background: rgba(62,207,142,.12); border: 1px solid var(--green); color: #c8ffe6;
  border-radius: 10px; padding: .6rem .8rem; font-size: .85rem; margin-bottom: .9rem; }

.divider { height: 1px; background: var(--border); margin: 1rem 0; border: none; }
.small { font-size: .82rem; color: var(--muted); }
table.users { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.users td, table.users th { text-align: left; padding: .5rem .3rem; border-bottom: 1px solid var(--border); }

.hide { display: none !important; }

@media (min-width: 620px) {
  h1 { font-size: 1.5rem; }
}

/* ---------- file manager ---------- */
.files-toolbar { display: flex; gap: .5rem; margin-bottom: .8rem; flex-wrap: wrap; }
.files-toolbar #search { flex: 1 1 160px; }
.files-toolbar select { flex: 0 0 auto; width: auto; }
.files-toolbar .btn { padding: .55rem .7rem; font-size: .85rem; }
.copy-btn {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: .35rem .55rem; cursor: pointer; font-size: .95rem; flex: 0 0 auto;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%) translateY(2rem);
  background: var(--accent); color: #06210f; font-weight: 600; font-size: .85rem;
  padding: .55rem 1rem; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: .2s; z-index: 50; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- paste buttons on form fields ---------- */
.paste-group { display: flex; gap: .4rem; align-items: stretch; }
.paste-group input { flex: 1 1 auto; min-width: 0; }
.paste-btn {
  flex: 0 0 auto; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 10px; padding: 0 .7rem;
  cursor: pointer; font-size: 1rem;
}
.paste-btn:hover { color: var(--accent); border-color: var(--accent); }
