/* Debriage control panel */
:root {
  --bg: #080d14;
  --bg-soft: #0d141f;
  --panel: #111a27;
  --panel-raised: #15202f;
  --panel-strong: #192637;
  --text: #edf3f8;
  --muted: #8fa0b4;
  --muted-strong: #b2c0ce;
  --line: #253245;
  --line-soft: rgba(143,160,180,.12);
  --brand: #55d6a8;
  --brand-hover: #6ee3b8;
  --brand-2: #70aef5;
  --warning: #f0b85a;
  --danger: #ed7180;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { color: #9bc9ff; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }

/* ---- application shell ------------------------------------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  width: 256px;
  height: 100vh;
  flex: 0 0 256px;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  border-right: 1px solid var(--line);
  background: #0b121c;
}
.sidebar-head { padding: 0 8px 20px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); font-size: 1.05rem; font-weight: 760; letter-spacing: -.025em; }
.brand:hover { color: var(--text); }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: #06120e; background: var(--brand); font-weight: 900; box-shadow: 0 8px 24px rgba(85,214,168,.15); }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: .64rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; min-height: 0; overflow-y: auto; }
.nav-label { padding: 0 12px 8px; color: #647589; font-size: .65rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-link { position: relative; display: flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 8px; color: var(--muted-strong); font-size: .87rem; font-weight: 600; transition: color .12s ease, background .12s ease; }
.nav-link::before { content: ''; width: 5px; height: 5px; margin-right: 11px; border-radius: 50%; background: #435267; transition: background .12s ease, box-shadow .12s ease; }
.nav-link:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-link.active { color: #e9fff7; background: rgba(85,214,168,.09); }
.nav-link.active::before { background: var(--brand); box-shadow: 0 0 0 4px rgba(85,214,168,.1); }
.sidebar .spacer { flex: 1; min-height: 18px; }
.account-card { display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-top: 1px solid var(--line); }
.account-avatar { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 9px; color: var(--brand); background: rgba(85,214,168,.09); border: 1px solid rgba(85,214,168,.18); font-size: .8rem; font-weight: 800; }
.account-copy { min-width: 0; }
.account-copy strong, .account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: .8rem; }
.account-copy small { color: var(--muted); font-size: .68rem; }
.sidebar-actions { display: flex; justify-content: space-between; align-items: center; padding: 0 10px 4px 52px; }
.sidebar-actions form { margin: 0; }
.sidebar-action { padding: 0; border: 0; background: none; color: var(--muted); font-size: .7rem; cursor: pointer; }
.sidebar-action:hover, .sidebar-action.active { color: var(--text); }
.language-switcher { display: flex; justify-content: center; gap: 4px; padding: 10px 4px 2px; }
.language-switcher a { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 8px; filter: grayscale(.55); font-size: 1rem; }
.language-switcher a:hover, .language-switcher a[aria-current="true"] { border-color: var(--line); background: var(--panel-raised); filter: none; }
.login-card > .language-switcher { margin: -8px 0 12px; }
.main { width: calc(100% - 256px); max-width: 1460px; padding: 36px 42px 70px; }
h1.page-title { margin: 0 0 5px; font-size: clamp(1.65rem,2.4vw,2rem); line-height: 1.2; letter-spacing: -.035em; }
.page-sub { max-width: 760px; margin: 0 0 26px; color: var(--muted); font-size: .91rem; }

/* ---- surfaces and data ------------------------------------------- */
.card { margin-bottom: 18px; padding: 22px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 1px 0 rgba(255,255,255,.015), 0 12px 35px rgba(0,0,0,.13); }
.card h2 { margin: 0 0 14px; font-size: 1.03rem; line-height: 1.3; letter-spacing: -.015em; }
.card h3 { color: var(--muted-strong); }
.card .hint { color: var(--muted); font-size: .81rem; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4,minmax(0,1fr)); }
.stat { position: relative; min-height: 104px; padding: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-raised); }
.stat::after { content: ''; position: absolute; right: -18px; bottom: -34px; width: 88px; height: 88px; border-radius: 50%; background: rgba(85,214,168,.045); }
.stat strong { position: relative; display: block; z-index: 1; font-size: 1.65rem; line-height: 1.25; letter-spacing: -.04em; }
.stat span { position: relative; z-index: 1; color: var(--muted); font-size: .76rem; }
table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: .85rem; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { color: #738398; font-size: .66rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
tbody tr:hover, table tr:not(:first-child):hover { background: rgba(255,255,255,.016); }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }

/* ---- statuses ----------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid transparent; border-radius: 999px; font-size: .68rem; font-weight: 750; line-height: 1.4; text-transform: capitalize; }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { color: #79dda9; background: rgba(72,187,120,.075); border-color: rgba(72,187,120,.2); }
.badge.warn { color: #e8bc68; background: rgba(240,184,90,.075); border-color: rgba(240,184,90,.2); }
.badge.err { color: #ef8793; background: rgba(237,113,128,.075); border-color: rgba(237,113,128,.2); }
.badge.muted { color: #95a5b7; background: rgba(143,160,180,.06); border-color: rgba(143,160,180,.16); }

/* ---- controls ----------------------------------------------------- */
label { display: block; margin: 12px 0 6px; color: var(--muted-strong); font-size: .79rem; font-weight: 650; }
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #314056; border-radius: 9px; background: #0d1622; color: var(--text); outline: none; transition: border-color .12s ease, box-shadow .12s ease, background .12s ease; }
textarea { min-height: 120px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #5f7084; }
input:hover, select:hover, textarea:hover { border-color: #40516a; }
input:focus, select:focus, textarea:focus { border-color: rgba(85,214,168,.65); box-shadow: 0 0 0 3px rgba(85,214,168,.08); background: #0f1926; }
select option { background: var(--panel-strong); }
.checkbox { display: flex; align-items: center; gap: 9px; margin: 12px 0; color: var(--text); font-size: .84rem; }
.checkbox input { width: auto; accent-color: var(--brand); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 9px; font-size: .82rem; font-weight: 720; cursor: pointer; white-space: nowrap; transition: border-color .12s ease, background .12s ease, color .12s ease, transform .12s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled, form[aria-busy="true"] .btn { opacity: .55; cursor: wait; transform: none; }
.btn-primary { color: #07130f; background: var(--brand); box-shadow: 0 5px 16px rgba(85,214,168,.1); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { color: var(--muted-strong); background: #172231; border-color: #314056; }
.btn-secondary:hover { color: var(--text); border-color: #43536a; background: #1b2838; }
.btn-danger { color: #f1919c; background: rgba(237,113,128,.07); border-color: rgba(237,113,128,.25); }
.btn-danger:hover { background: rgba(237,113,128,.12); }
.btn-sm { min-height: 31px; padding: 0 10px; border-radius: 8px; font-size: .74rem; }
form.inline { display: inline; }
.form-row { display: flex; align-items: end; flex-wrap: wrap; gap: 13px; }
.form-row > div { flex: 1; min-width: 170px; }

/* ---- feedback and utilities -------------------------------------- */
.flash { position: relative; padding: 12px 15px 12px 38px; margin-bottom: 14px; border: 1px solid; border-radius: 10px; font-size: .84rem; }
.flash::before { position: absolute; left: 15px; top: 11px; font-weight: 900; }
.flash.ok { color: #8ce2b2; background: rgba(72,187,120,.06); border-color: rgba(72,187,120,.22); }
.flash.ok::before { content: '✓'; }
.flash.error { color: #f29aa4; background: rgba(237,113,128,.06); border-color: rgba(237,113,128,.23); }
.flash.error::before { content: '!'; }
.secret-box { padding: 14px 15px; margin: 10px 0; border: 1px solid rgba(85,214,168,.23); border-radius: 9px; background: rgba(85,214,168,.045); font-family: ui-monospace,SFMono-Regular,Menlo,monospace; word-break: break-all; }
.meter { height: 7px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: #263346; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.meter.hot > i { background: var(--danger); }
code, .mono { font-family: ui-monospace,SFMono-Regular,Menlo,monospace; font-size: .86em; }
details.joblog pre { max-height: 260px; overflow: auto; color: var(--muted-strong); white-space: pre-wrap; font-size: .76rem; }

/* ---- login and support ------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 20%,rgba(85,214,168,.08),transparent 30%); }
.login-card { width: min(420px,100%); padding: 32px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.login-card .brand { justify-content: center; margin-bottom: 8px; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); text-align: center; font-size: .85rem; }
.login-card .btn { width: 100%; margin-top: 20px; }
.msg-thread .msg { padding: 14px 16px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-raised); }
.msg-thread .msg.staff { border-color: rgba(85,214,168,.22); background: rgba(85,214,168,.045); }
.msg-thread .msg .meta { margin-bottom: 5px; color: var(--muted); font-size: .7rem; }
.msg-thread .msg p { margin: 0; white-space: pre-wrap; font-size: .86rem; }

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .main { padding: 30px 28px 60px; }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; border: 0; border-bottom: 1px solid var(--line); }
  .sidebar-head { padding: 0 4px 11px; }
  .brand-mark { width: 31px; height: 31px; }
  .sidebar-nav { flex-direction: row; gap: 4px; padding-bottom: 3px; overflow-x: auto; scrollbar-width: thin; }
  .nav-label, .sidebar .spacer, .account-card, .sidebar-actions { display: none; }
  .nav-link { flex: 0 0 auto; min-height: 34px; padding: 0 10px; font-size: .76rem; }
  .nav-link::before { display: none; }
  .main { width: 100%; max-width: none; padding: 24px 16px 50px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .card { padding: 17px; }
}
@media (max-width: 560px) {
  .grid.cols-4 { grid-template-columns: 1fr; }
  .form-row { align-items: stretch; flex-direction: column; }
  .form-row > div { width: 100%; min-width: 0; }
  .form-row > .btn { width: 100%; }
  h1.page-title { font-size: 1.55rem; }
}

/* ---- domains and DNS ---------------------------------------------- */
.page-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.field label { margin-top: 0; }
.optional { color: #73869b; font-size: .72rem; font-weight: 600; }
.form-help { margin: 0; color: var(--muted); font-size: .8rem; }

.domain-add-card { padding: 0; overflow: hidden; }
.domain-add-card > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.domain-add-card > summary::-webkit-details-marker { display: none; }
.domain-add-card > summary:hover { background: rgba(255,255,255,.025); }
.domain-add-card > summary .summary-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: var(--brand);
  background: rgba(110,231,183,.09);
  border: 1px solid rgba(110,231,183,.25);
  font-size: 1.2rem;
}
.domain-add-card > summary strong { display: block; font-size: .96rem; }
.domain-add-card > summary small { display: block; color: var(--muted); font-size: .76rem; font-weight: 500; }
.domain-add-card[open] > summary { border-bottom: 1px solid var(--line); }
.domain-add-form { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; padding: 20px 22px 22px; }
.domain-credentials { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.02); }
.domain-credentials[hidden] { display: none; }
.domain-credentials .form-help { grid-column: 1 / -1; }
.domain-add-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.domain-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.domain-tile { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(15,29,48,.58); }
.domain-tile-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.domain-tile h2 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.domain-provider { color: var(--muted); font-size: .75rem; }
.domain-message { color: #fda4af; font-size: .78rem; margin: 10px 0 0; }
.domain-tile-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 16px 0; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.domain-tile-meta strong { color: var(--text); }
.empty-state, .dns-empty { text-align: center; padding: 38px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty-state-icon { color: var(--brand); font-size: 2rem; }
.empty-state h2 { color: var(--text); margin: 6px 0; font-size: 1.05rem; }
.empty-state p { margin: 0; }

.dns-zone { padding: 0; overflow: hidden; }
.dns-zone-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px; border-bottom: 1px solid var(--line); }
.dns-zone-header h2 { margin: 1px 0 3px; font-size: 1.2rem; }
.dns-zone-header p { margin: 0; color: var(--muted); font-size: .82rem; }
.eyebrow { color: var(--brand); text-transform: uppercase; letter-spacing: .11em; font-size: .66rem; font-weight: 800; }

.dns-add-panel { margin: 16px 22px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.018); overflow: hidden; }
.dns-add-panel > summary { padding: 12px 15px; cursor: pointer; list-style: none; font-size: .84rem; font-weight: 700; }
.dns-add-panel > summary::-webkit-details-marker { display: none; }
.dns-add-panel > summary span { color: var(--brand); font-size: 1.05rem; margin-right: 6px; }
.dns-add-panel[open] > summary { border-bottom: 1px solid var(--line); }
.dns-record-form { padding: 16px; }
.dns-form-grid { display: grid; grid-template-columns: 90px minmax(150px,1fr) minmax(220px,2fr) 110px 130px; gap: 12px; align-items: end; }
.dns-record-form input, .dns-record-form select { min-height: 42px; }
.dns-form-footer { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.dns-form-footer .form-help { flex: 1; }
.form-spacer { flex: 1; }
.proxy-toggle { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); cursor: pointer; white-space: nowrap; }
.proxy-toggle input { accent-color: var(--brand); }

.dns-records { border-top: 1px solid var(--line); }
.dns-record-head, .dns-record-row { display: grid; grid-template-columns: 64px minmax(145px,1.15fr) minmax(180px,1.6fr) 105px 78px 58px; gap: 12px; align-items: center; }
.dns-record-head { padding: 10px 22px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-size: .64rem; font-weight: 800; background: rgba(0,0,0,.1); }
.dns-record-row { min-height: 64px; padding: 11px 22px; border-top: 1px solid var(--line); }
.dns-records .dns-record-row:first-child { border-top: 0; }
.dns-record-item > summary { cursor: pointer; list-style: none; }
.dns-record-item > summary::-webkit-details-marker { display: none; }
.dns-record-item > summary:hover { background: rgba(255,255,255,.025); }
.dns-record-item[open] > summary { background: rgba(110,231,183,.035); }
.dns-type { width: max-content; padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--brand-2); font-family: ui-monospace, monospace; font-size: .75rem; font-weight: 800; }
.dns-name, .dns-content, .dns-routing { min-width: 0; font-size: .82rem; overflow-wrap: anywhere; }
.dns-name { font-weight: 700; }
.dns-content { color: #c8d4e2; font-family: ui-monospace, monospace; }
.dns-name small, .dns-content small, .dns-routing small { display: block; margin-top: 3px; color: var(--muted); font-family: inherit; font-size: .68rem; font-weight: 500; }
.proxy-state { color: var(--muted); font-size: .74rem; }
.proxy-state.on { color: #f59e0b; }
.edit-label { color: var(--brand-2); text-align: right; font-size: .75rem; font-weight: 700; }
.edit-label b { display: inline-block; margin-left: 3px; transition: transform .15s ease; }
.dns-record-item[open] .edit-label b { transform: rotate(180deg); }
.lock-mark { color: var(--muted); text-align: right; }
.system-record { background: rgba(255,255,255,.012); }
.dns-edit-panel { padding: 4px 22px 18px; border-top: 1px solid rgba(110,231,183,.13); background: rgba(5,11,19,.25); }
.dns-edit-panel .dns-record-form { padding: 16px 0 0; }
.dns-delete-form { display: flex; justify-content: flex-start; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.record-error { margin: 14px 0 0; color: #fda4af; font-size: .78rem; }
.dns-empty { margin: 18px 22px 22px; padding: 28px; }
.dns-empty strong, .dns-empty span { display: block; }
.dns-empty strong { color: var(--text); }
.dns-empty span { font-size: .8rem; margin-top: 3px; }

@media (max-width: 1050px) {
  .domain-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dns-form-grid { grid-template-columns: 90px 1fr 1.5fr; }
  .dns-form-grid > :nth-child(4), .dns-form-grid > :nth-child(5) { grid-row: 2; }
  .dns-record-head { display: none; }
  .dns-record-row { grid-template-columns: 54px minmax(130px,1fr) minmax(160px,1.4fr) 90px 72px 48px; }
}

@media (max-width: 720px) {
  .domain-add-form, .domain-credentials { grid-template-columns: 1fr; }
  .domain-credentials .form-help, .domain-add-actions { grid-column: 1; }
  .domain-add-actions { align-items: stretch; flex-direction: column; }
  .domain-overview { grid-template-columns: 1fr; }
  .dns-zone-header { align-items: flex-start; flex-direction: column; }
  .dns-form-grid { grid-template-columns: 1fr 1fr; }
  .dns-value-field { grid-column: 1 / -1; }
  .dns-form-grid > :nth-child(4), .dns-form-grid > :nth-child(5) { grid-row: auto; }
  .dns-form-footer { align-items: stretch; flex-direction: column; }
  .dns-form-footer .btn { width: 100%; }
  .dns-record-row { grid-template-columns: 52px 1fr auto; gap: 8px 10px; padding: 14px 16px; }
  .dns-record-row .dns-content { grid-column: 2 / -1; }
  .dns-record-row .dns-routing { grid-column: 2; }
  .dns-record-row > :nth-child(5) { grid-column: 3; grid-row: 1; }
  .dns-record-row > :nth-child(6) { grid-column: 3; grid-row: 3; }
  .dns-edit-panel { padding: 4px 16px 16px; }
  .dns-delete-form .btn { width: 100%; }
}
