*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface2:    #21262d;
  --surface3:    #2d333b;
  --border:      #30363d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --accent:      #a371f7;
  --accent-dim:  #6e40c9;
  --accent-glow: rgba(163,113,247,.15);
  --success:     #3fb950;
  --danger:      #f85149;
  --warning:     #d29922;
  --info:        #58a6ff;
  --sidebar-w:   230px;
  --radius:      8px;
  --tr:          .18s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.logo-wrap {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  min-height: 64px;
}
.logo-wrap img { max-height: 36px; max-width: 180px; object-fit: contain; }
.logo-text { font-size: 17px; font-weight: 700; background: linear-gradient(135deg,#a371f7,#58a6ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.logo-text span { -webkit-text-fill-color: var(--accent); }
.logo-sub { font-size: 11px; color: var(--text-muted); display: block; margin-top: 2px; }

nav { padding: 12px 10px; flex: 1; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-muted); padding: 8px 8px 4px; }
nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--text-muted); text-decoration: none; font-size: 13.5px;
  transition: all var(--tr); margin-bottom: 2px;
}
nav a:hover { background: var(--surface2); color: var(--text); }
nav a.active { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(163,113,247,.25); }
nav a svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg,#a371f7,#58a6ff); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ── Main ─────────────────────────────────────────────────────── */
#main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

#topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13,17,23,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.page-title { font-size: 16px; font-weight: 600; }

#content { padding: 24px 28px; flex: 1; }

/* ── Stats ────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Panel ────────────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-title { font-size: 14px; font-weight: 600; }
.panel-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Form controls ────────────────────────────────────────────── */
input[type="text"], input[type="url"], select, textarea {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 7px 12px; font-size: 13px; outline: none; font-family: inherit;
  transition: border-color var(--tr), box-shadow var(--tr);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select option { background: var(--surface2); }
textarea { resize: vertical; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: all var(--tr); text-decoration: none; white-space: nowrap; font-family: inherit;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid rgba(248,81,73,.4); }
.btn-danger-outline:hover { background: rgba(248,81,73,.1); }

/* ── Table ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
th { padding: 10px 16px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--tr); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
td { padding: 12px 16px; vertical-align: middle; }

.cell-name { font-weight: 600; }
.cell-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-mono { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 12px; color: var(--accent); }
.cell-url { font-size: 12px; color: var(--text-muted); max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.id-cell { font-family: monospace; font-size: 12px; color: var(--text-muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-active   { background: rgba(63,185,80,.15);  color: var(--success); }
.badge-inactive { background: rgba(139,148,158,.12); color: var(--text-muted); }
.badge-project  { background: rgba(88,166,255,.12);  color: var(--info); }
.badge-tld      { background: rgba(210,153,34,.12);   color: var(--warning); }

.row-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 6px; background: transparent;
  border: 1px solid transparent; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all var(--tr);
}
.icon-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border); }
.icon-btn.is-danger:hover { background: rgba(248,81,73,.12); color: var(--danger); border-color: rgba(248,81,73,.3); }
.icon-btn svg { width: 14px; height: 14px; }

/* ── Pagination ───────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; }
.page-btn { width: 28px; height: 28px; border-radius: 5px; background: transparent; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; text-decoration: none; transition: all var(--tr); }
.page-btn:hover, .page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 520px; max-width: calc(100vw - 40px); max-height: calc(100vh - 80px); overflow-y: auto; transform: translateY(12px) scale(.98); transition: transform .2s ease; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
.modal-overlay.open .modal { transform: none; }
.modal-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.label-note { font-weight: 400; text-transform: none; color: var(--text-muted); font-size: 11px; }
input[type="text"].full, input[type="url"].full, select.full, textarea.full { width: 100%; }

/* ── View detail ──────────────────────────────────────────────── */
.view-field { margin-bottom: 14px; }
.view-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 4px; }
.view-value { font-size: 13px; color: var(--text); word-break: break-all; }
.view-value.mono { font-family: monospace; color: var(--accent); }

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { width: 40px; height: 40px; opacity: .3; display: block; margin: 0 auto 12px; }

/* ── Flash ────────────────────────────────────────────────────── */
.flash { padding: 10px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 20px; border: 1px solid; }
.flash.success { background: rgba(63,185,80,.1);  border-color: rgba(63,185,80,.3);  color: var(--success); }
.flash.error   { background: rgba(248,81,73,.1);  border-color: rgba(248,81,73,.3);  color: var(--danger); }

/* ── Projects view ────────────────────────────────────────────── */
.project-list { display: flex; flex-direction: column; gap: 1px; }
.project-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.project-row:last-child { border-bottom: none; }
.project-name { font-weight: 600; }
.project-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.project-info { min-width: 150px; }
.project-tlds { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.tld-chip { display: inline-flex; align-items: center; gap: 2px; background: rgba(88,166,255,.1); border: 1px solid rgba(88,166,255,.25); color: var(--info); border-radius: 20px; padding: 3px 6px 3px 10px; font-size: 11px; font-weight: 600; }
.tld-del { background: none; border: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; opacity: .6; }
.tld-del:hover { opacity: 1; }
.tld-add-form { display: flex; align-items: center; gap: 6px; }
.tld-input { width: 140px !important; padding: 4px 10px !important; font-size: 12px !important; }
.tld-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; }
.tld-check-item { display: inline-flex; align-items: center; gap: 6px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 13px; transition: border-color var(--tr); user-select: none; }
.tld-check-item:hover { border-color: var(--accent); }
.tld-check-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; margin: 0; }

/* ── Watermark ────────────────────────────────────────────────── */
body::after {
  content: "TESTING ONLY\A NOT TO BE USED AT CLIENT";
  white-space: pre;
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 900;
  color: rgba(255,255,255,.07);
  text-align: center;
  line-height: 1.3;
  pointer-events: none;
  z-index: 99999;
  transform: rotate(0deg);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── TLD picker popup ─────────────────────────────────────────── */
#tld-picker { position: absolute; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 6px; z-index: 10000; box-shadow: 0 8px 24px rgba(0,0,0,.5); min-width: 180px; }
.tld-picker-label { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); padding: 4px 8px 6px; }
#tld-picker button { display: block; width: 100%; padding: 7px 10px; background: none; border: none; color: var(--text); font-size: 12px; font-family: 'SFMono-Regular', Consolas, monospace; text-align: left; cursor: pointer; border-radius: 5px; }
#tld-picker button:hover { background: var(--surface3); color: var(--accent); }

/* ── Toast ────────────────────────────────────────────────────── */
#toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; font-size: 13px; color: var(--text); z-index: 9999; transform: translateY(8px); opacity: 0; transition: all .25s ease; pointer-events: none; max-width: 300px; }
#toast.show { opacity: 1; transform: none; }
