/* Five Lion Labs admin. Colours match the public site. */
:root, html[data-theme=dark] {
  color-scheme: dark;
  --bg: #080808; --panel: #0e0e10; --panel-2: #141416; --line: rgba(168,159,141,.16); --line-2: rgba(168,159,141,.28);
  --text: #f4f1ec; --muted: #a89f8d; --gold: #c9a44a; --gold-2: #d9bd76; --gold-bg: rgba(201,164,74,.12);
  --new: #3ecf8e; --new-bg: rgba(62,207,142,.12); --err: #ff6b6b; --err-bg: rgba(255,107,107,.12);
  --hover: rgba(255,255,255,.035); --shadow: 0 30px 80px rgba(0,0,0,.6);
}
html[data-theme=light] {
  color-scheme: light;
  --bg: #f5f1e8; --panel: #fbf9f4; --panel-2: #f2ede3; --line: rgba(62,58,51,.14); --line-2: rgba(62,58,51,.24);
  --text: #1f1f21; --muted: #645f56; --gold: #a07926; --gold-2: #876320; --gold-bg: rgba(184,144,47,.12);
  --new: #13834f; --new-bg: rgba(19,131,79,.1); --err: #c62828; --err-bg: rgba(198,40,40,.08);
  --hover: rgba(28,28,31,.04); --shadow: 0 30px 80px rgba(60,50,30,.25);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); padding: 2px 6px; border-radius: 6px; letter-spacing: .05em; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 40px);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--gold); font-weight: 600; }
.brand em { font-style: normal; font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 9px; margin-left: 4px; }
.top nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.top nav a { color: var(--muted); padding: 8px 12px; border-radius: 999px; font-size: 14px; }
.top nav a:hover { color: var(--text); text-decoration: none; background: var(--hover); }
.top nav a.on { color: var(--text); background: var(--panel-2); }
.top nav form { margin: 0; }

.icon-btn { background: transparent; border: 1px solid var(--line-2); border-radius: 999px; min-width: 34px; height: 34px; padding: 0 10px; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--gold); }
.icon-btn.danger:hover { color: var(--err); border-color: var(--err); }
.ghost { background: transparent; border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 14px; font-size: 14px; color: var(--text); }
.ghost:hover { border-color: var(--gold); }
.primary { white-space: nowrap; background: var(--gold); color: #0b0b0b; border: 0; border-radius: 999px; padding: 11px 20px; font-weight: 600; }
.primary:hover { background: var(--gold-2); }
.link { background: none; border: 0; padding: 0; color: var(--gold-2); text-decoration: underline; }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 40px) 40px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: clamp(20px, 3vw, 32px); margin-bottom: 20px; }
.card.narrow { max-width: 460px; margin: 6vh auto 20px; }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 18px; font-weight: 600; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; letter-spacing: -.01em; }
.msg { padding: 10px 14px; border-radius: 12px; margin: 0 0 16px; }
.msg.err { background: var(--err-bg); color: var(--err); }
.msg.ok { background: var(--new-bg); color: var(--new); }
.pad { padding: 12px 16px; margin: 0; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.form input, .form select {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 11px 13px; width: 100%;
}
.form input:focus, .form select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-bg); }
.form .primary { justify-self: start; margin-top: 4px; }
.inline-form { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; }
.inline-form .port { max-width: 110px; }
.inline-form .primary { margin-top: 0; }
.steps { padding-left: 20px; margin: 0 0 18px; display: grid; gap: 10px; }
.qr { width: 190px; height: 190px; margin: 12px 0 6px; background: #fff; border-radius: 12px; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.settings-col { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: 0; }
.plain-list .addr { overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 6px; }
.row-actions form { margin: 0; }

/* ---------- dashboard: three columns ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.col-head h2 { margin: 0; font-size: 18px; }
.col-head h2::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-right: 10px; vertical-align: 2px; }
.domain { font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.boxes { list-style: none; margin: 0; padding: 6px; }
.box + .box { border-top: 1px solid var(--line); }
.box-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: transparent; border: 0; border-radius: 12px; padding: 13px 14px; text-align: left;
}
.box-row:hover { background: var(--hover); }
.box.open .box-row { background: var(--panel-2); }
.box-row .addr { font-weight: 500; overflow-wrap: anywhere; }
.box-row .addr::before { content: '›'; display: inline-block; width: 14px; color: var(--muted); transition: transform .2s; }
.box.open .box-row .addr::before { transform: rotate(90deg); }
.state { flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; padding: 4px 10px; border-radius: 999px; color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.state i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .7; }
.state.new { color: var(--new); background: var(--new-bg); border-color: transparent; font-weight: 600; }
.state.new i { opacity: 1; box-shadow: 0 0 0 3px var(--new-bg); animation: pulse 2s infinite; }
.state.error { color: var(--err); background: var(--err-bg); border-color: transparent; cursor: help; }
.state.loading i { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.empty { padding: 16px 14px; color: var(--muted); font-size: 14px; }

.msgs { padding: 4px 0 8px; }
.msg-list { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.item { width: 100%; display: grid; gap: 2px; text-align: left; background: transparent; border: 0; border-radius: 10px; padding: 9px 14px 9px 28px; position: relative; }
.item:hover { background: var(--hover); }
.item.unread::before { content: ''; position: absolute; left: 12px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--new); }
.msg-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.msg-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.item.unread .msg-from { color: var(--text); font-weight: 600; }
.msg-date { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.msg-subject { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.unread .msg-subject { font-weight: 600; }

/* ---------- e-mail popup ---------- */
dialog#mail {
  width: min(960px, 96vw); max-height: 92vh; padding: 0; border: 1px solid var(--line-2); border-radius: 20px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow); overflow: hidden;
  display: none; flex-direction: column;
}
dialog#mail[open] { display: flex; }
dialog#mail::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.mail-head { display: flex; justify-content: space-between; gap: 16px; padding: 20px 24px 14px; border-bottom: 1px solid var(--line); }
.mail-meta { min-width: 0; }
.mail-meta h3 { margin: 0 0 6px; font-size: 19px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.mail-meta p { margin: 0; overflow-wrap: anywhere; }
.mail-meta .from { font-size: 14px; }
.blocked-note { margin: 0; padding: 9px 24px; font-size: 13px; background: var(--gold-bg); color: var(--text); }
.mail-body { overflow-y: auto; overflow-x: hidden; background: #fff; flex: 1; min-height: 160px; }
.mail-body iframe { display: block; width: 100%; border: 0; min-height: 160px; background: #fff; }
.attachments { list-style: none; margin: 0; padding: 12px 24px; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); }
.att { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.att:hover { border-color: var(--gold); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); margin-top: auto; }
.foot-inner {
  max-width: 1600px; margin: 0 auto; padding: 18px clamp(16px, 3vw, 40px);
  display: flex; justify-content: space-between; align-items: center; gap: 10px 24px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted);
}
.foot a { color: var(--muted); }
.foot a:hover { color: var(--text); }
.foot b { color: var(--text); font-weight: 500; }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .board, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .brand span { display: none; }
  .mail-head { padding: 16px; }
  dialog#mail { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .foot-inner { justify-content: center; text-align: center; }
}
@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 8px; }
  .top nav { gap: 4px; }
  .top nav a { padding: 6px 9px; font-size: 13px; }
  .ghost { padding: 6px 11px; font-size: 13px; }
  .brand em { display: none; }
}

/* ---------- actions, compose, toast ---------- */
.mail-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--panel); }
.act { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--text); white-space: nowrap; }
.act:hover { border-color: var(--gold); }
.act.primary-act { background: var(--gold); border-color: var(--gold); color: #0b0b0b; font-weight: 600; }
.act.primary-act:hover { background: var(--gold-2); }
.act.danger:hover { border-color: var(--err); color: var(--err); }
.act-gap { flex: 1; }
.list-bar { display: flex; justify-content: flex-end; padding: 2px 14px 6px; }
.small-btn { padding: 5px 12px; font-size: 12.5px; }

dialog#compose {
  width: min(820px, 96vw); max-height: 94vh; padding: 0; border: 1px solid var(--line-2); border-radius: 20px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow); overflow: hidden;
}
dialog#compose::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.compose { display: flex; flex-direction: column; max-height: 94vh; margin: 0; }
.compose-fields { padding: 14px 24px; display: grid; gap: 10px; overflow-y: auto; }
.compose-fields label:not(.check) { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.compose-fields input:not([type=checkbox]), .compose-fields textarea {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; width: 100%;
}
.compose-fields textarea { min-height: 300px; resize: vertical; line-height: 1.55; font-size: 14.5px; }
.compose-fields input:focus, .compose-fields textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-bg); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.compose-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); }
.compose-foot .primary:disabled { opacity: .6; cursor: progress; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  transition: opacity .2s, transform .2s; z-index: 100; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); color: #fff; }
@media (max-width: 640px) {
  .mail-actions { padding: 10px 16px; }
  .act-gap { display: none; }
  dialog#compose { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .compose { max-height: 100vh; height: 100%; }
  .compose-fields { flex: 1; }
  .compose-fields label:not(.check) { grid-template-columns: 1fr; gap: 4px; }
}
