/* NoirLux Mail / Studio Edition. Dark, grid-led, editorial, retro-digital. */
:root {
  color-scheme: dark;
  --bg: #0b0b0a;
  --surface: #131310;
  --surface2: #191916;
  --raised: #20201c;
  --line: #37372f;
  --line-soft: #25251f;
  --text: #f0efe8;
  --muted: #a19f95;
  --accent: #d4af37;
  --accent2: #9b7938;
  --radius: 2px;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', 'Cascadia Code', 'Consolas', monospace;
  --sans: 'Helvetica Neue', 'Arial', sans-serif;
  font-family: var(--sans);
}
*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: .12; background-image: linear-gradient(to right, #888 1px, transparent 1px), linear-gradient(to bottom, #888 1px, transparent 1px); background-size: 80px 80px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 3.4vw, 48px); font-weight: 500; letter-spacing: -.065em; line-height: 1.12; margin-bottom: 9px; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -.03em; }
h3 { font-size: 14px; font-weight: 600; }
p { color: var(--muted); }
small { font-size: 11px; }
code { background: #1a1a16; padding: 3px 6px; border: 1px solid var(--line); color: var(--accent); font-family: var(--mono); border-radius: 0; }
[hidden] { display: none !important; }
.block { display: block; }
.muted { color: var(--muted); }
.ambient { display: none; }

/* Application shell */
.shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; background: #10100e; border-right: 1px solid var(--line); padding: 21px 13px 18px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 7px 9px 23px; margin-bottom: 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.brand img { height: 34px; width: 34px; object-fit: contain; filter: saturate(.65); }
.brand span { display: flex; align-items: baseline; gap: 6px; }
.brand b { font-size: 21px; font-weight: 600; letter-spacing: -.06em; }
.brand small { font: 11px var(--mono); color: var(--accent); letter-spacing: .06em; }
.instance-pill { display: flex; gap: 10px; align-items: center; background: var(--surface2); border: 1px solid var(--line); padding: 12px; }
.instance-pill div { min-width: 0; }
.instance-pill strong { display: block; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.instance-pill small { display: block; font: 10px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.gold-dot { width: 7px; height: 7px; flex-shrink: 0; background: var(--accent); }
.field-label, .side-section { display: block; font: 10px var(--mono); font-weight: 500; text-transform: uppercase; letter-spacing: .11em; color: var(--muted); padding: 11px 8px 4px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid transparent; color: #bcbab2; font-size: 12px; transition: background .12s, color .12s, border-color .12s; }
.nav a > span { width: 20px; text-align: center; font-size: 15px; }
.nav a:hover { background: #1d1d19; border-color: var(--line-soft); color: var(--text); }
.nav a.active { background: #211e15; border-color: color-mix(in srgb, var(--accent) 42%, #25251f); color: var(--accent); box-shadow: inset 2px 0 var(--accent); }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--line); padding: 17px 4px 0; display: flex; align-items: center; gap: 9px; }
.avatar { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--accent2); color: var(--accent); background: #211e15; font: 14px var(--mono); flex-shrink: 0; }
.avatar.mini { width: 28px; height: 28px; font-size: 11px; }
.account { min-width: 0; flex: 1; }
.account strong, .account small { display: block; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.account strong { font-size: 12px; font-weight: 600; }
.account small { color: var(--muted); font: 10px var(--mono); margin-top: 4px; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--muted); width: 32px; height: 32px; font-size: 17px; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { min-height: 65px; padding: 0 clamp(20px, 4vw, 56px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 15px; background: #10100e; }
.breadcrumbs { font: 10px var(--mono); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.breadcrumbs span { color: var(--accent); margin: 0 9px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.chip { border: 1px solid #484638; padding: 7px 9px; color: #c1bb9e; background: #1a1913; font: 9px var(--mono); letter-spacing: .04em; white-space: nowrap; }
.content { width: 100%; max-width: 1600px; margin: 0 auto; padding: 36px clamp(20px, 4vw, 56px) 55px; flex: 1; }
.footer { padding: 16px clamp(20px, 4vw, 56px); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font: 10px var(--mono); letter-spacing: .07em; }
.footer span { color: #777568; }
.page-heading { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 21px; margin: 0 0 23px; }
.page-heading p { margin: 8px 0 0; max-width: 720px; }
.eyebrow { display: flex; gap: 11px; align-items: center; font: 10px var(--mono); letter-spacing: .17em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.eyebrow::before { content: '◆'; font-size: 9px; }

/* Framed content / editorial grids */
.card { min-width: 0; padding: 25px; background: var(--surface); border: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.card h2 { margin-bottom: 22px; }
.card-header { display: flex; justify-content: space-between; align-items: center; }
.spaced { margin-top: 17px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; min-width: 0; }
.grid-2 > .card { min-width: 0; }
.narrow { max-width: 650px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-bottom: 18px; border: 1px solid var(--line); }
.metric { background: #151511; padding: 19px 23px 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; font: 10px var(--mono); text-transform: uppercase; color: var(--muted); letter-spacing: .11em; }
.metric strong { display: block; font: 500 36px var(--sans); color: var(--text); letter-spacing: -.07em; margin-top: 9px; line-height: 1; }
.metric strong::before { content: '›'; color: var(--accent); font: 18px var(--mono); vertical-align: top; margin-right: 9px; }

/* Buttons / forms */
.button { border: 1px solid #4b493d; border-radius: 0; min-height: 39px; padding: 10px 15px; background: #22221c; color: #e9e6d9; display: inline-flex; justify-content: center; align-items: center; gap: 8px; font: 600 11px var(--mono); letter-spacing: .025em; transition: .12s; white-space: nowrap; }
.button:hover { border-color: var(--accent); background: #302c20; color: #fff; }
.button.primary { color: #17150d; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: color-mix(in srgb, var(--accent) 82%, white); border-color: color-mix(in srgb, var(--accent) 82%, white); }
.button.subtle { background: #181814; border-color: var(--line); color: #c6c2b5; }
.button.discord { background: #5865f2; color: #fff; border-color: #5865f2; }
.button.tiny { font-size: 10px; padding: 5px 9px; min-height: 28px; }
.button.full { width: 100%; }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.inline-form { display: inline-flex; margin: 2px; }
.action-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
input, select, textarea { width: 100%; min-height: 41px; padding: 10px 12px; color: var(--text); background: #0c0c0b; border: 1px solid #48483d; border-radius: 0; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: inset 2px 0 var(--accent); }
input::placeholder, textarea::placeholder { color: #77766e; }
input:disabled { opacity: .65; cursor: not-allowed; }
input[type=color] { height: 44px; padding: 4px; cursor: pointer; }
textarea { resize: vertical; }
.form-stack { display: flex; flex-direction: column; gap: 15px; }
.form-stack label, .form-grid label { display: block; font-size: 12px; font-weight: 500; color: #d8d6cb; }
.form-stack label > input, .form-stack label > select, .form-stack label > textarea, .form-grid label > input, .form-grid label > select, .form-grid label > textarea { display: block; margin-top: 7px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid hr { width: 100%; }
.check { display: flex !important; align-items: center; gap: 9px; }
.check input { min-height: 16px; width: 16px; height: 16px; margin: 0 !important; accent-color: var(--accent); }
label small, .form-note { display: block; margin-top: 6px; font: 11px/1.6 var(--mono); color: var(--muted); }
.owner-selector { border-top: 1px solid var(--line); padding: 10px 0 0; }
.owner-selector .field-label { padding: 0 0 10px; }
.owner-selector .check { margin: 7px 0; }
.owner-new { padding: 14px; border: 1px solid var(--line); background: #1b1a14; }
.alert { padding: 14px 17px; border: 1px solid #507253; background: #1a241a; color: #b0d5b0; margin-bottom: 20px; }
.alert.error { border-color: #9c5651; background: #291a18; color: #f1aaa3; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.center { text-align: center; }
.auth-card { max-width: 470px; padding: 33px; margin: min(11vh, 100px) auto; }
.auth-card h1 { margin-top: 7px; }
.auth-card p { margin-bottom: 27px; }

/* Admin navigation / tables */
.tabs { display: flex; flex-wrap: nowrap; gap: 0; overflow: auto; border: 1px solid var(--line); background: #11110e; margin-bottom: 18px; }
.tabs a { padding: 12px 17px; font: 11px var(--mono); border-right: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tabs a.selected { background: var(--accent); color: #17150d; }
.tabs a:hover:not(.selected) { background: var(--surface2); color: var(--text); }
.tag { display: inline-block; padding: 4px 8px; border: 1px solid #4a493d; background: #1b1b17; color: #bcb9aa; font: 10px var(--mono); white-space: nowrap; }
.tag.ok { color: #a3c5aa; border-color: #456249; background: #1a251b; }
.tag.off { color: #d49f9f; border-color: #714747; background: #2b1c1c; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
th { padding: 11px 10px; border-bottom: 1px solid var(--line); color: #a9a69b; background: #191914; font: 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
td { padding: 14px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:hover td { background: #191914; }
td strong { font-weight: 600; }
.domain-list { display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--line); }
.domain-row { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 14px 8px; }
.domain-row.selected { background: #221f16; box-shadow: inset 3px 0 var(--accent); }
.domain-row:hover { background: #201f19; }
.domain-row > span:nth-child(2) { flex: 1; min-width: 0; }
.domain-row strong, .domain-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domain-row small, .small-row small, .resource-row small { color: var(--muted); }
.domain-icon { font: 23px var(--mono); color: var(--accent); }
.small-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.small-row strong, .small-row small { display: block; }
.pill-row { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 20px; border-left: 1px solid var(--line); }
.pill { border: 1px solid var(--line); border-left: none; padding: 8px 12px; color: var(--muted); font: 11px var(--mono); }
.pill.on { color: #16130c; background: var(--accent); border-color: var(--accent); }
.mini-details { display: inline-block; margin: 4px; vertical-align: top; font-size: 11px; }
.mini-details summary { cursor: pointer; color: var(--accent); font: 11px var(--mono); }
.mini-details .form-stack { width: 210px; padding: 13px; margin-top: 10px; border: 1px solid var(--line); background: #191914; }
.mini-details.account-password .form-stack { width: min(270px, 70vw); }

/* Mailbox */
.mailbox-card { padding: 0; }
.toolbar { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; width: min(100%, 520px); }
.search input { background: #0c0c0b; }
.messages-list { min-height: 320px; }
.mail-item { display: grid; grid-template-columns: 225px minmax(0, 1fr) 110px; gap: 18px; align-items: center; padding: 16px 21px; border-bottom: 1px solid var(--line-soft); transition: background .12s; }
.mail-item:hover { background: #222119; }
.mail-item.unread { background: #1b1a13; box-shadow: inset 2px 0 var(--accent); }
.mail-item.unread:hover { background: #27251b; }
.sender { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sender > div, .subject-preview { min-width: 0; }
.sender strong, .sender small, .subject-preview strong, .subject-preview small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sender small, .subject-preview small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.subject-preview strong { font-size: 13px; font-weight: 500; }
.unread .sender strong, .unread .subject-preview strong { font-weight: 700; color: #fff; }
.mail-meta { text-align: right; font: 13px var(--mono); color: var(--accent); }
.mail-meta small { color: var(--muted); display: block; white-space: nowrap; }
.empty { padding: 65px 20px; text-align: center; }
.empty-icon { font-size: 34px; color: var(--accent); }
.empty p { margin-bottom: 0; }
.back-link { display: inline-block; color: var(--accent); margin-bottom: 18px; }
.message-detail { max-width: 1100px; }
.message-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.message-head h1 { font-size: 28px; }
.message-from { display: flex; align-items: center; gap: 11px; margin-top: 16px; }
.message-from strong, .message-from small { display: block; }
.message-from small { color: var(--muted); }
.recipient-details { padding: 14px 0; color: var(--muted); }
.recipient-details p { margin: 4px 0; font-size: 12px; }
.recipient-details b { color: var(--text); }
.message-body { padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mail-preview { display: block; width: 100%; height: 380px; border: 1px solid #b8b6af; border-radius: 0; background: #fff; }
.message-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 20px; }
.attachments { padding: 18px 0; border-bottom: 1px solid var(--line); }
.attachments .button { margin: 5px; }

/* Composer */
.compose { max-width: 1100px; padding: 0; overflow: hidden; }
.compose-head { display: flex; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); background: #1b1a14; }
.compose-head h2 { margin: 0; }
.compose-line { display: grid; grid-template-columns: 65px 1fr; align-items: center; gap: 12px; padding: 7px 23px; border-bottom: 1px solid var(--line-soft); }
.compose-line label { color: var(--muted); font: 11px var(--mono); }
.compose-line input { border: 0; min-height: 32px; padding: 6px 0; background: none; box-shadow: none; }
.compose-line input:focus { box-shadow: none; }
.compose-line strong { font-weight: 400; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 13px 19px; }
.editor-tabs { display: flex; gap: 0; border: 1px solid var(--line); }
.editor-tab { padding: 9px 12px; background: none; border: 0; border-right: 1px solid var(--line); color: var(--muted); font: 11px var(--mono); }
.editor-tab:last-child { border: 0; }
.editor-tab.active { background: var(--accent); color: #17150d; }
.quick-inserts { display: flex; gap: 8px; }
.quick-inserts select { width: 150px; padding: 6px 8px; min-height: 33px; font-size: 11px; }
.editor-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; padding: 10px 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #1a1a16; }
.editor-toolbar button { background: none; border: 1px solid transparent; color: #cbc8ba; min-height: 29px; min-width: 30px; font-size: 12px; }
.editor-toolbar button:hover { border-color: var(--line); background: #302d21; color: var(--accent); }
.editor-toolbar input[type=color] { width: 29px; height: 27px; border: 0; padding: 2px; }
.tool-sep { height: 20px; border-left: 1px solid var(--line); margin: 0 4px; }
.editor-area { min-height: 350px; padding: 25px 29px; overflow: auto; overflow-wrap: anywhere; background: #fff; color: #191919; line-height: 1.55; outline: none; }
.editor-area:focus { box-shadow: inset 0 0 0 1px var(--accent); }
.editor-area img { max-width: 100%; height: auto; }
.source-area { min-height: 380px; width: 100%; padding: 22px; border: 0; border-radius: 0; background: #11140f; color: #d6dfbd; font: 13px/1.65 var(--mono); tab-size: 2; resize: vertical; }
.compose .mail-preview { min-height: 380px; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }
.composer-footer > div { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.upload-label { cursor: pointer; }
.code-area { min-height: 240px; font: 12px var(--mono); }
.resource-row { display: flex; justify-content: space-between; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.resource-row strong, .resource-row small { display: block; }

/* First-run + instance selector */
.install-wrap { max-width: 780px; padding: 20px; margin: 7vh auto; }
.install-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 25px; }
.install-brand img { width: 62px; height: 62px; object-fit: contain; }
.install-brand h1, .install-brand p { margin: 0; }
.install-wrap .card { padding: 30px; }
.home-instances { display: grid; grid-template-columns: repeat(auto-fit,minmax(250px,1fr)); gap: 1px; border: 1px solid var(--line); background: var(--line); }
.home-instance { display: flex; align-items: center; gap: 13px; background: #141410; padding: 20px; }
.home-instance:hover { background: #252115; }
.home-instance-icon { width: 47px; height: 47px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; background: #0b0b0a; flex-shrink: 0; }
.home-instance-icon img { width: 36px; height: 36px; object-fit: contain; }
.home-instance > div:nth-child(2) { min-width: 0; flex: 1; }
.home-instance strong, .home-instance small { display: block; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.home-instance small { margin-top: 4px; color: var(--muted); font: 10px var(--mono); }
.home-instance > span { color: var(--accent); font: 20px var(--mono); }

.mobile-menu { display: none; }
@media(max-width: 1150px) {
  .shell { grid-template-columns: 218px minmax(0,1fr); }
  .sidebar { padding: 16px 9px; }
  .grid-2 { grid-template-columns: 1fr; }
  .mail-item { grid-template-columns: 170px minmax(0, 1fr) 90px; }
  .content { padding: 27px 23px 45px; }
  .topbar { padding: 0 23px; }
}
@media(max-width: 740px) {
  .shell { display: block; }
  .sidebar { position: relative; height: auto; overflow: visible; padding: 8px 14px; }
  .brand { padding: 7px 3px; margin: 0; border: 0; }
  .sidebar .instance-pill, .sidebar .nav, .sidebar .side-section, .sidebar .field-label, .sidebar .button.full { display: none; }
  .sidebar-bottom { margin: 0; padding: 0; border: 0; position: absolute; top: 17px; right: 14px; }
  .sidebar-bottom .account, .sidebar-bottom .avatar { display: none; }
  .sidebar > select { display: block; max-width: 280px; }
  .mobile-menu { display: block; background: #1b1b16; border: 1px solid var(--line); color: var(--accent); padding: 6px 10px; margin-left: auto; }
  .sidebar.open .instance-pill, .sidebar.open .nav, .sidebar.open .side-section, .sidebar.open .field-label, .sidebar.open .button.full { display: flex; }
  .sidebar.open .side-section, .sidebar.open .field-label { display: block; }
  .sidebar.open { padding-bottom: 20px; }
  .topbar { min-height: 54px; padding: 8px 16px; }
  .breadcrumbs { font-size: 9px; }
  .chip, .top-actions .avatar { display: none; }
  .content { padding: 24px 15px 34px; }
  .page-heading { padding-bottom: 18px; }
  .metrics { gap: 0; }
  .metric { padding: 13px 8px; }
  .metric strong { font-size: 24px; }
  .metric strong::before { font-size: 12px; margin-right: 3px; }
  .grid-2 { gap: 12px; }
  .card { padding: 18px; }
  .mail-item { grid-template-columns: 1fr 85px; gap: 8px; }
  .mail-item .sender { grid-column: 1; }
  .subject-preview { grid-column: 1; grid-row: 2; }
  .mail-meta { grid-column: 2; grid-row: 1 / 3; }
  .compose-line { grid-template-columns: 42px 1fr; padding: 6px 13px; }
  .composer-footer { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: 1; }
  .editor-toolbar { padding: 6px; }
  .resource-row { align-items: flex-start; }
}

/* 1.2.0: quiet, structured admin actions. */
.admin-users-table { width: 100%; }
.admin-users-table .card-header { gap: 16px; padding-bottom: 8px; }
.admin-users-table .card-header h2 { margin-bottom: 0; }
.admin-users-table .card-header p { margin: 3px 0 0; font: 11px var(--mono); }
.admin-users-table .table-scroll { margin-top: 18px; }
.admin-users-table td { vertical-align: middle; }
.admin-discord { font-family: var(--mono); font-size: 11px; word-break: break-all; }
.admin-discord i { color: #a9b0ff; margin-right: 5px; }
.actions-col { min-width: 194px; text-align: right; }
td:last-child .table-actions { justify-content: flex-end; }
.table-actions { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.inline-form { vertical-align: middle; }
.table-actions .inline-form { display: inline-flex; margin: 0; }
.table-icon { appearance: none; border: 1px solid var(--line); border-radius: 2px; background: #181813; color: #ccc9bd; display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0; line-height: 1; transition: color .14s,border-color .14s,background .14s; }
.table-icon i { font-size: 12px; line-height: 1; }
.table-icon:hover:not(:disabled) { color: var(--accent); background: #252218; border-color: var(--accent2); }
.table-icon.is-warning:hover:not(:disabled) { color: #ffcc66; border-color: #b88723; }
.table-icon.is-success:hover:not(:disabled) { color: #9fcba7; border-color: #43794d; }
.table-icon.is-danger:hover:not(:disabled) { color: #ef9999; border-color: #994b4b; background: #301d1d; }
.table-icon:focus-visible, .dialog-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.table-icon:disabled { opacity: .3; cursor: not-allowed; }
/* Native dialog supports Escape, true focus management, and a modal backdrop. */
.nx-dialog { width: min(490px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; margin: auto; border: 1px solid #6d5b31; border-radius: 3px; color: var(--text); background: #151511; box-shadow: 0 25px 80px #000b; padding: 24px; }
.nx-dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(3px); }
.nx-dialog:not([open]) { display: none; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 19px; }
.dialog-heading h2 { margin: 4px 0 0; font-size: 18px; }
.dialog-heading small { color: var(--accent); letter-spacing: .08em; font: 10px var(--mono); }
.dialog-close { appearance: none; border: 1px solid var(--line); background: #191914; color: var(--muted); width: 31px; height: 31px; flex-shrink: 0; }
.dialog-close:hover { color: var(--text); border-color: var(--accent); }
.nx-dialog p { line-height: 1.55; margin-bottom: 8px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 13px; flex-wrap: wrap; }
.button.danger { color: #ffdfdf; background: #502626; border-color: #8c4040; }
.button.danger:hover { background: #6b2d2d; border-color: #c96060; }
.danger-text { color: #ffb8b8; }
.nx-dialog .form-stack { gap: 12px; }
.nx-dialog input, .nx-dialog select { background: #0c0c0a; }
@media (max-width: 900px) { .admin-users-table .table-scroll { overflow-x: auto; } .admin-users-table table { min-width: 665px; } }

/* v1.3.0: Design system for ALL native form primitives.
   Native, accessible HTML semantics remain; controls no longer use browser defaults. */
:root { --field-bg: #10100e; --field-border: #454338; --field-text: #f1ecde; }
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]),
select,textarea {
  appearance: none; -webkit-appearance: none;
  border-radius: 2px; border: 1px solid var(--field-border);
  background-color: var(--field-bg); color: var(--field-text);
  font-family: var(--sans); font-size: 13px; letter-spacing: .005em;
  transition: border-color .16s, box-shadow .16s, background-color .16s;
}
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):hover,
select:hover,textarea:hover { border-color: #7c7154; background-color: #171610; }
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):focus,
select:focus,textarea:focus { border-color: var(--accent); box-shadow: inset 2px 0 var(--accent), 0 0 0 2px color-mix(in srgb, var(--accent) 9%, transparent); background-color: #171610; outline: none; }
input::placeholder,textarea::placeholder { color: #8f8b7c; }
input[readonly] { color: #999181 !important; cursor: not-allowed; }
select { padding-right: 40px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10' viewBox='0 0 14 10'%3E%3Cpath d='m2 3 5 5 5-5' fill='none' stroke='%23c3a85d' stroke-width='1.8' stroke-linecap='square'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 12px; }
select option { color: #f1ecde; background: #181714; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1) brightness(2); }
input[type="checkbox"],input[type="radio"] {
  appearance: none; -webkit-appearance: none; display: inline-grid; place-content: center;
  width: 19px; height: 19px; min-width: 19px; min-height: 19px;
  margin: 0; padding: 0; flex-shrink: 0; background: #12120f;
  border: 1px solid #6c634c; border-radius: 2px; cursor: pointer;
  box-shadow: none; vertical-align: middle; transition: .14s;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::before { content: ''; width: 10px; height: 10px; transform: scale(0); transition: transform .12s; clip-path: polygon(12% 48%,0 62%,42% 100%,100% 16%,85% 3%,40% 72%); background: #16130d; }
input[type="radio"]::before { content: ''; width: 8px; height: 8px; border-radius: 50%; transform: scale(0); transition: transform .12s; background: #17150f; }
input[type="checkbox"]:checked,input[type="radio"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::before,input[type="radio"]:checked::before { transform: scale(1); }
input[type="checkbox"]:focus-visible,input[type="radio"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input[type="checkbox"]:disabled,input[type="radio"]:disabled { opacity: .45; cursor: not-allowed; }
.check { gap: 10px; cursor: pointer; line-height: 1.5; }
.check input { width: 19px; height: 19px; min-height: 19px; }
input[type="file"] { padding: 7px; min-height: 44px; cursor: pointer; }
input[type="file"]::file-selector-button { appearance: none; background: #2c281c; border: 1px solid #756034; color: var(--accent); font: 600 11px var(--mono); padding: 8px 12px; margin-right: 14px; border-radius: 1px; cursor: pointer; }
input[type="color"] { padding: 5px; height: 44px; background: #0c0c0a; border: 1px solid var(--field-border); border-radius: 2px; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 1px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 1px; }
.upload-label input[type="file"][hidden] { display: none; }
button:disabled,.button:disabled { opacity: .44; cursor: not-allowed; }

/* Domain distribution center */
.distro-card .card-header { align-items: center; flex-wrap: wrap; margin-bottom: 23px; }
.distro-card .card-header h2 { margin: 0 0 6px; font-size: 22px; font-weight: 500; }
.distro-card .card-header p { margin: 0; font-size: 12px; }
.distro-card .eyebrow { margin: 0 0 6px; }
.distro-domains { margin-bottom: 16px; }
.distro-domains .pill span { color: inherit; opacity: .65; margin-left: 8px; }
.distro-context { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #191915; padding: 12px 16px; border: 1px solid var(--line); margin-bottom: 20px; }
.distro-context small,.distro-context strong { display: block; }
.distro-context small { font: 9px var(--mono); color: var(--accent); letter-spacing: .09em; margin-bottom: 3px; }
.distro-context strong { font-weight: 500; }
.distro-table td { vertical-align: middle; }
.distro-table td:first-child strong { font-size: 13px; }
.distro-members { font: 11px var(--mono); color: #d3c6a4; white-space: nowrap; }
.distro-members i { color: var(--accent); margin-right: 6px; }
.distro-empty { padding: 56px 20px 62px; border: 1px dashed #514a36; text-align: center; background: #12120f; }
.distro-empty > i { display: block; font-size: 33px; margin-bottom: 15px; color: var(--accent); }
.distro-empty h3 { margin-bottom: 6px; font-size: 17px; }
.distro-empty p { max-width: 460px; margin: 0 auto 20px; }
.nx-dialog.distro-dialog { width: min(770px, calc(100vw - 26px)); padding: 26px 30px; }
.distro-form-heading { display: flex; gap: 13px; align-items: center; margin-top: 9px; }
.distro-form-heading strong,.distro-form-heading small { display: block; }
.distro-form-heading strong { font-size: 14px; }
.distro-form-heading small { color: var(--muted); margin-top: 2px; font-size: 11px; }
.distro-step { width: 34px; height: 34px; background: #242016; border: 1px solid #55482a; color: var(--accent); display: grid; place-items: center; font: 12px var(--mono); }
.distro-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.distro-fields label { min-width: 0; }
.distro-address-input { display: flex; align-items: stretch; margin-top: 7px; }
.distro-address-input input { margin: 0 !important; min-width: 0; border-right: 0 !important; flex: 1; }
.distro-address-input span { display: inline-flex; align-items: center; background: #222016; border: 1px solid var(--field-border); padding: 0 12px; font: 11px var(--mono); white-space: nowrap; color: var(--accent); }
.distro-locked .distro-address-input { opacity: .75; }
.distro-picker { border: 1px solid var(--line); background: #11110e; }
.distro-picker-top { padding: 13px; background: #1c1b15; border-bottom: 1px solid var(--line); }
.distro-search { position: relative; display: flex !important; align-items: center; }
.distro-search i { position: absolute; left: 15px; z-index: 1; color: var(--accent); }
.distro-search input { margin: 0 !important; padding-left: 41px !important; background: #0b0b09 !important; }
.distro-picker-tools { display: flex; gap: 15px; flex-wrap: wrap; margin-top: 11px; }
.distro-text-btn { appearance: none; background: transparent; border: 0; padding: 0; font: 11px var(--mono); color: var(--accent); }
.distro-text-btn:hover { color: #fff; text-decoration: underline; }
.distro-picker-scroll { overflow: auto; max-height: min(330px, 39vh); scrollbar-color: #54482c #10100e; }
.distro-choice { display: flex !important; align-items: center; gap: 12px; padding: 12px 15px; border-bottom: 1px solid #282720; cursor: pointer; transition: background .13s; margin: 0; }
.distro-choice:last-child { border-bottom: 0; }
.distro-choice:hover { background: #252319; }
.distro-choice.is-checked { background: #272317; box-shadow: inset 2px 0 var(--accent); }
.distro-choice input[type="checkbox"] { margin: 0; width: 18px; height: 18px; }
.distro-choice-icon { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #494334; background: #191811; color: #bcaa7a; }
.distro-choice-text { min-width: 0; flex: 1; }
.distro-choice-text strong,.distro-choice-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.distro-choice-text strong { font-size: 12px; font-weight: 600; }
.distro-choice-text small { font: 10px var(--mono); color: var(--muted); margin-top: 3px; }
.distro-choice-check { width: 20px; color: #5f5b50; }
.distro-choice.is-checked .distro-choice-check { color: var(--accent); }
.distro-choice-check i { font-size: 11px; }
.distro-no-results { text-align: center; padding: 22px 10px; margin: 0; }
.distro-picker-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 11px 14px; border-top: 1px solid var(--line); font: 11px var(--mono); color: var(--muted); background: #191813; }
.distro-picker-footer i { color: var(--accent); }
.distro-picker-footer strong { color: var(--accent); }
@media(max-width: 720px){.distro-fields{grid-template-columns:1fr}.nx-dialog.distro-dialog{padding:18px}.distro-card .card-header>.button{width:100%}.distro-table{min-width:650px}}

/* NoirLux Mail 1.4, Composer / Contact Studio, square modern-retro controls */
.nx-composer { padding: 0; overflow: visible; border-color: #514b38; }
.nx-composer .compose-head { background: #171710; border-bottom: 1px solid var(--line); padding: 20px 25px; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.nx-composer .compose-head .eyebrow { margin: 0 0 8px; }
.nx-composer .compose-head h2 { margin: 0; font-weight: 500; font-size: 24px; letter-spacing: -.04em; }
.composer-meta { display: flex; align-items: center; justify-content: flex-end; gap: 17px; flex-wrap: wrap; }
.composer-meta > span { font: 10px var(--mono); }
.composer-state { color: #b9c9a9; }
.composer-state i { font-size: 10px; padding-right: 5px; }
.nx-composer .compose-line { padding: 9px 25px; min-height: 55px; }
.nx-composer .compose-line > label { font: 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: #bcb39a; }
.nx-composer .compose-line strong { font-weight: 500; }
.nx-recipient-entry { display: flex; align-items: center; min-width: 0; flex: 1; gap: 9px; }
.nx-recipient-entry > input { flex: 1; min-width: 0; }
.nx-recipient-entry > button { border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 7px 12px; min-height: 32px; background: #232117; color: var(--accent); font: 10px var(--mono); white-space: nowrap; }
.nx-recipient-entry > button:hover { border-color: var(--accent); background: #302a1c; }
.nx-recipient-entry > button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nx-composer .composer-actions { padding: 11px 23px; background: #131310; gap: 15px; }
.composer-insert-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer-insert-actions .button { min-height: 34px; padding: 8px 12px; }
.nx-composer .editor-tab { padding: 9px 13px; font-size: 10px; }
.nx-composer .editor-tab i { margin-right: 5px; }
.nx-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 0; background: #201e17; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 15px; }
.nx-tools-group { display: inline-flex; align-items: center; gap: 2px; padding: 0 10px; border-right: 1px solid #484333; min-height: 34px; }
.nx-tools-group:last-child { border-right: 0; }
.nx-tools-group > button { min-width: 32px; height: 32px; border: 1px solid transparent; padding: 5px; background: transparent; color: #d4cfc0; font-size: 12px; }
.nx-tools-group > button:hover,.nx-tools-group > button:focus-visible { background: #383224; border-color: #665837; color: var(--accent); outline: none; }
.nx-tools-group > button[data-block] { font: bold 11px var(--mono); }
.nx-tools-group .nx-select { width: auto; }
.nx-tools-group .nx-select-trigger { min-height: 34px; font-size: 11px; padding: 5px 11px; background: #12120f; border: 1px solid #514b39; color: #e5dbbf; min-width: 86px; }
.nx-tools-group #editor-font + .nx-select-trigger { min-width: 125px; }
.nx-tools-group > .nx-select { margin-right: 4px; }
.nx-tools-group select { width: auto; min-width: 110px; height: 34px; min-height: 34px; }
.nx-color-input { position: relative; width: 33px; height: 32px; display: grid; place-items: center; border: 1px solid #514b39; background: #16150f; cursor: pointer; }
.nx-color-input i { color: #e8dabb; z-index: 1; pointer-events: none; }
.nx-color-input input[type=color] { width: 100%; height: 100%; position: absolute; inset: 0; opacity: .12; padding: 0; cursor: pointer; }
.nx-editor-surface { background: white; border-bottom: 1px solid #d2cbbf; }
.nx-composer .editor-area { padding: 30px 34px; min-height: 430px; background: #fff; font: 15px/1.65 Arial,sans-serif; }
.nx-composer .editor-area:empty::before { content: attr(data-placeholder); color: #969696; pointer-events: none; }
.nx-composer .editor-area table td { min-width: 50px; }
.nx-composer .source-area { resize: vertical; min-height: 430px; width: 100%; background: #11140f; color: #d8e0bb; padding: 24px; border: 0; border-radius: 0; font: 13px/1.65 Consolas,monospace; outline: 0; }
.nx-composer .mail-preview { display: block; width: 100%; min-height: 430px; border: 0; background: white; }
.nx-signature-footer { background: #13130f; border-bottom: 1px solid var(--line); padding: 16px 24px 19px; }
.nx-signature-label { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; color: var(--accent); font: 10px var(--mono); letter-spacing: .075em; }
.nx-signature-label span { color: #cdc6b7; letter-spacing: 0; margin-left: 6px; }
.nx-signature-label a { margin-left: auto; padding: 5px 8px; border: 1px solid var(--line); }
.nx-signature-label a:hover { border-color: var(--accent); }
.nx-signature-preview { background: #fff; color: #222; margin-top: 10px; padding: 15px 20px; border-left: 2px solid var(--accent); max-height: 240px; overflow: auto; }
.nx-signature-preview img { max-width: 100%; }
.nx-signature-footer > small { font: 10px var(--mono); display: block; margin-top: 9px; color: #a59f8f; }
.nx-editor-status { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 23px; border-bottom: 1px solid var(--line); font: 10px var(--mono); color: #a8a396; background: #171712; }
.nx-editor-status span:first-child { color: var(--accent); }
.nx-composer .composer-footer { padding: 16px 24px; }
.nx-composer.is-expanded { position: relative; width: calc(100vw - 315px); margin-left: calc((100% - (100vw - 315px))/2); z-index: 5; }
.nx-composer.is-expanded .editor-area,.nx-composer.is-expanded .source-area,.nx-composer.is-expanded .mail-preview { min-height: 68vh; }
.nx-picker-dialog { width: min(720px, calc(100vw - 32px)); max-height: min(760px, 92vh); overflow-y: auto; }
.nx-picker-list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); background: #11110e; margin: 17px 0; max-height: 380px; overflow-y: auto; }
.nx-picker-item { display: flex; align-items: center; text-align: left; gap: 16px; padding: 16px; width: 100%; border: 0; border-bottom: 1px solid #313027; background: transparent; color: var(--text); }
.nx-picker-item:hover,.nx-recipient-choice:hover { background: #282318; }
.nx-picker-item > i:first-child { color: var(--accent); border: 1px solid #514a35; padding: 12px; }
.nx-picker-item > i:last-child { margin-left: auto; color: var(--accent); }
.nx-picker-item span { flex: 1; }
.nx-picker-item strong,.nx-picker-item small { display: block; }
.nx-picker-item small { margin-top: 4px; color: var(--muted); }
.nx-picker-intro { font: 11px var(--mono); color: #beb7a3; padding: 14px 16px; border: 1px solid var(--line); background: #1c1a14; }
.nx-picker-intro strong { color: var(--accent); }
.nx-picker-search { display: flex; align-items: center; position: relative; margin-top: 16px; }
.nx-picker-search > i { position: absolute; left: 14px; color: var(--accent); }
.nx-picker-search input { padding-left: 40px !important; }
.nx-recipient-choice { display: flex !important; align-items: center; padding: 14px; gap: 13px; border-bottom: 1px solid #313027; margin: 0; cursor: pointer; }
.nx-recipient-choice > i { width: 31px; text-align: center; color: var(--accent); }
.nx-recipient-choice > span { flex: 1; min-width: 0; }
.nx-recipient-choice strong,.nx-recipient-choice small { display: block; overflow-wrap: anywhere; }
.nx-recipient-choice small { margin-top: 3px; color: #b7ad98; font: 10px var(--mono); }
.nx-groups-card { margin-bottom: 17px; }
.nx-groups-card .card-header { flex-wrap: wrap; gap: 20px; margin-bottom: 18px; }
.nx-groups-card .card-header h2 { margin-bottom: 7px; font-size: 21px; }
.nx-group-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(250px,1fr)); gap: 1px; background: #39362b; border: 1px solid #39362b; }
.nx-group-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #191814; padding: 16px; }
.nx-group-card > div:first-child { display: grid; grid-template-columns: 28px 1fr; align-items: center; min-width: 0; }
.nx-group-card > div:first-child i { color: var(--accent); grid-row: span 2; }
.nx-group-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.nx-group-card small { grid-column: 2; font: 10px var(--mono); color: var(--muted); }
.nx-group-card .table-actions { gap: 2px; white-space: nowrap; }
.nx-group-checkboxes { border: 1px solid var(--line); padding: 13px; display: flex; flex-wrap: wrap; gap: 8px 17px; }
.nx-group-checkboxes > strong { width: 100%; color: var(--accent); font: 10px var(--mono); margin-bottom: 3px; text-transform: uppercase; }
.nx-group-checkboxes .check { font-size: 11px; }
.nx-dialog #nx-group-choices { max-height: 275px; }
@media (max-width: 1050px) { .nx-composer.is-expanded { width: 100%; margin-left: 0; } }
@media (max-width: 700px) {
 .nx-composer .compose-head,.nx-composer .compose-line,.nx-composer .composer-footer { padding-left: 14px; padding-right: 14px; }
 .nx-recipient-entry { flex-wrap: wrap; }
 .nx-recipient-entry > button { margin-left: auto; }
 .nx-composer .editor-area { padding: 19px; min-height: 310px; }
 .nx-composer .composer-actions { padding: 11px; }
 .nx-tools-group { padding: 0 6px; }
 .nx-signature-footer { padding: 12px; }
}

/* All native dropdowns are progressively replaced by a NoirLux picker. */
.nx-select { position: relative; display: inline-block; width: 100%; min-width: 0; }
.nx-select select.nx-select-native { display: none !important; position: absolute !important; width: 0 !important; height: 0 !important; opacity: 0 !important; pointer-events: none !important; }
.nx-select-trigger { appearance: none; width: 100%; min-height: 41px; padding: 10px 14px; background: #11110e; color: #ece8da; border: 1px solid #55503e; border-radius: 1px; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; font: 12px var(--sans); }
.nx-select-trigger > i { color: var(--accent); font-size: 10px; }
.nx-select-trigger:hover,.nx-select.is-open .nx-select-trigger { border-color: var(--accent); background: #222016; }
.nx-select-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nx-select-value { min-width: 0; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.nx-select-menu { position: absolute; z-index: 75; left: 0; right: 0; top: calc(100% + 4px); min-width: 160px; overflow: auto; max-height: 250px; padding: 4px; background: #191811; border: 1px solid #75613a; box-shadow: 0 10px 24px #0009; }
.nx-select-option { display: block; width: 100%; padding: 11px 10px; border: 0; text-align: left; background: transparent; color: #e7e2d5; font: 11px var(--sans); }
.nx-select-option:hover,.nx-select-option.selected { background: #322b1a; color: var(--accent); }
