:root {
	color-scheme: dark;
	--bg: #0d1117; --panel: #161b22; --panel2: #1c2128; --hover: #21262d; --line: #30363d;
	--text: #e6edf3; --muted: #8b949e; --blue: #58a6ff; --green: #3fb950; --red: #f85149; --orange: #f78166; --purple: #a371f7;
	--gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	--shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
html:has(dialog:modal), body:has(dialog:modal) { overflow: hidden; }
dialog:modal, dialog:modal * { overscroll-behavior: contain; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
[hidden] { display: none !important; }
#system-update-overlay { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; background: rgba(13, 17, 23, .97); color: var(--text); text-align: center; padding: 24px; }
#system-update-overlay[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#system-update-overlay::backdrop { background: var(--bg); }
#system-update-overlay h2 { font-size: clamp(32px, 6vw, 52px); margin: 24px 0 12px; }
#system-update-overlay p { color: var(--muted); }
#system-update-output { text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 900px; max-height: 40vh; overflow: auto; margin: 24px auto; }
.update-spinner { width: 100px; height: 100px; flex: none; margin: 0 auto; border: 8px solid var(--line); border-top-color: var(--purple); border-radius: 50%; animation: update-spin 1s linear infinite; }
@keyframes update-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .update-spinner { animation-duration: 3s; } }

button, select, input, textarea { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; transition: border-color .15s, background .15s; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
button { cursor: pointer; white-space: nowrap; }
label:has(input[type="checkbox"]), input[type="checkbox"] { cursor: pointer; }
button:hover { background: var(--hover); border-color: var(--muted); }
button.primary { background: #238636; border-color: #2ea043; color: #fff; font-weight: 600; }
button.primary:hover { background: #2ea043; }
button.danger { color: var(--red); }
button.danger:hover { background: rgba(248, 81, 73, .15); border-color: var(--red); }
button.ghost { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .3); color: #fff; }
button.ghost:hover { background: rgba(255, 255, 255, .25); }
button.small, select.small { padding: 3px 9px; font-size: 12.5px; }
button.wide { width: 100%; padding: 9px; }

.page-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: var(--gradient); box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand h1 { margin: 0; font-size: 20px; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .3); }
.brand .host { color: rgba(255, 255, 255, .8); font-size: 13px; }
.page-header nav { display: flex; gap: 6px; flex: 1; }
.page-header nav button { background: transparent; border-color: transparent; color: rgba(255, 255, 255, .85); font-weight: 500; }
.page-header nav button:hover { background: rgba(255, 255, 255, .15); }
.page-header nav button.active { background: rgba(255, 255, 255, .22); color: #fff; border-color: rgba(255, 255, 255, .35); }
.page-header form { margin: 0; }
.count { background: rgba(0, 0, 0, .3); border-radius: 10px; padding: 0 7px; font-size: 12px; }
.count:empty { display: none; }

main { padding: 20px 24px; max-width: 1600px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.sites-empty { min-height: calc(100dvh - 220px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; text-align: center; }
.sites-empty-icon { display: grid; place-items: center; width: 112px; height: 112px; margin-bottom: 24px; border: 1px solid rgba(163, 113, 247, .3); border-radius: 32px; color: #b9d8ff; background: linear-gradient(135deg, rgba(88, 166, 255, .16), rgba(163, 113, 247, .2)); box-shadow: 0 0 60px rgba(163, 113, 247, .1); }
.sites-empty-icon .ico { width: 58px; height: 58px; }
.sites-empty h2 { margin: 0 0 12px; font-size: clamp(24px, 4vw, 32px); letter-spacing: -.03em; }
.sites-empty p { max-width: 400px; margin: 0 0 28px; color: var(--muted); font-size: 15px; line-height: 1.7; }
#btn-empty-new-site { display: inline-flex; align-items: center; gap: 10px; padding: 13px 28px; font-size: 16px; border-radius: 10px; box-shadow: 0 4px 24px rgba(63, 185, 80, .2); }
#btn-empty-new-site .ico { width: 20px; height: 20px; }
.hint { color: var(--muted); font-size: 12px; }
.sql-backup-history summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.sql-backup-history table { margin-top: 8px; }
.error { color: var(--red); }
#search { min-width: 260px; }

.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.chip:hover { border-color: var(--blue); }
.chip.active { border-color: var(--blue); background: rgba(88, 166, 255, .15); box-shadow: 0 0 14px rgba(88, 166, 255, .25); }
.chip b { font-size: 16px; }
.chip span { color: var(--muted); font-size: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); grid-auto-rows: 1fr; align-items: stretch; gap: 16px; }
.cards > .site { min-width: 0; }
.site-activity { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; color: var(--blue); background: rgba(88, 166, 255, .12); font-size: 11px; }
.activity-spinner { width: 12px; height: 12px; border: 2px solid rgba(88, 166, 255, .25); border-top-color: var(--blue); border-radius: 50%; animation: activity-spin .8s linear infinite; }
@keyframes activity-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .activity-spinner { animation: none; } }
.multi-select { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(88, 166, 255, .08); cursor: pointer; }
.multi-select input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.site:has(.multi-select input:checked) { border-color: var(--blue); }
#multi-selection, #multi-skipped { overflow-wrap: anywhere; }
#dlg-multi { width: min(520px, 92vw); min-width: 0; max-height: 90dvh; overflow-y: auto; padding: 26px; background: linear-gradient(145deg, rgba(163, 113, 247, .08), transparent 55%), var(--panel); }
#multi-title { margin-top: 0; }
#multi-selection { display: flex; flex-wrap: wrap; gap: 7px; max-height: 120px; overflow-y: auto; margin: 14px 0 20px; padding: 2px; font-size: 12px; }
.multi-site-tag { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 6px 10px; border: 1px solid rgba(163, 113, 247, .3); border-radius: 8px; color: #d3baff; background: rgba(163, 113, 247, .1); }
.multi-site-tag .ico { width: 14px; height: 14px; flex: none; }
.multi-site-tag > span { min-width: 0; overflow-wrap: anywhere; }
#dlg-multi .multi-action-label { color: var(--muted); font-size: 12px; font-weight: 600; }
#dlg-multi select { appearance: none; margin-top: 8px; padding: 13px 40px 13px 14px; border: 1px solid rgba(163, 113, 247, .5); border-radius: 10px; background-color: var(--panel2); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a371f7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
#dlg-multi select:hover { border-color: var(--purple); background-color: var(--hover); }
#multi-action-description { font-size: 13px; line-height: 1.6; }
.site { background: linear-gradient(135deg, rgba(88, 166, 255, .04), transparent 60%), var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: 0 4px 16px rgba(0, 0, 0, .15); display: flex; flex-direction: column; gap: 20px; position: relative; cursor: pointer; transition: border-color .2s, box-shadow .2s; }
.site:hover { border-color: rgba(88, 166, 255, .5); box-shadow: 0 10px 28px rgba(0, 0, 0, .3), 0 0 20px rgba(88, 166, 255, .07); }
.site.is-admin { border-color: rgba(163, 113, 247, .5); }
.site-head { display: flex; align-items: center; gap: 12px; }
.site-identity { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 0; }
.site-identity .badge { font-size: 10px; padding: 2px 7px; }
.site-emblem { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border: 1px solid rgba(163, 113, 247, .25); border-radius: 12px; background: linear-gradient(135deg, rgba(88, 166, 255, .15), rgba(163, 113, 247, .18)); color: #b9d8ff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
.site-emblem .ico { width: 23px; height: 23px; }
.site-head > .dot { margin-left: auto; }
.card-update-check { display: inline-flex; align-items: center; gap: 6px; color: var(--blue); font-size: 12px; }
.card-update-check.up-to-date { color: var(--green); }
@media (prefers-reduced-motion: reduce) { .site { transition: none; } }
.site-title { font-size: 15px; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.active { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.failed, .dot.inactive { background: var(--red); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 6px; background: var(--hover); color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.badge.umbraco { background: linear-gradient(135deg, #3544b1, #00bcd4); color: #fff; }
.badge.csharp { background: #512bd4; color: #fff; }
.badge.python { background: #3776ab; color: #fff; }
.badge.html { background: #e34f26; color: #fff; }
.badge.admin { background: var(--purple); color: #fff; }
.badge.state-active { background: rgba(63, 185, 80, .2); color: var(--green); }
.badge.publish-pending { background: rgba(210, 153, 34, .2); color: #d29922; }
.badge.updates-available { background: rgba(210, 153, 34, .2); color: #d29922; }
.badge.updates-error { background: rgba(248, 81, 73, .2); color: var(--red); }
.publish-status { flex-basis: 100%; display: flex; }
.badge.state-failed, .badge.state-inactive { background: rgba(248, 81, 73, .2); color: var(--red); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta .database-name { overflow-wrap: anywhere; min-width: 0; }
.meta .aliases a { font-style: italic; }
.meta dd { margin: 0; overflow-wrap: anywhere; }
a.link { color: var(--blue); cursor: pointer; text-decoration: none; }
a.link:hover { text-decoration: underline; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--line); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.sql-connection-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 16px; }
.sql-connection-bar > button { min-height: 42px; }
.sql-connection-bar label { margin: 0; min-width: 220px; }
.sql-connection-bar label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
#sql-connection { appearance: none; width: min(320px, 100%); padding: 10px 40px 10px 14px; border-radius: 10px; border-color: rgba(163, 113, 247, .45); color: var(--text); font-size: 14px; font-weight: 600; background: var(--panel2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
#sql-connection:hover { border-color: var(--purple); }
.sql-system-databases { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.sql-system-databases summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 6px 0; }
.sql-system-databases table { margin-top: 8px; }
.sql-table { margin-top: 16px; padding: 16px; overflow-x: auto; }
.sql-table h3 { margin-top: 0; }
.sql-databases-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.sql-databases-header h3 { margin: 0; }
.sql-databases-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.sql-table td { overflow-wrap: anywhere; }
.sql-table .actions { flex-wrap: wrap; gap: 6px; justify-content: flex-end; border-top: 0; padding-top: 0; }
.sql-table > table th:last-child, .sql-table > table td:last-child:not([colspan]) { text-align: right; }
#sql-databases-panel table th:first-child, #sql-databases-panel table td:first-child { width: 100%; }
#sql-databases-panel table th:not(:first-child), #sql-databases-panel table td:not(:first-child) { white-space: nowrap; }
#sql-databases-panel .actions { flex-wrap: nowrap; }
#sql-databases-panel .sql-state-online { color: var(--green); }
#sql-databases-panel .sql-state-offline, #sql-databases-panel .sql-state-offline_secondary, #sql-databases-panel .sql-state-suspect { color: var(--red); }
#sql-databases-panel .sql-state-restoring, #sql-databases-panel .sql-state-copying { color: var(--blue); }
#sql-databases-panel .sql-state-recovering { color: #39c5cf; }
#sql-databases-panel .sql-state-recovery_pending { color: #d29922; }
#sql-databases-panel .sql-state-emergency { color: var(--orange); }
#form-sql-connection input[type=checkbox] { width: auto; }
#dlg-sql-connection { width: min(520px, 92vw); min-width: 0; max-height: 90vh; overflow-y: auto; }
#dlg-sql-restore-login { width: min(520px, 92vw); min-width: 0; max-height: 90vh; overflow-y: auto; }
#prompt-checkbox-row, #prompt-login-row { flex-direction: row; align-items: flex-start; gap: 12px; margin: 16px 0 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); color: var(--text); font-size: 14px; line-height: 1.5; cursor: pointer; }
#prompt-checkbox, #prompt-login-checkbox { flex: none; width: 18px; height: 18px; margin: 2px 0 0; padding: 0; accent-color: var(--blue); }
#prompt-checkbox-label { min-width: 0; overflow-wrap: anywhere; }
#form-sql-connection .sql-trust-certificate { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--text); }
#form-sql-connection .sql-trust-certificate input { flex: none; margin: 0; }
#sql-trust-help { margin-top: 0; }
#sql-ssh-fields { margin: 16px 0; padding: 14px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
#sql-ssh-fields legend { color: var(--muted); padding: 0 6px; }
.system-update-available { color: var(--orange); background: rgba(210, 153, 34, .15); }
.package-panel { margin-top: 16px; overflow: hidden; }
.package-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); background: linear-gradient(110deg, rgba(163, 113, 247, .08), transparent); }
.package-heading { display: flex; align-items: center; gap: 10px; }
.package-head h3 { margin: 0; font-size: 15px; }
.package-count { padding: 2px 8px; border-radius: 12px; background: rgba(163, 113, 247, .15); color: var(--purple); font-size: 12px; font-weight: 600; }
.package-head .actions { margin: 0; padding: 0; border: 0; }
.package-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 20px; }
.package-list > p { margin: 12px 0; }
.package-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 20px; width: 100%; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: transparent; text-align: left; white-space: normal; }
.package-row:hover { background: var(--hover); }
.package-copy { min-width: 0; padding: 0; border: 0; background: transparent; text-align: left; white-space: normal; }
.package-copy:hover { background: transparent; color: var(--blue); }
.package-versions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.package-version.package-latest { color: var(--green); border-color: rgba(63, 185, 80, .4); background: rgba(63, 185, 80, .1); }
.package-row.has-update { background: rgba(63, 185, 80, .04); }
.package-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.package-name .ico { flex: none; width: 18px; height: 18px; color: var(--purple); }
.package-name > span { min-width: 0; }
.package-version { max-width: 100%; padding: 5px 12px; border: 1px solid rgba(88, 166, 255, .5); border-radius: 6px; background: rgba(88, 166, 255, .15); color: var(--blue); font: 600 14px ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.package-error { margin: 12px 20px; color: var(--orange); font-size: 12px; }
#files th:first-child, #files td:first-child { width: 100%; white-space: nowrap; }
#files .file-size, #files .file-modified { text-align: right; white-space: nowrap; }
#files .file-permissions, #files .file-owner { white-space: nowrap; }
#files .file-permissions { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
#files .file-folder-row, #files .file-open-row { cursor: pointer; }
#files .file-empty-row:hover { background: transparent; }
#files .file-empty-row { cursor: default; }
.files-navigation { align-items: stretch; }
#files-search { flex: 1; min-width: 180px; width: 0; box-sizing: border-box; }
.files-navigation > button, #files-search { height: 34px; }
#files .file-entry { display: inline-flex; align-items: center; gap: 10px; }
#files .file-entry .ico { width: 20px; height: 20px; flex: none; margin: 0; }
#files .file-name { padding: 0; border: 0; background: transparent; color: var(--blue); text-align: left; }
#files .file-folder { color: var(--blue); }
#files .file-document.file-name { color: var(--text); }
#files .file-name:hover { background: transparent; }
#files .tools { cursor: default; }
#files .file-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
#files .file-action { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; margin: 0; border-radius: 8px; }
#files .file-action .ico { width: 16px; height: 16px; margin: 0; }
#files .file-download { box-sizing: border-box; vertical-align: middle; color: var(--blue); border: 1px solid color-mix(in srgb, var(--blue) 35%, var(--line)); background: color-mix(in srgb, var(--blue) 9%, var(--panel2)); text-decoration: none; }
#files .file-download:hover { background: color-mix(in srgb, var(--blue) 20%, var(--panel2)); border-color: var(--blue); }
.file-uneditable { color: var(--muted); opacity: .65; cursor: default; }
#files-filter[aria-pressed=true] { border-color: var(--blue); color: var(--blue); }
.list.dragging { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue); }
.drop-hint { display: none; position: absolute; inset: 0; pointer-events: none; background: rgba(13, 17, 23, .85); align-items: center; justify-content: center; font-size: 18px; color: var(--blue); }
.list.dragging .drop-hint { display: flex; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--hover); }
.num { text-align: right; white-space: nowrap; }
td.tools { white-space: nowrap; text-align: right; }
td.tools a { margin-left: 10px; font-size: 13px; }
.dirty { color: var(--orange); font-size: 12px; }

#tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
#tabs .tab { display: flex; gap: 8px; align-items: center; padding: 5px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
#tabs .tab:hover { border-color: var(--muted); }
#tabs .tab.active { border-color: var(--blue); background: rgba(88, 166, 255, .15); }
#tabs .tab .x { color: var(--muted); padding: 0 2px; }
#tabs .tab .x:hover { color: var(--red); }
#panes .pane { height: calc(100vh - 190px); min-height: 300px; background: #000; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 22px; min-width: min(440px, 92vw); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
dialog p { margin: 0 0 12px; white-space: pre-line; color: var(--muted); }
dialog input, dialog select { width: 100%; }
dialog label, .card label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; color: var(--muted); font-size: 12.5px; }
dialog label input, dialog label select { color: var(--text); font-size: 14px; }
dialog fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 10px 12px 0; }
dialog legend { color: var(--muted); font-size: 12px; padding: 0 6px; }
dialog menu { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 0; margin: 14px 0 0; }
dialog menu .cancel-link { margin-right: auto; align-self: center; padding: 8px 0; border: 0; background: transparent; color: var(--blue); font: inherit; text-decoration: none; cursor: pointer; }
dialog menu .cancel-link:hover { background: transparent; text-decoration: underline; }
dialog.danger h2 { color: var(--red); }
dialog.danger .primary { background: #da3633; border-color: var(--red); }
#prompt-ok:disabled { opacity: .4; cursor: not-allowed; background: var(--panel2); border-color: var(--line); color: var(--muted); }
#dlg-prompt { width: min(520px, 92vw); min-width: 0; }
#prompt-message { overflow-wrap: anywhere; }
#dlg-prompt .confirmation-copy { white-space: normal; }
#dlg-prompt .prompt-extra-row { margin-top: 16px; }
#dlg-prompt #prompt-extra { width: 100%; height: 160px; resize: none; overflow-y: auto; font: inherit; }

#toasts { position: fixed; inset: auto 18px 18px auto; margin: 0; padding: 0; border: 0; background: transparent; color: inherit; max-width: calc(100vw - 36px); max-height: calc(100vh - 36px); overflow: auto; display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 420px; animation: pop .15s ease-out; }
.toast.error { border-left-color: var(--red); }
.toast { display: flex; align-items: flex-start; gap: 12px; pointer-events: auto; }
.toast span { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.toast button { flex-shrink: 0; }
.toast.ok { border-left-color: var(--green); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

body.login { display: grid; place-items: center; min-height: 100vh; background: var(--bg) radial-gradient(circle at 20% 10%, rgba(102, 126, 234, .25), transparent 40%), radial-gradient(circle at 80% 90%, rgba(118, 75, 162, .25), transparent 40%); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(360px, 92vw); box-shadow: var(--shadow); overflow: hidden; }
.card-head { background: var(--gradient); padding: 22px 24px; }
.card-head h1 { margin: 0; font-size: 22px; color: #fff; }
.card-head p { margin: 4px 0 0; color: rgba(255, 255, 255, .8); }
.card-body { padding: 22px 24px 24px; }
.card-body input { width: 100%; color: var(--text); font-size: 15px; padding: 8px 12px; }

@media (max-width: 800px) {
	main { padding: 12px; }
	.page-header { padding: 12px; gap: 10px; }
	#search { min-width: 0; flex: 1; }
	th:nth-child(3), td:nth-child(3) { display: none; }
}

/* ---- v2: header, account menu, environments, dock ---- */
.brand .logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: rgba(255, 255, 255, .2); color: #fff; font-size: 18px; }
.brand h1 { font-size: 17px; line-height: 1.1; }
.brand .host { display: block; font-size: 12px; }
.page-header #search { min-width: 280px; background: rgba(0, 0, 0, .25); border-color: rgba(255, 255, 255, .25); color: #fff; border-radius: 18px; padding-left: 16px; }
.page-header #search::placeholder { color: rgba(255, 255, 255, .65); }
.page-header #search:focus { background: rgba(0, 0, 0, .4); outline-color: #fff; }
.user { position: relative; }
.avatar { width: 36px; height: 36px; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .5); color: #fff; font-weight: 700; font-size: 15px; }
.avatar:hover { background: rgba(255, 255, 255, .35); border-color: #fff; }
.menu { position: absolute; right: 0; top: 46px; min-width: 200px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.menu form { margin: 0; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--hover); }
#settings-update { display: flex; align-items: center; gap: 6px; }
#system-update-badge { font-size: 10px; padding: 2px 6px; }
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-group:not([hidden]) ~ .menu-group:not([hidden]) { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.menu-group-title { padding: 5px 10px; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
#btn-dock .count { margin-left: 4px; background: #fff; color: #4b3a8c; font-weight: 700; }
.toolbar .stats { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 500; }
.back .ico { width: 18px; height: 18px; }

.site { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.site:hover { border-color: var(--blue); }
.env-rows { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.env-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.env-label { font-weight: 600; }
.dot.remote { background: var(--purple); }

.detail-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.detail-title h2 { margin: 0; font-size: 26px; }
.sql-heading { margin-bottom: 16px; }
#site-head > .detail-title:last-child { margin-bottom: 16px; }
#site-head > .actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 20px; margin-bottom: 20px; }
.envs { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.env { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; border-top: 3px solid var(--blue); }
.env.prod { border-top-color: var(--orange); }
.env-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.env-head h3 { margin: 0; font-size: 18px; }
.env-head .create-production { margin-left: auto; }
.env .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }

#dock { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(1, 4, 9, .72); backdrop-filter: blur(3px); }
.dock-window { display: flex; flex-direction: column; width: min(1200px, 94vw); height: min(720px, 86vh); background: #000; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, .7); }
#dock.max .dock-window { width: 98vw; height: 96vh; }
.dock-bar { display: flex; align-items: center; gap: 6px; background: var(--panel); padding: 6px 10px; border-bottom: 1px solid var(--line); }
.dock-bar .ghost { color: var(--text); }
#dock #tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0; flex-wrap: nowrap; }
#dock #panes { flex: 1; min-height: 0; position: relative; }
#dock #panes .pane { position: absolute; inset: 0; height: auto; min-height: 0; padding: 6px 10px; border: 0; border-radius: 0; overflow: hidden; }

dialog.editor { padding: 14px 18px; flex-direction: column; }
dialog.editor[open] { display: flex; }
dialog.editor .toolbar { margin-bottom: 10px; }
dialog.editor textarea { flex: 1; min-height: 0; width: 100%; resize: none; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; tab-size: 4; }
dialog.wide { width: min(1000px, 94vw); }
dialog.editor, dialog.files-dialog, #dlg-logs { width: min(1100px, 94vw); height: min(740px, 86vh); }
#dlg-logs { padding: 18px; flex-direction: column; }
#dlg-logs[open] { display: flex; }
dialog.files-dialog { padding: 18px; }
.files-dialog #view-files { display: flex; flex-direction: column; height: 100%; }
.files-heading h2 { margin: 0; font-size: 18px; }
.files-dialog #drop { flex: 1; min-height: 0; overflow: auto; }
#logs-text { flex: 1; min-height: 0; overflow: auto; background: #000; padding: 10px; border-radius: 6px; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; }
@media (max-width: 800px) { .page-header #search { min-width: 0; flex: 1; } .brand h1, .brand .host { display: none; } .envs { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
	.env .desktop-only, .env .actions:not(:has(> button:not(.desktop-only))) { display: none; }
	.package-row { flex-wrap: nowrap; gap: 10px; }
	.package-copy { flex: 1; }
	.package-versions { flex: 0 0 auto; max-width: 55%; justify-content: flex-end; }
	.package-version { white-space: nowrap; overflow-wrap: normal; }
	#view-sql { min-width: 0; }
	#sql-status { overflow-wrap: anywhere; }
	.sql-connection-bar label { min-width: 0; width: 100%; }
	#sql-connection { width: 100%; }
	.sql-connection-bar .spacer { display: none; }
	.sql-table { padding: 12px; overflow-x: visible; min-width: 0; }
	#view-sql table, #view-sql tbody { display: block; width: 100%; }
	#view-sql thead { display: none; }
	#view-sql tbody > tr { display: block; margin-top: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
	#view-sql td:not([colspan]) { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; width: 100%; padding: 6px 0; border: 0; white-space: normal; text-align: left; overflow-wrap: anywhere; }
	#view-sql td[data-label]::before { content: attr(data-label); color: var(--muted); font-weight: 400; }
	#view-sql td[colspan] { display: block; padding: 0; border: 0; }
	#view-sql .actions { flex-wrap: wrap; justify-content: flex-start; min-width: 0; margin: 0; }
	#view-sql .sql-backup-history { min-width: 0; overflow-wrap: anywhere; }
}

.list { position: relative; overflow-x: auto; }
.env .actions.quick { margin-top: 12px; }
.env .actions.quick button { background: var(--accent-soft, transparent); }
.env .actions.quick .script-select { appearance: none; max-width: 100%; min-width: 150px; padding: 6px 32px 6px 12px; border-radius: 8px; border-color: var(--blue); color: var(--blue); background-color: rgba(88,166,255,.08); cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2358a6ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.script-select option, .script-select optgroup { color: var(--text); background: var(--panel2); }
.badge.version { text-transform: none; color: #fff; background: #57606a; }
.badge.version[data-major="0"] { background: #8250df; }
.badge.version[data-major="1"] { background: #0969da; }
.badge.version[data-major="2"] { background: #1a7f37; }
.badge.version[data-major="3"] { background: #bf8700; }
.badge.version[data-major="4"] { background: #cf222e; }
.badge.version[data-major="5"] { background: #bf3989; }
.badge.version[data-major="6"] { background: #0a7f8f; }
.badge.version[data-major="7"] { background: #953800; }

/* Button icons and tones */
button .ico { width: 1.1em; height: 1.1em; margin: -2px 6px -2px -2px; vertical-align: middle; }
button[data-tone] { --tone: var(--muted); color: var(--tone); border-color: color-mix(in srgb, var(--tone) 35%, var(--line)); background: color-mix(in srgb, var(--tone) 9%, var(--panel2)); }
button[data-tone]:hover { background: color-mix(in srgb, var(--tone) 20%, var(--panel2)); border-color: var(--tone); }
button[data-tone="blue"] { --tone: var(--blue); }
button[data-tone="green"] { --tone: var(--green); }
button[data-tone="red"] { --tone: var(--red); }
button[data-tone="amber"] { --tone: #d29922; }
button[data-tone="teal"] { --tone: #39c5cf; }
button[data-tone="purple"] { --tone: var(--purple); }
button[data-tone="gray"] { --tone: #9da7b3; }
.menu button[data-tone] { background: transparent; border-color: transparent; color: var(--text); }
.menu button[data-tone] .ico { color: var(--tone); }
.menu button[data-tone]:hover { background: var(--hover); border-color: transparent; }
button.primary[data-tone] { background: #238636; border-color: #2ea043; color: #fff; }
#sql-remove-connection { padding-left: 0; padding-right: 0; border: 0; background: transparent; color: var(--red); align-self: center; }
#sql-remove-connection:hover { background: transparent; text-decoration: underline; }
#form-sql-connection menu { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
#sql-connection-cancel { grid-column: 1; grid-row: 1; justify-self: start; }
#sql-remove-connection { grid-column: 2; grid-row: 1; justify-self: center; }
#form-sql-connection menu > button[type="submit"] { grid-column: 3; grid-row: 1; justify-self: end; }
@media (max-width: 560px) {
	#form-sql-connection menu { grid-template-columns: minmax(0, 1fr) auto; }
	#form-sql-connection menu > button[type="submit"] { grid-column: 2; }
	#sql-remove-connection { grid-column: 1 / -1; grid-row: 2; }
}
/* Delete buttons stand alone at the far right of their row */
.actions > button.danger, #site-head .actions > button.danger { margin-left: auto; }
dialog.editor #editor-box { flex: 1; min-height: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }

/* New site dialog */
dialog.newsite { width: min(640px, 94vw); max-height: 90vh; max-height: 90dvh; padding: 0; overflow-y: auto; }
dialog.newsite form { padding: 0 24px 20px; }
.ns-head { display: flex; align-items: center; gap: 14px; margin: 0 -24px 18px; padding: 20px 24px; background: linear-gradient(135deg, rgba(88,101,242,.35), rgba(139,92,246,.22)); border-bottom: 1px solid var(--line); }
.ns-head h2 { margin: 0; font-size: 20px; }
.ns-head p { margin: 2px 0 0; font-size: 13px; }
.ns-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #6c7bff, #8b5cf6); box-shadow: 0 4px 14px rgba(108,123,255,.4); }
.ns-section { margin: 4px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.type-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
dialog .type-card { position: relative; display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: rgba(255,255,255,.02); transition: border-color .15s, background .15s; }
.type-card:hover { border-color: var(--blue); }
.type-card input { position: absolute; opacity: 0; pointer-events: none; width: auto; }
.type-card .tc-title { color: var(--text); font-size: 14px; font-weight: 600; }
.type-card .tc-sub { font-size: 12px; color: var(--muted); }
.type-card:has(input:checked) { border-color: var(--blue); background: rgba(88,166,255,.12); box-shadow: 0 0 0 1px var(--blue) inset; }
.type-card:has(input:focus-visible) { outline: 2px solid var(--blue); }
.ns-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
dialog.newsite .hint { margin: 2px 0 0; font-size: 12px; }
dialog.newsite .template-status { height: 16px; line-height: 16px; overflow-y: auto; }
@media (max-width: 560px) { dialog.newsite .template-status { height: 32px; } }
dialog.newsite menu { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
@media (max-width: 560px) { .type-cards, .ns-grid { grid-template-columns: 1fr; } }
dialog.newsite input:not([type=radio]), dialog.newsite select { height: 38px; padding: 0 12px; font-size: 14px; line-height: 1.2; }
dialog.newsite select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
dialog.newsite select option { background: var(--panel2); color: var(--text); }
.actions > button.push-right { margin-left: auto; }
.actions > button.push-right + button.danger { margin-left: 0; }
.env-binding { display: flex; gap: 8px; align-items: baseline; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.env-tags { display: flex; gap: 6px; align-items: center; }
.badge.env-development { background: rgba(88, 166, 255, .2); color: var(--blue); }
.badge.env-test { background: rgba(210, 153, 34, .2); color: #d29922; }
.badge.env-staging { background: rgba(163, 113, 247, .2); color: #a371f7; }
.badge.env-production { background: rgba(248, 81, 73, .2); color: var(--red); }
.environment-current { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; color: var(--muted); font-size: 13px; }
.environment-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 0; padding: 0; margin: 0 0 18px; }
.environment-options legend { margin-bottom: 12px; padding: 0; }
.environment-option { --env-tone: var(--blue); min-height: 76px; justify-content: center; }
.environment-option.env-test { --env-tone: #d29922; }
.environment-option.env-staging { --env-tone: var(--purple); }
.environment-option.env-production { --env-tone: var(--red); }
.environment-option .tc-title { color: var(--env-tone); }
.environment-option:has(input:checked) { border-color: var(--env-tone); background: color-mix(in srgb, var(--env-tone) 12%, transparent); box-shadow: 0 0 0 1px var(--env-tone) inset; }
.environment-option:has(input:focus-visible) { outline-color: var(--env-tone); outline-offset: 3px; }
dialog .environment-notice { padding: 12px 14px; border: 1px solid rgba(210, 153, 34, .25); border-radius: 10px; background: rgba(210, 153, 34, .07); font-size: 12px; color: #d29922; }
@media (max-width: 440px) { .environment-options { grid-template-columns: 1fr; } }
a.btn-link { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 10px; font-size: 12.5px; color: var(--blue); text-decoration: none; background: rgba(88, 166, 255, .1); border: 1px solid rgba(88, 166, 255, .35); border-radius: 6px; transition: background .15s, border-color .15s; }
a.btn-link:hover { background: rgba(88, 166, 255, .2); border-color: var(--blue); }
a.btn-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.btn-link .ico { width: 13px; height: 13px; flex: none; }
.site-links { display: flex; flex-direction: column; margin-top: auto; border: 1px solid var(--line); border-radius: 10px; background: rgba(1, 4, 9, .16); overflow: hidden; }
.site-link-group { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 12px; }
.site-link-group + .site-link-group { border-top: 1px solid var(--line); }
.site-environment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-environment-head .badge { font-size: 10px; padding: 4px 7px; }
.site-environment-links { display: flex; align-items: stretch; gap: 6px; flex-shrink: 0; }
.site-links:has(.publish-status) .site-environment-links { flex-direction: column; }
@media (max-width: 420px) {
	.site { padding: 16px; }
	.site-link-group { flex-wrap: wrap; }
	.site-environment-links { margin-left: auto; }
}
.https-lock { display: inline-flex; align-items: center; flex: none; }
.confirmation-copy { display: inline; padding: 0; border: 0; border-radius: 2px; background: transparent; color: inherit; font: inherit; overflow-wrap: anywhere; }
.confirmation-copy:hover { background: transparent; text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 3px; }
#form-prompt menu { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; list-style: none; }
#prompt-copy-status { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.clipboard-transfer { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.https-lock.secure { color: #e3b341; }
.https-lock.insecure { color: var(--red); }
.https-lock.unknown { color: var(--muted); }
.remote-icon { display: inline-flex; align-items: center; color: var(--purple); }
.remote-icon .ico { width: 16px; height: 16px; }
.https-lock .ico { width: 15px; height: 15px; }
.site-link-group .frontend { --link-tone: var(--blue); }
.site-link-group .backend { --link-tone: var(--purple); }
.site-link-group.production .frontend { --link-tone: var(--green); }
.site-link-group.production .backend { --link-tone: #39c5cf; }
.site-link-group a.btn-link { color: var(--link-tone); background: color-mix(in srgb, var(--link-tone) 10%, transparent); border-color: color-mix(in srgb, var(--link-tone) 35%, transparent); }
.site-link-group a.btn-link:hover { background: color-mix(in srgb, var(--link-tone) 20%, transparent); border-color: var(--link-tone); }
.env-binding { flex-wrap: wrap; gap: 6px; }
.env-row { justify-content: space-between; }
.env-row > a.btn-link { justify-self: start; }
.env-tags { justify-self: end; }
#btn-new-site { margin-right: 14px; padding: 7px 18px; font-weight: 600; box-shadow: 0 2px 10px rgba(63, 185, 80, .25); }
