:root {
  --bg: #0b0d11;
  --panel: #141821;
  --panel-2: #181d27;
  --border: #242a36;
  --text: #f2f5f4;
  --muted: #8b93a7;
  --green: #5fd07f;
  --green-2: #45a861;
  --danger: #ef7a7a;
  --warning: #e7bd68;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(95, 208, 127, .09), transparent 28rem),
    radial-gradient(circle at 85% 85%, rgba(95, 208, 127, .05), transparent 24rem),
    var(--bg);
}
.auth-shell { width: min(920px, calc(100% - 32px)); display: grid; grid-template-columns: 1fr 420px; align-items: center; gap: 64px; }
.auth-brand { display: flex; align-items: center; gap: 16px; }
.auth-brand h1 { margin: 0 0 6px; font-size: 28px; }
.auth-brand p { margin: 0; color: var(--muted); }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 14px; background: var(--green); color: #07110a;
  font-weight: 900; font-size: 22px; box-shadow: 0 12px 36px rgba(95, 208, 127, .16);
}
.auth-card { background: rgba(20,24,33,.96); border: 1px solid var(--border); border-radius: 20px; padding: 32px; box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.auth-heading { margin-bottom: 24px; }
.auth-heading h2 { margin: 5px 0 8px; font-size: 24px; }
.auth-heading p { margin: 0; color: var(--muted); line-height: 1.7; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field > span { color: var(--muted); font-size: 13px; }
input, select {
  width: 100%; height: 44px; border: 1px solid var(--border); border-radius: 10px;
  background: #0f131a; color: var(--text); outline: none; padding: 0 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(95,208,127,.09); }
input::placeholder { color: #596175; }
.form-error { min-height: 20px; margin: 4px 0 12px; color: var(--danger); font-size: 13px; }
.primary-button, .secondary-button, .text-button, .icon-button {
  border: 0; border-radius: 10px; height: 42px; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.primary-button { background: var(--green); color: #08120b; font-weight: 800; }
.primary-button:hover { background: #70dc8d; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.text-button { background: transparent; color: var(--muted); }
.text-button:hover { color: var(--text); }
.wide { width: 100%; }
.icon-button { width: 42px; background: var(--panel-2); color: var(--text); }
.code-inputs { display: grid; grid-template-columns: repeat(6, 52px); gap: 8px; justify-content: start; }
.code-inputs input { height: 54px; padding: 0; text-align: center; font-size: 22px; font-weight: 800; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; background: #10141b; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 8px; }
.brand .brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 17px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 14px; }
.brand span { color: var(--muted); font-size: 12px; margin-top: 2px; }
.nav-list { display: grid; gap: 4px; margin-top: 28px; }
.nav-item { height: 46px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 12px; padding: 0 12px; text-align: left; }
.nav-item span { width: 18px; text-align: center; font-size: 17px; }
.nav-item b { font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,.025); color: var(--text); }
.nav-item.active { background: rgba(95,208,127,.1); color: var(--green); }
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; }
.connection-pill { height: 36px; border: 1px solid var(--border); border-radius: 9px; display: flex; align-items: center; gap: 8px; padding: 0 10px; color: var(--muted); font-size: 12px; }
.connection-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.connection-pill i.online { background: var(--green); box-shadow: 0 0 12px rgba(95,208,127,.6); }
.connection-pill i.offline { background: var(--danger); }

.main { min-width: 0; }
.topbar { height: 76px; padding: 0 28px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; }
.topbar-kicker { color: var(--muted); font-size: 11px; }
.topbar h1 { margin: 2px 0 0; font-size: 20px; }
.topbar #menu-button { display: none; }
.profile { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.profile img { width: 38px; height: 38px; border-radius: 50%; background: var(--panel-2); object-fit: cover; }
.profile strong, .profile span { display: block; }
.profile strong { font-size: 13px; }
.profile span { color: var(--muted); margin-top: 3px; font-size: 12px; }
.content { max-width: 1440px; padding: 24px 28px 48px; }
.page-section { display: none; }
.page-section.active { display: block; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.stat-card { min-height: 118px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.stat-card span, .stat-card small { color: var(--muted); display: block; }
.stat-card strong { display: block; font-size: 24px; margin: 14px 0 5px; }
.stat-card small { font-size: 12px; }
.grid-two { display: grid; grid-template-columns: 1.35fr .65fr; gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.panel-heading { min-height: 72px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.panel-heading h2, .inline-title { margin: 4px 0 0; font-size: 16px; }
.list { min-height: 220px; }
.status-detail { min-height: 220px; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 20px; }
.status-ring { width: 92px; height: 92px; border-radius: 50%; border: 7px solid rgba(95,208,127,.18); border-top-color: var(--green); display: grid; place-content: center; text-align: center; }
.status-ring span { font-size: 22px; font-weight: 800; }
.status-ring small { color: var(--muted); }
.status-detail b { display: block; margin-bottom: 8px; }
.status-detail p { margin: 0; max-width: 180px; color: var(--muted); line-height: 1.6; }

.toolbar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.segmented { height: 38px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 3px; display: flex; }
.segmented button { height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); padding: 0 12px; }
.segmented button.active { background: var(--panel-2); color: var(--text); }
.task-list, .file-list, .server-list { min-height: 300px; }
.task-row, .file-row, .server-row { min-height: 68px; padding: 12px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.task-row:last-child, .file-row:last-child, .server-row:last-child { border-bottom: 0; }
.task-main, .file-main, .server-main { min-width: 0; flex: 1; }
.task-main b, .file-main b, .server-main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-main p, .file-main p, .server-main p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.state { padding: 5px 8px; border-radius: 999px; font-size: 11px; background: var(--panel-2); color: var(--muted); }
.state.running { color: var(--green); background: rgba(95,208,127,.1); }
.state.failed { color: var(--danger); background: rgba(239,122,122,.1); }
.state.done { color: #91a0ca; background: rgba(145,160,202,.1); }
.row-actions { display: flex; gap: 6px; }
.row-actions button { height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--muted); padding: 0 10px; }
.row-actions button:hover { color: var(--text); }
.empty-state { min-height: 300px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state b { color: var(--text); margin-bottom: 6px; }

.upload-progress { height: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.upload-progress span { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }
.setting-row { min-height: 84px; padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.setting-row b { display: block; }
.setting-row p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.switch input { display: none; }
.switch span { width: 42px; height: 24px; border-radius: 999px; background: #303746; display: block; position: relative; }
.switch span::after { content:""; position:absolute; width:18px; height:18px; border-radius:50%; top:3px; left:3px; background:white; transition:.18s; }
.switch input:checked + span { background: var(--green-2); }
.switch input:checked + span::after { transform: translateX(18px); }
.trusted-list, .account-list { padding: 12px 18px; }
.trusted-row, .account-row { min-height: 52px; border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.trusted-row:last-child, .account-row:last-child { border-bottom:0; }
.trusted-row small { display:block; color:var(--muted); margin-top:4px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr auto; align-items:end; gap:12px; padding:18px; border-bottom:1px solid var(--border); }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; background: rgba(5,7,10,.72); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(680px, 100%); max-height: calc(100vh - 40px); overflow: hidden; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; display: grid; grid-template-rows: auto 1fr auto; }
.modal-header { height: 76px; padding: 14px 18px; border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.modal-header h2 { margin: 4px 0 0; font-size: 18px; }
.modal-body { overflow: auto; padding: 18px; }
.modal-footer { min-height: 66px; padding: 12px 18px; border-top: 1px solid var(--border); display:flex; justify-content:flex-end; gap:8px; }
.form-grid-modal { display:grid; grid-template-columns:1fr 1fr; gap:0 12px; }
.form-grid-modal .full { grid-column:1/-1; }
.task-builder { display:grid; gap:10px; }
.task-step { border:1px solid var(--border); border-radius:10px; padding:12px; background:var(--panel-2); }
.task-step-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.task-step select { margin-bottom:10px; }

.toast-region { position: fixed; z-index: 30; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast { min-width: 240px; max-width: 360px; border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 10px; background: #191f29; padding: 12px 14px; box-shadow: 0 12px 30px rgba(0,0,0,.28); animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--green); }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content:center; padding:0; }
  .brand > div:last-child, .nav-item b, .connection-pill span { display:none; }
  .nav-item { justify-content:center; padding:0; }
  .connection-pill { justify-content:center; padding:0; }
  .stats-grid { grid-template-columns:1fr 1fr; }
  .grid-two { grid-template-columns:1fr; }
}
@media (max-width: 680px) {
  .auth-shell { grid-template-columns:1fr; gap:24px; }
  .auth-brand { justify-content:center; }
  .auth-brand h1 { font-size:22px; }
  .app-shell { display:block; }
  .sidebar { position:fixed; z-index:10; left:-220px; width:220px; transition:.2s; }
  .sidebar.open { left:0; box-shadow:20px 0 60px rgba(0,0,0,.45); }
  .sidebar.open .brand > div:last-child, .sidebar.open .nav-item b, .sidebar.open .connection-pill span { display:block; }
  .sidebar.open .nav-item { justify-content:flex-start; padding:0 12px; }
  .topbar { padding:0 16px; }
  .topbar #menu-button { display:inline-flex; }
  .profile div { display:none; }
  .content { padding:16px 12px 40px; }
  .stats-grid { grid-template-columns:1fr 1fr; }
  .stat-card { min-height:100px; }
  .form-grid-modal { grid-template-columns:1fr; }
  .form-grid-modal .full { grid-column:auto; }
  .form-grid { grid-template-columns:1fr; }
  .toolbar { gap:8px; }
  .task-row { align-items:flex-start; flex-wrap:wrap; }
  .row-actions { width:100%; }
}
