/* Control: carbon surfaces, architectural spacing, teal accents. */
:root {
  color-scheme: dark;
  --bg: #050808;
  --surface: #0b1010;
  --surface-raised: #101717;
  --line: #273434;
  --muted: #9baead;
  --text: #f0f6f5;
  --accent: #008A95;
  --accent-text: #6ed6dc;
  --accent-dim: #0b282c;
  --error: #ffb4a9;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; display: flex; min-height: 100vh; }
button, input, select { font: inherit; }
button, a, select, label:has(input[type=checkbox]) { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 4px; }
::selection { color: #fff; background: var(--accent); }
.sidebar {
  width: 252px; flex: none; height: 100vh; height: 100dvh; position: sticky; top: 0; z-index: 20;
  display: flex; flex-direction: column; background: #080c0c; border-right: 1px solid var(--line);
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 30px 24px 26px; }
.brand { display: flex; gap: 12px; align-items: center; font-size: 19px; font-weight: 750; letter-spacing: .11em; }
.brand small { display: block; font-size: 9px; color: var(--muted); letter-spacing: .18em; font-weight: 500; margin-top: 5px; }
.brand-mark { display: flex; gap: 4px; align-items: center; height: 34px; transform: skewY(-20deg); }
.brand-mark i { width: 6px; height: 19px; background: var(--accent); }
.brand-mark i:nth-child(2) { height: 30px; }
.brand-mark i:nth-child(3) { height: 24px; background: var(--accent-text); }
.server-tile { margin: 6px 16px 20px; border: 1px solid #355254; border-radius: 14px; padding: 16px 14px; display: flex; align-items: center; gap: 11px; background: #0f1b1c; }
.server-tile img { width: 40px; height: 40px; border-radius: 11px; object-fit: cover; }
.server-tile label { flex: 1; min-width: 0; font-size: 11px; color: var(--accent-text); }
.server-tile select { width: 100%; color: var(--text); background: transparent; border: 0; font-size: 13px; font-weight: 650; padding: 5px 0; }
.server-tile option { background: var(--surface); }
.server-tile small { display: block; font-size: 10px; color: var(--muted); }
.sidebar-search { margin: 0 16px 22px; font-size: 0; }
.sidebar-search input { width: 100%; background: #0d1313; border: 1px solid #3b4b4b; border-radius: 11px; padding: 12px 14px; min-height: 44px; color: var(--text); font-size: 12px; }
.sidebar nav { overflow-y: auto; padding: 0 12px; scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
.nav-group { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; margin: 12px 12px; }
.nav-group:not(:first-child) { margin-top: 28px; }
.nav { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; margin: 5px 0; border: 1px solid transparent; border-radius: 11px; padding: 12px 14px; text-align: left; font-size: 13px; color: #b9c9c7; background: transparent; transition: background 140ms, color 140ms; }
.nav-number { color: #819895; font: 11px Consolas, monospace; }
.nav:hover { background: var(--surface-raised); color: #fff; }
.nav.active { border-color: #2b5d61; background: #0c292d; color: #e3faf9; }
.nav.active::after { content: ''; position: absolute; right: 14px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-text); }
.nav.active .nav-number { color: var(--accent-text); }
.sidebar-footer { margin-top: auto; padding: 26px 24px 22px; }
.sidebar-footer > span { display: block; font-size: 20px; line-height: 1.3; color: #a6b8b5; font-weight: 300; letter-spacing: -.03em; }
.back { display: inline-flex; align-items: center; color: var(--muted); font-size: 12px; min-height: 44px; padding: 12px 0 2px; }
.back:hover { color: var(--accent-text); }
.sidebar-scrim { position: fixed; inset: 0; background: #000b; z-index: 19; }
main { min-width: 0; flex: 1; }
.topbar { position: sticky; top: 0; z-index: 10; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 0 36px; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-left { display: flex; gap: 23px; align-items: center; min-width: 0; }
.scope-badge { display: flex; gap: 9px; align-items: center; font-size: 11px; letter-spacing: .045em; white-space: nowrap; }
.scope-dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.breadcrumb { border-left: 1px solid var(--line); padding-left: 23px; font-size: 11px; color: var(--muted); }
.account-badge { color: var(--muted); font-size: 10px; border: 1px solid var(--line); padding: 8px 12px; border-radius: 5px; text-align: right; }
.icon-button { min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--text); font-size: 12px; padding: 8px; }
#open-menu, #close-menu { display: none; border-radius: 10px; }
.wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 32px 40px 70px; }
.heading { margin-bottom: 28px; }
h1 { font-size: 27px; line-height: 1.3; font-weight: 550; letter-spacing: -.035em; margin: 0 0 8px; }
.heading p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.card { border: 1px solid #273232; background: #0d1212; border-radius: 16px; padding: 24px; margin-bottom: 18px; }
.card h2 { font-size: 16px; font-weight: 550; letter-spacing: -.02em; line-height: 1.4; margin: 0 0 8px; }
.card p { color: var(--muted); font-size: 12px; line-height: 1.65; margin: 8px 0; }
.field { display: grid; gap: 8px; font-size: 11px; font-weight: 550; color: #b5c7c5; margin-bottom: 18px; }
.field input, .field select { width: 100%; min-width: 0; min-height: 45px; border: 1px solid #48605e; border-radius: 11px; background: #060b0b; color: var(--text); padding: 12px 14px; font-size: 13px; }
input::placeholder { color: #8b9d9b; }
input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
.search { max-width: 420px; margin-bottom: 36px; }
.stack { display: grid; gap: 26px; }
.channel-group { margin: 0; }
.channel-group > h2 { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 550; color: #c3d4d2; margin: 0 0 12px; }
.channel-group > h2::before { content: ''; width: 18px; height: 2px; background: var(--accent); }
.channel-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 44%); gap: 15px 28px; align-items: center; padding: 22px 24px; border-radius: 14px; margin: 0 0 12px; }
.channel-card:last-child { margin-bottom: 0; }
.channel-card h2 { font-size: 14px; margin: 0 0 5px; }
.channel-card p { font-size: 11px; margin: 0; }
.channel-controls { display: flex; align-items: end; gap: 8px; }
.channel-controls .field { flex: 1; min-width: 0; margin: 0; font-size: 10px; }
.channel-controls .field select { font-size: 11px; }
.stale-channel { grid-column: 1/-1; color: var(--error) !important; }
.button { display: inline-flex; justify-content: center; align-items: center; border: 1px solid #3e5351; border-radius: 11px; padding: 11px 17px; min-height: 44px; font-size: 12px; font-weight: 650; white-space: nowrap; color: var(--text); background: var(--surface-raised); transition: background 150ms; }
.button:hover { background: #1b2c2b; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #000; }
.button.primary:hover { background: #24a7b0; border-color: #24a7b0; }
.button.danger { border-color: #bc6c62; color: var(--error); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.role-workspace { display: grid; grid-template-columns: 255px minmax(0, 1fr); gap: 22px; align-items: start; }
.role-picker { padding: 22px 16px 16px; }
.role-picker-heading { display: flex; justify-content: space-between; align-items: center; margin: 0 4px 20px; }
.role-picker-heading h2 { font-size: 13px; margin: 0; }
#role-total { color: var(--muted); font-size: 11px; }
.role-picker .field { margin: 0 4px 14px; }
.role-picker .field:has(#access-role) { display: none; }
.role-directory { display: grid; gap: 3px; max-height: 490px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #355651 transparent; }
.directory-role { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 11px 12px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #b3c0be; font-size: 12px; text-align: left; }
.directory-role span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-role:hover { background: #14201e; color: #fff; }
.directory-role.selected { border-color: #255b5e; background: #0c292c; color: #dbf4f2; }
.role-dot { width: 7px; height: 7px; border-radius: 50%; background: #6f8580; flex: none; }
.selected .role-dot { background: var(--accent-text); }
.access-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.access-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.access-heading h2 { font-size: 21px; margin: 0 0 5px; }
#selected-role-id { color: var(--muted); font: 10px Consolas, monospace; }
#role-config-description { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; }
.count-badge { flex: none; padding: 7px 11px; border-radius: 20px; background: #182222; color: #bbcecb; font-size: 11px; }
.choice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; max-height: 365px; overflow: auto; margin: 18px 0 28px; scrollbar-color: var(--accent) transparent; scrollbar-width: thin; }
.choice-list label { display: flex; align-items: center; gap: 10px; min-height: 48px; border: 1px solid #3d5350; border-radius: 10px; background: #0d1514; padding: 13px; color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.choice-list label:hover { border-color: #567b78; }
.choice-list small { display: block; color: var(--muted); font-size: 10px; }
.choice-list input, .toggle input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.choice-list label:has(input:checked) { border-color: var(--accent); background: #092226; }
.function-list { max-height: none; display: grid; grid-template-columns: 1fr; gap: 6px; margin: 14px 0 20px; }
.function-list label { position: relative; flex-direction: row-reverse; justify-content: space-between; align-items: center; min-height: 70px; border: 0; border-radius: 10px; background: transparent; padding: 15px 12px; gap: 20px; }
.function-list label:hover { background: #152020; }
.function-list label:has(input:checked) { background: #0b2326; }
.function-list span { min-width: 0; font-size: 13px; font-weight: 500; line-height: 1.5; }
.function-list small { display: block; font-size: 12px; font-weight: 400; line-height: 1.5; margin-top: 4px; color: var(--muted); }
.function-list input { appearance: none; -webkit-appearance: none; width: 33px; height: 19px; border: 1px solid #5f7470; background: #26332f; border-radius: 12px; position: relative; cursor: pointer; }
.function-list input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #b4c3be; transition: transform 140ms; }
.function-list input:checked { background: var(--accent); border-color: var(--accent); }
.function-list input:checked::after { background: #000; transform: translateX(14px); }
.function-list input:disabled { opacity: .4; cursor: not-allowed; }
.save-bar { display: flex; justify-content: space-between; align-items: center; gap: 18px; border-top: 1px solid var(--line); padding-top: 20px; }
.save-bar > span { font-size: 11px; color: var(--muted); line-height: 1.6; }
.notice { border: 1px solid #30656b; border-left: 1px solid var(--accent); background: #0a2023; color: #d2eceb; border-radius: 12px; padding: 17px; font-size: 12px; line-height: 1.6; margin: 18px 0; }
#notice { position: fixed; z-index: 30; right: 24px; bottom: 20px; max-width: min(460px, calc(100vw - 40px)); box-shadow: 0 12px 35px #0008; }
.notice.failed { border-color: #bc6c62; background: #231613; color: var(--error); }
.missing-roles { grid-column: 1/-1; color: var(--error) !important; }
.risk-roles { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.risk-roles span { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12px; overflow-wrap: anywhere; }
.risk-roles small { color: var(--muted); font-size: 10px; }
.setting-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.switch { position: relative; min-width: 48px; min-height: 44px; display: grid; align-items: center; }
.switch input { position: absolute; width: 100%; height: 100%; margin: 0; opacity: 0; }
.switch span { pointer-events: none; width: 44px; height: 25px; border: 1px solid #597370; border-radius: 20px; background: #263735; position: relative; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #d8e8e5; transition: transform 160ms; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(19px); background: #000; }
.switch input:focus-visible + span { outline: 2px solid var(--accent-text); outline-offset: 4px; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 18px 0; font-size: 12px; }
.support-status { border-left: 2px solid #75938e; padding: 8px 12px; font-size: 11px !important; }
.security-roles { margin-top: 30px; }
.empty { color: var(--muted); font-size: 13px; }
@media (max-height: 650px) {
  .sidebar-brand { padding: 18px 20px; }
  .server-tile { margin: 0 12px 12px; padding: 12px; }
  .sidebar-search { margin: 0 12px 12px; }
  .nav-group, .nav-group:not(:first-child) { margin: 8px 12px; }
  .nav { min-height: 44px; margin: 3px 0; padding: 10px 12px; }
  .sidebar-footer { padding: 14px 24px 10px; }
  .sidebar-footer > span { font-size: 18px; }
}
@media (max-width: 1180px) {
  .wrap { padding: 36px 28px 72px; }
  .role-workspace { grid-template-columns: 235px minmax(0, 1fr); }
  .function-list { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .sidebar { width: 236px; position: fixed; left: 0; transform: translateX(-101%); transition: transform 180ms ease; box-shadow: 15px 0 40px #0007; }
  .sidebar.open { transform: translateX(0); }
  #open-menu, #close-menu { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 24px; }
  .wrap { max-width: 980px; }
  .role-workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .function-list { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .wrap { padding: 30px 20px 65px; }
  .role-workspace { grid-template-columns: 1fr; gap: 10px; }
  .role-picker { position: static; }
  .role-directory { max-height: 190px; }
  .channel-card { grid-template-columns: 1fr; }
  .account-badge { display: none; }
  .breadcrumb { display: none; }
}
@media (max-width: 450px) {
  .topbar { height: 64px; padding: 0 18px; }
  .top-left { gap: 16px; }
  .wrap { padding: 28px 16px 60px; }
  .heading { gap: 10px; }
  .heading p { font-size: 12px; }
  .eyebrow { font-size: 9px; }
  .card { padding: 19px; }
  .function-list { grid-template-columns: 1fr; }
  .function-list label { min-height: 70px; }
  .save-bar { align-items: stretch; flex-direction: column; gap: 12px; }
  .access-heading { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

.sidebar nav { overflow-y: auto; min-height: 0; }
.settings-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.settings-form > p { max-width: 72ch; line-height: 1.7; margin-bottom: 28px; }
.settings-fields { display: grid; gap: 24px; margin-bottom: 30px; }
.setting-field .field { margin: 0; }
.setting-field .field > span { margin-bottom: 8px; }
.setting-field textarea { background: var(--surface, #0b1010); color: var(--text, #e1ecec); border: 1px solid #263636; border-radius: 11px; padding: 13px; font: inherit; width: 100%; resize: vertical; line-height: 1.6; }
.settings-switch { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.settings-switch input { width: 20px; height: 20px; accent-color: #008A95; }
.settings-check-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px; max-height: 320px; overflow-y: auto; margin-top: 12px; }
.settings-check-list label { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 10px; font-size: 13px; }
.settings-check-list label:has(input:checked) { background: #008a951c; }
.settings-check-list input { accent-color: #008A95; width: 17px; height: 17px; }
.settings-rows { display: grid; gap: 24px; margin: 12px 0 18px; }
.settings-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; padding-bottom: 24px; border-bottom: 1px solid #263636; }
.settings-row > [hidden] { display: none; }
.settings-row .settings-remove { align-self: end; justify-self: start; color: #d6a4a4; }
.settings-image-preview { display: block; max-width: 100%; max-height: 220px; object-fit: contain; margin: 18px 0; background: #050808; border-radius: 12px; }
.settings-image-preview[hidden] { display: none; }
.settings-selected, .settings-member-results { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.settings-selected-member { font-size: 12px; }
@media (max-width: 760px) { .settings-toolbar { grid-template-columns: 1fr; gap: 14px; } .settings-row { grid-template-columns: 1fr; } }
