:root {
  color-scheme: dark;
  --page: #0b131c;
  --sidebar: #070d14;
  --surface: #131f2b;
  --raised: #1a2a39;
  --line: #33495d;
  --control-line: #657f95;
  --text: #edf3f8;
  --muted: #adbfcd;
  --blue: #84cbfb;
  --button-text: #092033;
  --blue-hover: #b7e1ff;
  --green-bg: #163b32;
  --green: #a7e6cd;
  --amber-bg: #443619;
  --amber: #ffdc91;
  --red-bg: #4a2229;
  --red: #ffbec6;
  background: var(--page);
  color: var(--text);
  font: 16px/1.5 system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
.dashboard { display: grid; grid-template-columns: 225px minmax(0, 1fr); }
aside { display: flex; flex-direction: column; gap: 24px; padding: 22px 18px; background: var(--sidebar); border-right: 1px solid var(--line); }
.brand { display: grid; justify-items: center; color: var(--muted); text-decoration: none; }
.brand img { width: 156px; height: 153px; object-fit: contain; }
.brand span { margin-top: -12px; font-size: .76rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
nav { display: grid; gap: 6px; }
nav a { display: block; border: 1px solid transparent; border-radius: 7px; padding: 9px 12px; color: var(--muted); text-decoration: none; }
nav a:hover, nav a[aria-current="page"] { background: var(--raised); color: var(--text); }
nav a[aria-current="page"] { border-color: var(--line); color: var(--blue); font-weight: 700; }
#logout { margin-top: auto; align-self: start; }
main { width: 100%; max-width: 1240px; padding: 36px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 20px; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.035em; line-height: 1.15; }
h2 { margin-bottom: 8px; font-size: 1.22rem; }
h3 { margin-bottom: 6px; }
section { min-width: 0; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
label { display: block; margin: 10px 0 4px; font-weight: 650; }
input, textarea, select, button { max-width: 100%; min-width: 0; border: 1px solid var(--control-line); border-radius: 6px; padding: 7px 10px; font: inherit; }
input, textarea, select { background: var(--page); color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--muted); }
button { border-color: var(--blue); background: var(--blue); color: var(--button-text); cursor: pointer; font-weight: 650; }
button:hover:not(:disabled) { background: var(--blue-hover); }
button:disabled { opacity: .55; cursor: wait; }
#logout, #cancel-customer { border-color: var(--control-line); background: transparent; color: var(--text); }
#logout:hover:not(:disabled), #cancel-customer:hover:not(:disabled) { background: var(--raised); }
a { color: var(--blue); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.row, .actions, .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row input { flex: 1 1 125px; }
.inline-form { margin: 14px 0 18px; }
.inline-form label { margin: 0; }
ul { padding-left: 20px; }
#status { margin-bottom: 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--raised); color: var(--text); }
#status.error { background: var(--red-bg); color: var(--red); }

.section-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 18px; }
.section-heading p, .website-card p, #nginx-detail, .result-count { color: var(--muted); }
.section-heading p { margin-bottom: 0; }
.status-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.status-tile, .proxy-status { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); }
.status-tile strong { font-size: 1.65rem; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge.ready { background: var(--green-bg); color: var(--green); }
.badge.issue { background: var(--red-bg); color: var(--red); }
.badge.pending { background: var(--amber-bg); color: var(--amber); }
.proxy-status { margin-bottom: 16px; }
#nginx-detail { font-size: .9rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); }
th { background: var(--raised); color: var(--muted); font-size: .82rem; }
tbody tr:last-child td { border-bottom: 0; }
td a { font-weight: 650; }
.list-controls { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(2, minmax(140px, 1fr)); gap: 12px; margin: 12px 0; }
.list-controls label { margin: 0; color: var(--muted); font-size: .86rem; }
.list-controls input, .list-controls select { display: block; width: 100%; margin-top: 4px; }
.result-count { margin: 8px 0 12px; font-size: .86rem; }

#customer-detail h2 { margin-top: 14px; }
.website-card { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.website-card p { margin: 7px 0; }
.website-card details { margin-top: 10px; }
.website-card summary { cursor: pointer; color: var(--blue); font-weight: 650; }
.website-card form { padding: 8px 0 12px; }
.website-card textarea { width: 100%; }
.thumbnail { position: relative; display: grid; place-items: center; width: 240px; height: 144px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--muted); font-size: .85rem; }
.thumbnail iframe { position: absolute; inset: 0; width: 960px; height: 576px; border: 0; transform: scale(.25); transform-origin: top left; pointer-events: none; background: #fff; color-scheme: light; }
.release { margin-top: 10px; font-size: .9rem; }

#customer-dialog { width: min(420px, calc(100% - 32px)); padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 16px 48px #0008; }
#customer-dialog::backdrop { background: #000a; }
#customer-dialog input { width: 100%; }
#customer-error { margin: 8px 0 0; color: var(--red); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.login-page main { max-width: 480px; margin: auto; padding-top: 20px; }
.login-page header { text-align: center; }
.login-logo { width: 202px; height: 198px; object-fit: contain; }
.login-page header h1 { font-size: 1.75rem; }
.login-page input { display: block; width: 100%; margin-bottom: 14px; }
.login-page button { margin-top: 4px; }
.login-page form a { margin-left: 8px; }
.login-page code { overflow-wrap: anywhere; }
#qr { display: block; max-width: 100%; height: auto; margin-bottom: 8px; border-radius: 6px; background: #fff; }

@media (max-width: 900px) { main { padding: 24px; } }
@media (max-width: 760px) {
  .dashboard { grid-template-columns: 160px minmax(0, 1fr); }
  .brand img { width: 116px; height: 114px; }
  .website-card { grid-template-columns: 1fr; }
  .list-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-controls label:first-child { grid-column: 1/-1; }
}
@media (max-width: 560px) {
  .dashboard { display: block; }
  aside { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 7px 14px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand img { width: 57px; height: 56px; }
  .brand span { display: none; }
  nav { display: flex; }
  #logout { align-self: center; margin: 0 0 0 auto; }
  main { padding: 16px; }
  section { padding: 14px; }
  th, td { padding: 9px 7px; }
  .status-summary { gap: 6px; }
  .status-tile { display: block; padding: 7px; }
  .status-tile .badge { font-size: .7rem; }
}

.backup-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 16px}
.backup-fields input,.backup-fields select{display:block;width:100%;margin-top:4px}
#backup-settings,#backup-schedule{margin-bottom:24px}
#backup-jobs{overflow-wrap:anywhere}
@media(max-width:560px){.backup-fields{grid-template-columns:1fr}}

.operation-alert { background: var(--red-bg); color: var(--red); padding: 10px 12px; border-radius: 6px; }
#backup-restore { margin: 16px 0 24px; }
#backup-restore button { margin-top: 12px; }

.backup-fields.restore-fields { grid-template-columns: minmax(0, 1fr); max-width: 36rem; }

#invite-result { margin-bottom: 20px; }
#invite-link { min-width: min(22rem,100%); }

#role-permission-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 8px 16px;
}

#role-permission-options label {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#role-permission-options input {
  width: auto;
}
