@font-face { font-family: "Roboto"; src: url("/static/fonts/Roboto-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Roboto"; src: url("/static/fonts/Roboto-Medium.ttf") format("truetype"); font-weight: 500 900; font-display: swap; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Roboto", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 13px; color: #1a1a1a; background: #f8fafc;
  min-width: 1100px; min-height: 640px;
}
button, input, select { font: inherit; }

#app { position: absolute; inset: 0; min-width: 1100px; min-height: 640px; display: flex; flex-direction: column; }
#loading { margin: auto; color: #64748b; font-size: 14px; }
.app-error { margin: auto; max-width: 640px; padding: 24px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; white-space: pre-wrap; }

/* ---- customtkinter widgets ---- */
.w { flex: 0 0 auto; min-width: 0; }
.ctk-root { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.ctk-frame { display: flex; flex-direction: column; }
.ctk-scroll { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ctk-scroll-inner { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; padding: 4px 4px 4px 4px; scrollbar-width: thin; scrollbar-color: #8c8c8c transparent; }
.ctk-scroll-inner::-webkit-scrollbar { width: 12px; }
.ctk-scroll-inner::-webkit-scrollbar-thumb { background: #8c8c8c; border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
.ctk-scroll-inner::-webkit-scrollbar-thumb:hover { background-color: #666; }

.ctk-label { display: flex; align-items: center; justify-content: center; min-height: 28px; white-space: pre; line-height: 1.2; padding: 0 2px; }
.ctk-label.anchor-w { justify-content: flex-start; }
.ctk-label.anchor-e { justify-content: flex-end; }

.ctk-button { display: flex; align-items: center; justify-content: center; border: 0; padding: 0 8px; cursor: pointer; white-space: pre; line-height: 1.2; background: var(--bg); transition: background-color .08s; }
.ctk-button:hover:not(:disabled) { background: var(--hover, var(--bg)); }
.ctk-button:disabled { cursor: default; }
.ctk-button:focus-visible, .ctk-option select:focus-visible, .ctk-entry:focus-visible { outline: 2px solid #0ea5e9; outline-offset: 2px; }

.ctk-option { position: relative; display: block; }
.ctk-option select {
  width: 100%; height: 100%; border: 0; padding: 0 34px 0 12px; cursor: pointer;
  -webkit-appearance: none; appearance: none; color: inherit; border-radius: inherit;
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.5l4.5 4.5 4.5-4.5' fill='none' stroke='%23DCE4EE' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
    linear-gradient(to left, var(--btn) 0, var(--btn) 28px, transparent 28px);
  background-repeat: no-repeat, no-repeat; background-position: right 8px center, 0 0;
}
.ctk-option select:hover { background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.5l4.5 4.5 4.5-4.5' fill='none' stroke='%23DCE4EE' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
    linear-gradient(to left, var(--btn-hover) 0, var(--btn-hover) 28px, transparent 28px); }
.ctk-option select option { background: #fff; color: #1e293b; }

.ctk-radio, .ctk-check { display: inline-flex; align-items: center; cursor: pointer; user-select: none; white-space: pre; line-height: 1.2; }
.ctk-radio .dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border); flex: 0 0 auto; margin-right: 6px; background: transparent; transition: border-width .08s; }
.ctk-radio:hover .dot { border-color: var(--hover); }
.ctk-radio.checked .dot { border: 6px solid var(--fg); }
.ctk-check { min-height: 24px; }
.ctk-check .box { width: 24px; height: 24px; border-radius: 6px; border: 3px solid var(--border); flex: 0 0 auto; margin-right: 6px; display: flex; align-items: center; justify-content: center; }
.ctk-check:hover .box { border-color: var(--fg); }
.ctk-check.checked .box { background: var(--fg); border-color: var(--fg); }
.ctk-check.checked .box::after { content: ""; width: 12px; height: 6px; border-left: 2.5px solid var(--mark); border-bottom: 2.5px solid var(--mark); transform: rotate(-45deg) translate(1px, -1px); }

.ctk-entry { padding: 0 8px; outline: none; }
.ctk-progress { overflow: hidden; }
.ctk-progress .bar { height: 100%; border-radius: inherit; transition: width .15s linear; }
.ctk-textbox { overflow-y: auto; white-space: pre-wrap; word-break: break-word; padding: 4px 6px; line-height: 1.35; scrollbar-width: thin; }

/* ---- hosting extras (not part of the app window) ---- */
#shell { position: fixed; top: 30px; right: 26px; display: flex; align-items: center; gap: 6px; z-index: 5; }
#shell form { margin: 0; }
#shell button, #shell .shell-link { height: 30px; padding: 0 11px; border: 1px solid #e2e8f0; border-radius: 6px; background: #f8fafc; color: #1e293b; cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; text-decoration: none; }
#shell button:hover, #shell .shell-link:hover { background: #e2e8f0; }
#who { font-size: 12px; color: #64748b; margin-right: 4px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#toast { position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 12px; z-index: 40; }

/* ---- dialogs ---- */
#modals:empty { display: none; }
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .32); display: flex; align-items: center; justify-content: center; z-index: 20; }
.win { background: #fff; border-radius: 8px; box-shadow: 0 18px 50px rgba(15, 23, 42, .35); border: 1px solid #cbd5e1; display: flex; flex-direction: column; max-width: calc(100vw - 40px); max-height: calc(100vh - 40px); overflow: hidden; }
.win-title { padding: 10px 14px; font-size: 13px; background: #f1f5f9; border-bottom: 1px solid #e2e8f0; color: #1e293b; }
.mb { min-width: 320px; max-width: 520px; }
.mb-body { display: flex; gap: 14px; padding: 20px 18px 16px; align-items: flex-start; }
.mb-icon { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 20px; line-height: 1; }
.mb-icon.info { background: #2563eb; } .mb-icon.question { background: #2563eb; }
.mb-icon.warning { background: #d97706; } .mb-icon.error { background: #dc2626; }
.mb-text { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.45; padding-top: 6px; color: #1e293b; overflow-y: auto; max-height: 60vh; }
.win-buttons { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; background: #f8fafc; border-top: 1px solid #e2e8f0; }
.win-buttons button, .fd-bar button, .fd-row button { min-width: 78px; height: 30px; padding: 0 12px; border: 1px solid #94a3b8; border-radius: 5px; background: #fff; color: #1e293b; cursor: pointer; }
.win-buttons button:hover, .fd-bar button:hover, .fd-row button:hover { background: #f1f5f9; }
.win-buttons button.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.win-buttons button.primary:hover { background: #1d4ed8; }
.win-buttons button:disabled { opacity: .5; cursor: default; }
.win-buttons button:focus-visible, .fd-bar button:focus-visible { outline: 2px solid #0ea5e9; outline-offset: 2px; }

.fd { width: 680px; height: 520px; }
.fd-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #e2e8f0; }
.fd-bar .grow { flex: 1; color: #64748b; font-size: 12px; }
.fd-bar select { height: 30px; border: 1px solid #94a3b8; border-radius: 5px; background: #fff; padding: 0 6px; }
.fd-list { flex: 1 1 0; overflow-y: auto; min-height: 0; }
.fd-row { display: grid; grid-template-columns: 1fr 150px 80px auto; gap: 10px; align-items: center; padding: 7px 14px; border-bottom: 1px solid #f1f5f9; cursor: default; font-size: 13px; }
.fd-row.head { position: sticky; top: 0; background: #fff; color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid #e2e8f0; z-index: 1; }
.fd-row.pick { cursor: pointer; }
.fd-row.pick:hover { background: #f1f5f9; }
.fd-row.sel, .fd-row.sel:hover { background: #dbeafe; }
.fd-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-row .meta { color: #64748b; font-size: 12px; white-space: nowrap; }
.fd-row .acts { display: flex; gap: 6px; }
.fd-row .acts button, .fd-row .acts a { min-width: 0; height: 26px; padding: 0 10px; font-size: 12px; border: 1px solid #94a3b8; border-radius: 5px; background: #fff; color: #1e293b; text-decoration: none; display: inline-flex; align-items: center; cursor: pointer; }
.fd-row .acts a:hover { background: #f1f5f9; }
.fd-row .acts button.danger { color: #dc2626; border-color: #fca5a5; }
.fd-empty { padding: 40px 14px; text-align: center; color: #64748b; }
.fd-msg { padding: 8px 14px; font-size: 12px; color: #dc2626; border-top: 1px solid #fee2e2; background: #fef2f2; }
.fd-tag { font-size: 11px; color: #059669; margin-left: 8px; }

/* ---- login ---- */
.login-page { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 100vh; background: #f8fafc; }
.login-card { width: 340px; padding: 28px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { font-size: 18px; margin: 0 0 8px; color: #1e293b; font-weight: 700; }
.login-card label { font-size: 12px; color: #64748b; }
.login-card input { height: 36px; border: 2px solid #979DA2; border-radius: 6px; padding: 0 10px; background: #F9F9FA; }
.login-card input:focus { outline: none; border-color: #2563eb; }
.login-card button { height: 40px; border: 0; border-radius: 6px; background: #2563eb; color: #fff; font-weight: 700; cursor: pointer; margin-top: 6px; }
.login-card button:hover { background: #1d4ed8; }
.login-error { margin: 0; color: #dc2626; font-size: 12px; }

/* ---- account pages ---- */
body.page { min-width: 0; min-height: 0; background: #f8fafc; color: #1e293b; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: #fff; border-bottom: 1px solid #e2e8f0; }
.page-brand { font-weight: 700; font-size: 16px; color: #1e293b; text-decoration: none; }
.page-nav { display: flex; align-items: center; gap: 6px; }
.page-nav form { margin: 0; }
.page-nav a, .page-nav button { height: 30px; padding: 0 11px; border: 1px solid #e2e8f0; border-radius: 6px; background: #f8fafc; color: #1e293b; font-size: 12px; text-decoration: none; display: inline-flex; align-items: center; cursor: pointer; }
.page-nav a:hover, .page-nav button:hover { background: #e2e8f0; }
.page-body { max-width: 900px; margin: 0 auto; padding: 24px; }
.page-body h1 { font-size: 22px; margin: 4px 0 14px; display: flex; align-items: center; gap: 8px; }
.page-body h2 { font-size: 15px; margin: 0 0 12px; }
.page-body p { line-height: 1.5; }
.page-body a { color: #2563eb; }
.notice { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; padding: 9px 12px; border-radius: 6px; }
.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 9px 12px; border-radius: 6px; }
.meta, .hint { color: #64748b; font-size: 12px; }
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 18px; margin: 18px 0; }
table.users { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
table.users th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #64748b; padding: 9px 12px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
table.users td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; }
table.users tr:last-child td { border-bottom: 0; }
table.users tr.off td { color: #94a3b8; }
table.users .right { text-align: right; }
.tag { font-size: 11px; color: #2563eb; background: #dbeafe; border-radius: 10px; padding: 1px 7px; margin-left: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #059669; margin-left: 2px; vertical-align: middle; }
form.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
form.grid .full { grid-column: 1 / -1; }
form.grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: #64748b; }
form.grid input, form.grid select { height: 36px; border: 2px solid #cbd5e1; border-radius: 6px; padding: 0 10px; background: #F9F9FA; color: #1e293b; font-size: 13px; }
form.grid input:focus, form.grid select:focus { outline: none; border-color: #2563eb; }
form.grid input:disabled { color: #64748b; background: #f1f5f9; }
.page-body button, .page-body .button { height: 36px; padding: 0 16px; border: 1px solid #94a3b8; border-radius: 6px; background: #fff; color: #1e293b; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; font-size: 13px; }
.page-body button:hover, .page-body .button:hover { background: #f1f5f9; }
.page-body .primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.page-body .primary:hover { background: #1d4ed8; }
.page-body .danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.page-body .danger:hover { background: #b91c1c; }
.page-nav button { font-weight: 400; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.danger-zone { border-color: #fecaca; }
.changes { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.changes li { padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
.changes li:last-child { border-bottom: 0; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; background: #fff; border: 1px dashed #94a3b8; border-radius: 8px; padding: 14px 18px; display: inline-block; user-select: all; }
