:root {
  --bg: #eef1f5; --panel: #fff; --fg: #1f2937; --muted: #6b7280; --line: #dde2e9; --head: #f7f9fb;
  --top: #1b2a41; --top-fg: #e8eef7; --blue: #1f6fd1; --green: #17a34a; --green-d: #128a3e; --red: #d93a3a; --amber: #c47f00;
  --hover: #f2f6fb;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--fg); min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 17px; margin: 0 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
svg.i { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- top bar ---------- */
.topbar { background: var(--top); color: var(--top-fg); display: flex; align-items: center; gap: 18px; padding: 0 22px; height: 60px; position: sticky; top: 0; z-index: 5; box-shadow: 0 2px 6px #0002; }
.brand { color: #fff; font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { background: var(--blue); border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center; }
.brand-mark svg { width: 20px; height: 20px; }
.search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; background: #ffffff14; border: 1px solid #ffffff26; border-radius: 8px; padding: 0 12px; }
.search input { flex: 1; background: transparent; border: 0; color: #fff; font: inherit; padding: 9px 0; outline: none; min-width: 0; }
.search input::placeholder { color: #c3cddc; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill { display: flex; align-items: center; gap: 8px; font-size: 13px; background: #ffffff12; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #ef4444; }
.pill.on .dot { background: #22c55e; box-shadow: 0 0 0 3px #22c55e40; }
.pill.busy .dot { background: #f59e0b; }
.top-btn { all: unset; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 10px; border-radius: 6px; }
.top-btn:hover { background: #ffffff1a; }

main { max-width: 1280px; margin: 0 auto; padding: 24px 22px 60px; }
.page { display: none; }
.page.active { display: block; }

/* ---------- buttons & inputs ---------- */
.btn { font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--fg); padding: 9px 16px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover { background: var(--green-d); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.red { color: var(--red); border-color: #f0c4c4; }
.btn.red:hover { background: #fdf1f1; }
.btn.huge { width: 100%; font-size: 18px; padding: 15px; margin-top: 14px; border-radius: 10px; }
.btn.sm { padding: 6px 11px; font-size: 13.5px; }
.btn:disabled { opacity: .6; cursor: wait; }
.link-btn { all: unset; cursor: pointer; color: var(--blue); font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select { font: inherit; font-weight: 400; color: var(--fg); background: #fff; border: 1px solid #c9d1dc; border-radius: 8px; padding: 10px 12px; min-width: 0; }
input:focus, select:focus { outline: 3px solid #1f6fd133; border-color: var(--blue); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin: 14px 0; align-items: end; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.row.end { justify-content: flex-end; }
details.advanced { margin-top: 14px; }
details.advanced > summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: 14px; }
details.advanced[open] > summary { margin-bottom: 10px; }
details.advanced label { margin-top: 10px; }

/* ---------- boxes ---------- */
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 20px; overflow: hidden; }
.box.wide { padding: 24px; }
.box-head { background: var(--head); border-bottom: 1px solid var(--line); padding: 12px 18px; font-weight: 700; font-size: 15px; }
.box.wide > .box-head { margin: -24px -24px 18px; }
.pad { padding: 0; }
.crumb { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.page-title { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.title-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- home ---------- */
.home { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.group .box-head { display: flex; align-items: center; gap: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; padding: 14px; }
.tile { all: unset; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.tile:hover, .tile:focus-visible { background: var(--hover); outline: 2px solid #1f6fd122; }
.tile-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; color: #fff; flex: none; }
.tile-icon svg { width: 26px; height: 26px; }
.page-title .tile-icon { width: 58px; height: 58px; }
.page-title .tile-icon svg { width: 32px; height: 32px; }
.c-blue { background: linear-gradient(135deg, #2f80ed, #1c5fc0); }
.c-teal { background: linear-gradient(135deg, #14b8a6, #0d8a7c); }
.c-green { background: linear-gradient(135deg, #22c55e, #15913f); }
.c-orange { background: linear-gradient(135deg, #f59e0b, #d9730a); }
.c-purple { background: linear-gradient(135deg, #8b5cf6, #6537d6); }
.c-red { background: linear-gradient(135deg, #f43f5e, #c81e3f); }
.c-gray { background: linear-gradient(135deg, #64748b, #45536a); }
.c-indigo { background: linear-gradient(135deg, #6366f1, #4338ca); }
.no-results { padding: 30px; text-align: center; color: var(--muted); }

.facts { margin: 0; padding: 6px 18px 14px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid #eef1f4; font-size: 14px; }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; word-break: break-word; }
.stat { padding: 12px 18px; border-bottom: 1px solid #eef1f4; }
.stat:last-child { border-bottom: 0; }
.stat-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.stat-top b { font-weight: 600; }
.meter { height: 8px; background: #e7ebf0; border-radius: 4px; overflow: hidden; }
.meter > div { height: 100%; background: var(--green); border-radius: 4px; }
.meter.warn > div { background: var(--amber); }
.meter.bad > div { background: var(--red); }

.notice { display: flex; align-items: center; gap: 16px; background: #eaf7ee; border: 1px solid #b7e2c4; border-radius: 10px; padding: 16px 20px; margin-bottom: 20px; flex-wrap: wrap; }
.notice > div { flex: 1; min-width: 240px; }
.notice-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; }
.notice-icon svg { width: 24px; height: 24px; }

/* ---------- login ---------- */
.login-card { max-width: 440px; margin: 40px auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 34px; box-shadow: 0 10px 30px #1b2a4114; text-align: center; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.login-icon { width: 64px; height: 64px; border-radius: 16px; background: var(--blue); color: #fff; display: grid; place-items: center; margin: 0 auto 14px; }
.login-icon svg { width: 34px; height: 34px; }

/* ---------- install wizard ---------- */
.stepbox { display: flex; gap: 18px; padding: 20px 0; border-top: 1px solid #eef1f4; }
.step-num { width: 38px; height: 38px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 700; font-size: 18px; display: grid; place-items: center; flex: none; }
.step-body { flex: 1; min-width: 0; }
.step-body p { margin: 4px 0 10px; }
.addr { display: flex; align-items: stretch; border: 2px solid #c9d1dc; border-radius: 10px; overflow: hidden; max-width: 640px; background: #fff; flex-wrap: wrap; }
.addr:focus-within { border-color: var(--blue); }
.addr input, .addr select { border: 0; border-radius: 0; font-size: 18px; padding: 12px; outline: none; }
.addr input { flex: 1; min-width: 120px; font-weight: 600; }
.addr select { background: #f7f9fb; border-left: 1px solid #e3e8ee; min-width: 0; }
.addr-pre, .addr-dot { display: grid; place-items: center; padding: 0 4px 0 12px; color: var(--muted); font-size: 18px; }
.addr-dot { padding: 0 2px; }
.dns-table { border-collapse: collapse; margin: 6px 0 12px; font-size: 15px; }
.dns-table th, .dns-table td { border: 1px solid var(--line); padding: 8px 14px; text-align: left; }
.dns-table th { background: var(--head); font-size: 13px; color: var(--muted); }
.dns-table td { font-family: Consolas, ui-monospace, monospace; font-weight: 600; }
.dns-status { margin-bottom: 10px; }
.status-msg { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; font-size: 14.5px; }
.status-msg.ok { background: #eaf7ee; color: #12632f; }
.status-msg.warn { background: #fff6e5; color: #7a4f00; }
.status-msg.bad { background: #fdeeee; color: #8f1f1f; }

/* ---------- sites ---------- */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.site-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.site-name { font-weight: 700; font-size: 17px; word-break: break-all; display: flex; align-items: center; gap: 8px; }
.site-meta { font-size: 13px; color: var(--muted); }
.site-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.tag.ok { background: #e3f6e9; color: #12632f; }
.tag.warn { background: #fff1d6; color: #7a4f00; }
.tag.info { background: #e6effb; color: #164f9c; }
.empty { background: #fff; border: 2px dashed var(--line); border-radius: 12px; padding: 40px; text-align: center; color: var(--muted); grid-column: 1 / -1; }

.list-table { width: 100%; border-collapse: collapse; }
.list-table th, .list-table td { padding: 12px 10px; border-bottom: 1px solid #eef1f4; text-align: left; }
.list-table th { font-size: 13px; color: var(--muted); }
.list-table td:last-child { text-align: right; }

/* ---------- file manager ---------- */
.fm { padding: 0 !important; }
.fm.drag { outline: 3px dashed var(--blue); outline-offset: -8px; }
.fm-tools { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 12px; background: var(--head); border-bottom: 1px solid var(--line); }
.tool { all: unset; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: #334155; min-width: 70px; text-align: center; }
.tool svg { width: 24px; height: 24px; color: var(--blue); }
.tool:hover { background: #e6edf6; }
.tool.danger, .tool.danger svg { color: var(--red); }
.fm-path { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.fm-path > svg { color: #e0a100; }
#crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
#crumbs a { cursor: pointer; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
#crumbs a:hover { background: var(--hover); }
#crumbs .sep { color: var(--muted); }
.fm-hint { padding: 12px 16px; background: #fff6e5; color: #7a4f00; border-bottom: 1px solid #f3dfb5; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table.files { width: 100%; border-collapse: collapse; }
table.files th, table.files td { padding: 10px 14px; border-bottom: 1px solid #eef1f4; text-align: left; white-space: nowrap; }
table.files th { font-size: 13px; color: var(--muted); background: #fff; }
table.files tbody tr:hover td { background: var(--hover); }
table.files .num { text-align: right; }
table.files .r { text-align: right; }
table.files .cb { width: 38px; }
table.files td.name { white-space: normal; word-break: break-all; }
.fname { display: inline-flex; align-items: center; gap: 10px; cursor: default; font-weight: 500; }
.fname svg { width: 22px; height: 22px; }
.fname.dir { cursor: pointer; color: var(--fg); font-weight: 600; }
.fname.dir svg { color: #e0a100; }
.fname.file svg { color: #7b8796; }
.fname.zip svg { color: var(--purple, #7c3aed); }
.fname.dir:hover span { color: var(--blue); text-decoration: underline; }
.racts { display: flex; gap: 4px; justify-content: flex-end; }
.racts button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 5px 8px; border-radius: 6px; color: #475569; }
.racts button:hover { background: #e6edf6; color: var(--blue); }
.racts button.del:hover { background: #fdeeee; color: var(--red); }
.drop-hint { display: flex; align-items: center; gap: 8px; padding: 14px 16px; font-size: 13.5px; color: var(--muted); }
.upload-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f3f8ff; font-size: 14px; font-weight: 600; }
.bar { flex: 1; height: 10px; background: #dbe5f1; border-radius: 5px; overflow: hidden; }
#uploadFill { height: 100%; width: 0; background: var(--blue); transition: width .2s; }

/* ---------- status ---------- */
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.scard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.scard .k { font-size: 13px; color: var(--muted); }
.scard .v { font-size: 17px; font-weight: 700; margin-top: 2px; word-break: break-word; }
.scard .v.ok { color: var(--green); }
.scard .v.bad { color: var(--red); }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 14px; padding: 26px; width: min(620px, calc(100vw - 32px)); box-shadow: 0 20px 60px #0004; color: var(--fg); }
dialog::backdrop { background: #0f172a99; }
#askDlg { width: min(460px, calc(100vw - 32px)); }
#askBody { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.job-head { display: flex; align-items: center; gap: 12px; }
.job-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--blue); flex: none; }
.job-icon svg { width: 22px; height: 22px; }
.job-icon.ok { background: var(--green); }
.job-icon.bad { background: var(--red); }
.job-icon.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 10px; background: #e7ebf0; border-radius: 5px; overflow: hidden; margin: 18px 0 14px; }
#jobFill { height: 100%; width: 3%; background: var(--blue); transition: width .4s; }
#jobFill.ok { background: var(--green); }
#jobFill.bad { background: var(--red); }
.job-steps { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
.job-steps li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.job-steps .mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 700; color: #fff; }
.job-steps li.doing .mark { border: 3px solid #cfe0f6; border-top-color: var(--blue); animation: spin .8s linear infinite; }
.job-steps li.done .mark { background: var(--green); }
.job-steps li.fail .mark { background: var(--red); }
.job-steps li.doing { font-weight: 600; }
.job-steps li.warn-line { color: var(--amber); font-size: 14px; padding-left: 32px; }
.result-ok { background: #eaf7ee; border: 1px solid #b7e2c4; border-radius: 10px; padding: 16px; margin: 12px 0; }
.result-bad { background: #fdeeee; border: 1px solid #f1c2c2; border-radius: 10px; padding: 16px; margin: 12px 0; color: #7f1d1d; }
.result-ok h3 { color: #12632f; }
.cred { display: grid; grid-template-columns: max-content 1fr auto; gap: 8px 12px; align-items: center; margin: 10px 0; background: #fff; border-radius: 8px; padding: 12px; border: 1px solid #d5ecdc; }
.cred .k { color: var(--muted); font-size: 14px; }
.cred .v { font-family: Consolas, ui-monospace, monospace; font-weight: 600; word-break: break-all; }
.big-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
details.tech summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 6px; }
.log { background: #0f172a; color: #cbd5e1; border-radius: 8px; padding: 12px; max-height: 260px; overflow: auto; font: 12px/1.5 Consolas, ui-monospace, monospace; white-space: pre-wrap; word-break: break-word; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1f2937; color: #fff; padding: 12px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); z-index: 20; font-weight: 500; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--red); }

@media (max-width: 960px) {
  .home { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  main { padding: 18px 16px 50px; }
  .box.wide { padding: 18px; }
  .box.wide > .box-head { margin: -18px -18px 16px; }
  .stepbox { gap: 12px; }
  .site-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
}

/* ---------- tool pages ---------- */
.not-here { padding: 14px 18px; font-size: 14px; color: var(--muted); }
.not-here ul { margin: 6px 0 0; padding-left: 18px; }
.not-here li { margin: 3px 0; }
.picker { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 18px; }
.picker label { min-width: 280px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 10px 0 16px; }
.radio-card { border: 2px solid var(--line); border-radius: 10px; padding: 14px 16px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; font-weight: 400; flex-direction: row; }
.radio-card:has(input:checked) { border-color: var(--blue); background: #f3f8ff; }
.radio-card input { margin-top: 4px; }
.radio-card b { display: block; font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 700; }
.kpi .v.warn { color: var(--amber); } .kpi .v.ok { color: var(--green); }
.list-table td.wrap { white-space: normal; word-break: break-word; }
.list-table td.mono, .mono { font-family: Consolas, ui-monospace, monospace; font-size: 13.5px; }
.list-table .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.disk-row { padding: 10px 0; border-bottom: 1px solid #eef1f4; }
.disk-row:last-child { border-bottom: 0; }
.log-view { background: #0f172a; color: #cbd5e1; border-radius: 10px; padding: 14px; height: 520px; overflow: auto; font: 12.5px/1.55 Consolas, ui-monospace, monospace; white-space: pre-wrap; word-break: break-word; margin: 0; }
.svc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.svc { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.svc .name { font-weight: 700; font-size: 16px; }
.editor-dlg { width: min(1100px, calc(100vw - 32px)); }
#editText { width: 100%; height: min(65vh, 640px); margin: 14px 0 4px; font: 13px/1.5 Consolas, ui-monospace, monospace; border: 1px solid #c9d1dc; border-radius: 8px; padding: 12px; resize: vertical; tab-size: 4; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.inline-form label { flex: 1; min-width: 200px; }
