:root {
  color-scheme: dark;
  --bg: #0c0e0e;
  --surface: rgba(18, 20, 20, 0.92);
  --surface-soft: rgba(255, 255, 255, 0.035);
  --surface-hover: rgba(255, 255, 255, 0.065);
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.34);
  --text: #f4f4f2;
  --muted: #949594;
  --accent: #00e5fd;
  --accent-light: #82f3ff;
  --accent-soft: rgba(0, 229, 253, 0.13);
  --success: #48bd74;
  --danger: #e34b4b;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "Rajdhani", "Arial Narrow", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: linear-gradient(115deg, #090b0b, #0e1010 52%, #0a0c0c);
}

body::before,
body::after {
  position: fixed;
  z-index: 0;
  bottom: -22vh;
  width: 45vw;
  height: 78vh;
  content: "";
  pointer-events: none;
  opacity: .34;
  background: radial-gradient(circle, rgba(255,255,255,.26) 0 1px, transparent 1.7px) 0 0 / 12px 12px;
  mask-image: radial-gradient(ellipse at center, #000 5%, transparent 68%);
  transform: rotate(14deg);
}
body::before { left: -10vw; }
body::after { right: -12vw; transform: rotate(-15deg); }

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.noise {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  opacity: .012;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

.side-rail {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  width: 76px;
  border-right: 1px solid var(--line);
  background: rgba(9, 11, 11, .5);
}
.side-rail span {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #e6e7e5;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 2px;
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-90deg);
}

.app-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding-left: 76px;
}

.site-header {
  position: relative;
  z-index: 30;
  display: grid;
  min-height: 104px;
  padding: 0 34px 0 48px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.site-nav {
  display: flex;
  grid-column: 2;
  gap: 48px;
  align-items: center;
}

.public-nav { display: flex; gap: 48px; align-items: center; }
.public-nav > button,
.public-nav > a,
.app-nav button {
  position: relative;
  padding: 20px 0 9px;
  border: 0;
  color: #777978;
  font: inherit;
  font-size: 18px;
  cursor: pointer;
  background: transparent;
  text-decoration: none;
  transition: color 220ms var(--ease);
}
.public-nav > button::after,
.public-nav > a::after,
.app-nav button::after {
  position: absolute;
  right: 50%;
  bottom: 0;
  left: 50%;
  height: 1px;
  content: "";
  background: var(--accent);
  transition: inset 220ms var(--ease);
}
.public-nav > button:hover,
.public-nav > button.active,
.public-nav > a:hover,
.public-nav > a.active,
.app-nav button:hover,
.app-nav button.active { color: var(--text); }
.public-nav > button:hover::after,
.public-nav > button.active::after,
.public-nav > a:hover::after,
.public-nav > a.active::after,
.app-nav button:hover::after,
.app-nav button.active::after { right: 0; left: 0; }

.environment-pill,
.role-badge,
.status-dot {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  background: rgba(255, 255, 255, .025);
}
.environment-pill { padding: 8px 13px; font-size: 12px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; }
.app-nav { display: flex; gap: 48px; align-items: center; }
.environment-pill i,
.status-dot::before { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 14px var(--success); content: ""; }
.environment-pill.is-warning i { background: #e9b44c; box-shadow: 0 0 14px rgba(233, 180, 76, .7); }

.account-slot { display: flex; grid-column: 3; justify-self: end; align-items: center; }
.account-login {
  display: inline-flex;
  padding: 8px 4px;
  gap: 9px;
  align-items: center;
  border: 0;
  color: var(--muted);
  font-size: 17px;
  text-decoration: none;
  background: transparent;
  cursor: pointer;
  transition: color 220ms var(--ease);
}
.account-login:hover { color: var(--text); }
.account-icon {
  display: block;
  width: 19px;
  height: 19px;
  color: var(--accent);
  filter: drop-shadow(0 0 7px rgba(0,229,253,.28));
  transition: color 220ms var(--ease), filter 220ms var(--ease), transform 220ms var(--ease);
}
.account-icon svg { width: 100%; height: 100%; fill: currentColor; }
.account-login:hover .account-icon { color: var(--accent-light); filter: drop-shadow(0 0 9px rgba(130,243,255,.5)); transform: scale(1.06); }
.account-button {
  display: inline-flex;
  padding: 6px 4px;
  gap: 9px;
  align-items: center;
  flex-direction: row-reverse;
  border: 0;
  color: var(--text);
  background: transparent;
}
.account-button span { display: grid; text-align: left; line-height: 1.08; }
.account-button strong { max-width: 160px; overflow: hidden; font-size: 17px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.account-button small { display: none; }
.account-button img { width: 26px; height: 26px; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; object-fit: cover; background: #252727; }
.logout-button {
  display: grid;
  width: 30px;
  height: 30px;
  margin-left: 3px;
  padding: 7px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  transition: color 180ms ease;
}
.logout-button:hover { color: var(--accent-light); background: rgba(130,243,255,.12); }

.skeleton { display: block; border-radius: 8px; background: linear-gradient(90deg, #181c1d 25%, #222829 50%, #181c1d 75%) 0 0 / 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-account { width: 180px; height: 45px; }
@keyframes shimmer { to { background-position: -200% 0; } }

main {
  position: relative;
  z-index: 2;
  display: block;
  width: min(1600px, calc(100vw - 116px));
  min-height: calc(100vh - 104px);
  margin: 0 auto;
}
.login-view,
.dashboard-view,
.error-view { width: 100%; animation: view-in 520ms var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.login-view {
  position: relative;
  min-height: calc(100vh - 104px);
  padding: 260px 0 40px;
}
.login-copy { position: relative; z-index: 3; max-width: 800px; }
.eyebrow { margin: 0; color: var(--text); font-size: 37px; font-weight: 700; line-height: .96; text-transform: uppercase; }
.login-copy .eyebrow { display: none; }
.login-copy h1,
.page-heading h1 {
  margin: 0;
  font-size: 38px;
  font-weight: 700;
  line-height: 1.28;
  text-transform: uppercase;
}
.login-copy h1 span { display: block; color: var(--accent); }
.lead { max-width: 800px; margin: 5px 0 0; color: var(--muted); font-size: 18px; line-height: 1.5; }
.login-alert { max-width: 590px; margin: -18px 0 27px; padding: 12px 14px; border: 1px solid rgba(255,102,102,.35); color: #ff9b9b; font-size: 14px; background: rgba(255,102,102,.07); }

.primary-button,
.secondary-button {
  position: relative;
  display: inline-flex;
  min-height: 38px;
  padding: 9px 28px;
  gap: 12px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: #111;
  font-weight: 700;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  background: var(--accent);
  transition: color 220ms var(--ease), transform 220ms var(--ease), box-shadow 220ms var(--ease);
}
.primary-button::before { position: absolute; z-index: -1; inset: 0; content: ""; background: #101212; transform: translateX(-102%); transition: transform 280ms var(--ease); }
.primary-button:hover { color: var(--accent-light); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(130,243,255,.18); }
.primary-button:hover::before { transform: translateX(0); }
.primary-button svg { width: 21px; fill: currentColor; }
.primary-button.is-disabled { border-color: var(--line-strong); color: var(--muted); cursor: not-allowed; background: rgba(255,255,255,.06); box-shadow: none; }
.primary-button.is-disabled:hover { transform: none; box-shadow: none; }
.secondary-button { color: var(--text); border-color: var(--line-strong); background: transparent; }
.config-note { color: #e9b44c; font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }

.login-copy > .primary-button { width: 250px; margin-top: 36px; }

.stats-grid {
  display: grid;
  width: 800px;
  max-width: calc(100vw - 180px);
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 34px;
}
.stat-card { min-height: 120px; padding: 27px 20px; border: 1px solid var(--line); border-radius: 4px; background: rgba(18,20,20,.72); }
.stat-card span { display: block; font-size: 13px; letter-spacing: 1.6px; text-transform: uppercase; }
.stat-card strong { display: block; color: var(--accent); font-size: 24px; line-height: 1.25; }
.stat-card small { font-size: 14px; white-space: nowrap; }

.login-visual {
  position: absolute;
  z-index: 1;
  right: -1vw;
  bottom: 0;
  width: min(58vw, 900px);
  height: calc(100vh - 150px);
  pointer-events: none;
}
.login-visual::after {
  position: absolute;
  right: 2%;
  bottom: 0;
  width: 85%;
  height: 22%;
  content: "";
  background: radial-gradient(ellipse, rgba(0,0,0,.78), transparent 70%);
}
.login-visual img {
  position: absolute;
  z-index: 1;
  right: 5%;
  bottom: 0;
  max-width: 86%;
  max-height: 100%;
  object-fit: contain;
  object-position: right bottom;
  filter: contrast(1.05) drop-shadow(0 22px 20px rgba(0,0,0,.5));
}

.dashboard-view { min-height: calc(100vh - 104px); padding: 44px 0 50px; }
.page-heading { display: flex; min-height: 126px; margin-bottom: 30px; gap: 30px; align-items: end; justify-content: space-between; border-top: 1px solid var(--line-strong); }
.page-heading h1 { font-size: 37px; line-height: .96; }
.page-heading h1 span { color: var(--accent); }
.page-heading > div > p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 18px; }
.role-badge { padding: 9px 15px; color: var(--accent); border-color: rgba(0,229,253,.18); font-size: 12px; font-weight: 700; letter-spacing: 1px; white-space: nowrap; background: var(--accent-soft); }
.management-heading { align-items: center; }
.compact-button { min-height: 44px; padding: 0 18px; font-size: 14px; white-space: nowrap; }

.metrics-grid { display: grid; margin-top: 0; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.metric-card { min-height: 120px; padding: 27px 20px; border: 1px solid var(--line); border-radius: 4px; background: rgba(18,20,20,.72); }
.metric-card > span { font-size: 13px; letter-spacing: 1.6px; text-transform: uppercase; }
.metric-card strong { display: block; max-width: 100%; overflow: hidden; color: var(--accent); font-size: 24px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.metric-card small { font-size: 14px; white-space: nowrap; }

.workspace-grid { display: grid; margin-top: 16px; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .7fr); gap: 16px; }
.panel { min-height: 345px; padding: 28px; border: 1px solid var(--line); background: rgba(14,17,18,.8); }
.panel-heading { display: flex; gap: 20px; align-items: start; justify-content: space-between; }
.panel-heading small { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 1.8px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 25px; font-weight: 600; }
.status-dot { padding: 7px 11px; font-size: 11px; }
.module-list { display: grid; margin-top: 25px; gap: 9px; }
.module-row { display: grid; min-height: 68px; padding: 0 18px; grid-template-columns: 42px 1fr auto; gap: 14px; align-items: center; border: 1px solid rgba(255,255,255,.075); color: var(--text); background: rgba(255,255,255,.02); transition: border-color 180ms ease, background 180ms ease; }
.module-row:not(.is-locked):hover { border-color: rgba(0,229,253,.24); background: var(--surface-hover); }
.module-row.is-locked { opacity: .48; }
.module-icon { display: grid; width: 35px; height: 35px; place-items: center; border: 1px solid rgba(0,229,253,.17); color: var(--accent); background: rgba(0,229,253,.05); }
.module-copy { display: grid; }
.module-copy strong { font-size: 16px; font-weight: 600; }
.module-copy small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.module-state { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 1px; }
.module-row:not(.is-locked) .module-state { color: var(--accent); }
.empty-state { display: grid; min-height: 240px; place-content: center; justify-items: center; text-align: center; }
.empty-icon { display: grid; width: 50px; height: 50px; margin-bottom: 13px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 24px; }
.empty-state strong { font-size: 16px; }
.empty-state p { max-width: 260px; margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

.faction-overview-section { margin-top: 42px; }
.section-heading { display: flex; margin-bottom: 19px; gap: 20px; align-items: end; justify-content: space-between; }
.section-heading small { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 1.8px; }
.section-heading h2 { margin: 5px 0 0; font-size: 27px; font-weight: 600; }
.text-button { padding: 10px 0; border: 0; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; background: transparent; }
.text-button span { margin-left: 8px; color: var(--accent); }
.text-button:hover { color: var(--text); }
.faction-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.faction-card { position: relative; min-height: 245px; padding: 25px; overflow: hidden; border: 1px solid var(--line); background: linear-gradient(145deg, rgba(23,27,28,.88), rgba(13,16,17,.94)); transition: transform 220ms var(--ease), border-color 220ms ease; }
.faction-card:hover { border-color: color-mix(in srgb, var(--faction-color) 42%, transparent); transform: translateY(-3px); }
.faction-card::before { position: absolute; top: 0; right: 0; left: 0; height: 2px; content: ""; background: var(--faction-color); box-shadow: 0 0 22px var(--faction-color); }
.faction-card::after { position: absolute; width: 170px; height: 170px; right: -70px; bottom: -90px; border-radius: 50%; content: ""; opacity: .14; background: var(--faction-color); filter: blur(45px); }
.faction-card-top { position: relative; z-index: 1; display: flex; gap: 16px; align-items: center; }
.faction-logo { position: relative; display: grid; width: 54px; height: 54px; flex: 0 0 auto; overflow: hidden; place-items: center; border: 1px solid color-mix(in srgb, var(--faction-color) 45%, transparent); color: var(--faction-color); font-size: 20px; font-weight: 700; letter-spacing: 1px; background: color-mix(in srgb, var(--faction-color) 8%, transparent); }
.faction-logo img, .mini-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0d1011; }
.logo-initials { display: grid; width: 100%; height: 100%; place-items: center; }
.faction-title { min-width: 0; }
.faction-title h3 { margin: 0; overflow: hidden; font-size: 23px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.faction-title p { margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.faction-type { position: relative; z-index: 1; display: inline-flex; margin-top: 23px; padding: 6px 9px; border: 1px solid var(--line); color: #a5adad; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }
.faction-stats { position: relative; z-index: 1; display: grid; margin-top: 24px; grid-template-columns: 1fr 1fr; gap: 12px; }
.faction-stat { display: grid; }
.faction-stat span { color: #687171; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }
.faction-stat strong { margin-top: 4px; font-size: 18px; font-weight: 600; }
.capacity-bar { position: absolute; z-index: 1; right: 25px; bottom: 18px; left: 25px; height: 2px; background: rgba(255,255,255,.08); }
.capacity-bar i { display: block; width: var(--capacity); max-width: 100%; height: 100%; background: var(--faction-color); }
.empty-factions { display: grid; min-height: 280px; padding: 35px; place-content: center; justify-items: center; border: 1px dashed var(--line); color: var(--muted); text-align: center; background: rgba(255,255,255,.015); }
.empty-factions > span { color: var(--accent); font-size: 34px; }
.empty-factions h3 { margin: 12px 0 4px; color: var(--text); font-size: 19px; }
.empty-factions p { margin: 0; }

.management-panel { min-height: 390px; margin-top: 38px; }
.list-count { color: var(--muted); font-size: 12px; }
.management-list { display: grid; margin-top: 24px; gap: 8px; }
.management-row { display: grid; min-height: 78px; padding: 11px 15px; grid-template-columns: 48px minmax(170px, 1.4fr) minmax(100px, .7fr) minmax(90px, .55fr) auto; gap: 16px; align-items: center; border: 1px solid rgba(255,255,255,.075); background: rgba(255,255,255,.018); }
.management-row:hover { border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.032); }
.mini-logo { position: relative; display: grid; width: 42px; height: 42px; overflow: hidden; place-items: center; border: 1px solid color-mix(in srgb, var(--faction-color) 45%, transparent); color: var(--faction-color); font-weight: 700; background: color-mix(in srgb, var(--faction-color) 7%, transparent); }
.row-main { display: grid; min-width: 0; }
.row-main strong, .row-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main strong { font-size: 17px; }
.row-main small, .row-detail small { color: var(--muted); }
.row-detail { display: grid; }
.row-detail strong { font-weight: 600; }
.row-actions { display: flex; gap: 5px; }
.row-action { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); color: var(--muted); cursor: pointer; background: transparent; }
.row-action:hover { color: var(--text); border-color: var(--line-strong); }
.row-action.delete:hover { color: var(--danger); border-color: rgba(255,102,102,.35); }
.compact-empty { min-height: 250px; margin-top: 24px; }

.modal { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 28px; border: 0; color: var(--text); background: transparent; }
.modal::backdrop { background: rgba(3,5,6,.83); backdrop-filter: blur(8px); }
.modal[open] { display: grid; place-items: center; animation: backdrop-in 180ms ease both; }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card { width: min(940px, 100%); max-height: calc(100vh - 56px); overflow: hidden; border: 1px solid var(--line-strong); color: var(--text); background: #111516; box-shadow: 0 35px 100px rgba(0,0,0,.65); animation: modal-in 260ms var(--ease) both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; min-height: 92px; padding: 20px 26px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header p { margin: 0 0 4px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 1.8px; }
.modal-header h2 { margin: 0; font-size: 27px; font-weight: 600; }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--line); color: var(--muted); font-size: 25px; cursor: pointer; background: transparent; }
.icon-button:hover { color: var(--text); }
.modal-body { max-height: calc(100vh - 242px); padding: 27px; overflow-y: auto; scrollbar-color: #354044 #111516; }
.form-alert { margin: 18px 26px 0; padding: 12px 14px; border: 1px solid rgba(255,102,102,.32); color: #ff9b9b; font-size: 13px; background: rgba(255,102,102,.075); }
.form-section + .form-section { margin-top: 36px; padding-top: 30px; border-top: 1px solid var(--line); }
.form-section-heading { display: flex; margin-bottom: 22px; gap: 13px; align-items: center; }
.form-section-heading > span { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid rgba(0,229,253,.2); color: var(--accent); font-size: 11px; background: var(--accent-soft); }
.form-section-heading h3 { margin: 0; font-size: 19px; }
.form-section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.field { display: grid; gap: 7px; }
.field > span, .type-field legend { color: #a8b0b0; font-size: 12px; font-weight: 600; letter-spacing: .5px; }
.field em { margin-left: 5px; color: var(--muted); font-size: 10px; font-style: normal; font-weight: 500; text-transform: uppercase; }
.field b, .type-field b { color: var(--accent); }
.field input:not([type="color"]) { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 0; color: var(--text); outline: 0; background: rgba(255,255,255,.025); transition: border-color 180ms ease; }
.field input:not([type="color"]):focus { border-color: rgba(0,229,253,.55); }
.field input.is-invalid { border-color: rgba(255,102,102,.6); }
.field > small, .type-field > small, .rank-error { min-height: 14px; color: var(--danger); font-size: 11px; }
.image-input-group { display: grid; grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) 70px; gap: 12px; align-items: end; }
.faction-image-preview { position: relative; display: grid; width: 70px; height: 70px; margin-bottom: 14px; overflow: hidden; place-items: center; border: 1px solid rgba(0,229,253,.28); color: var(--accent); font-size: 18px; font-weight: 700; letter-spacing: 1px; background: var(--accent-soft); }
.faction-image-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0d1011; }
.selector-row { display: grid; margin-top: 19px; grid-template-columns: 1.5fr .5fr; gap: 18px; align-items: start; }
.type-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.type-field legend { margin-bottom: 7px; }
.type-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.type-selector label { cursor: pointer; }
.type-selector input { position: absolute; opacity: 0; pointer-events: none; }
.type-selector label > span { display: flex; min-height: 66px; padding: 12px; gap: 11px; align-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.02); }
.type-selector i { display: grid; width: 33px; height: 33px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); color: var(--muted); font-style: normal; }
.type-selector strong, .type-selector small { display: block; }
.type-selector strong { font-size: 13px; }
.type-selector small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.type-selector input:checked + span { border-color: rgba(0,229,253,.45); background: rgba(0,229,253,.055); }
.type-selector input:checked + span i { border-color: rgba(0,229,253,.35); color: var(--accent); }
.color-control { display: flex; min-height: 66px; padding: 9px; gap: 12px; align-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.02); }
.color-control input { width: 46px; height: 46px; padding: 0; overflow: hidden; border: 0; cursor: pointer; background: transparent; }
.color-control output { font-size: 14px; font-weight: 600; letter-spacing: 1px; }

.rank-block { padding: 17px; border: 1px solid var(--line); background: rgba(255,255,255,.014); }
.rank-block + .rank-block { margin-top: 10px; }
.required-rank { border-left: 2px solid var(--accent); }
.rank-heading { display: flex; gap: 15px; align-items: center; justify-content: space-between; }
.rank-heading > div { display: flex; gap: 11px; align-items: center; }
.rank-number { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(0,229,253,.2); color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.rank-heading strong, .rank-heading small { display: block; }
.rank-heading small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.add-person-button { padding: 8px 11px; border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; background: transparent; }
.add-person-button:hover { color: var(--accent); border-color: rgba(0,229,253,.3); }
.add-person-button:disabled { opacity: .35; cursor: not-allowed; }
.person-list { display: grid; margin-top: 13px; gap: 8px; }
.person-row { display: grid; grid-template-columns: minmax(140px, .8fr) minmax(210px, 1fr) 36px; gap: 8px; }
.person-row input { min-width: 0; height: 40px; padding: 0 11px; border: 1px solid var(--line); color: var(--text); outline: 0; background: rgba(0,0,0,.18); }
.person-row input:focus { border-color: rgba(0,229,253,.45); }
.person-row input.is-invalid { border-color: rgba(255,102,102,.6); }
.remove-person { border: 1px solid var(--line); color: var(--muted); font-size: 18px; cursor: pointer; background: transparent; }
.remove-person:hover { color: var(--danger); border-color: rgba(255,102,102,.35); }
.modal-footer { display: flex; min-height: 74px; padding: 14px 26px; gap: 9px; align-items: center; justify-content: flex-end; border-top: 1px solid var(--line); background: #0e1213; }
.required-note { margin-right: auto; color: var(--muted); font-size: 11px; }
.modal-footer button:disabled { opacity: .5; cursor: wait; }
.confirm-card { display: grid; width: min(430px, 100%); padding: 32px; place-items: center; overflow: visible; text-align: center; }
.danger-icon { display: grid; width: 54px; height: 54px; place-items: center; border: 1px solid rgba(255,102,102,.4); border-radius: 50%; color: var(--danger); font-size: 25px; background: rgba(255,102,102,.07); }
.confirm-card h2 { margin: 18px 0 8px; }
.confirm-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.confirm-card p strong { color: var(--text); }
.confirm-actions { display: flex; width: 100%; margin-top: 25px; gap: 9px; }
.confirm-actions > * { flex: 1; }
.danger-button { min-height: 44px; padding: 0 16px; border: 1px solid var(--danger); color: #fff; font: inherit; font-weight: 700; cursor: pointer; background: #bb3e3e; }
.danger-button:hover { background: #d44949; }
.toast { position: fixed; z-index: 200; right: 24px; bottom: 24px; max-width: 390px; padding: 14px 18px; border: 1px solid rgba(0,229,253,.3); color: var(--text); background: #172022; box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: modal-in 220ms var(--ease); }
.toast.is-error { border-color: rgba(255,102,102,.45); background: #26191a; }

.error-view { display: grid; min-height: 60vh; padding: 50px; place-content: center; justify-items: center; text-align: center; }
.error-code { display: grid; width: 62px; height: 62px; place-items: center; border: 1px solid rgba(255,102,102,.4); border-radius: 50%; color: var(--danger); font-size: 30px; }
.error-view h1 { margin: 22px 0 8px; }
.error-view p { margin: 0 0 24px; color: var(--muted); }

.mobile-menu-button { display: none; }

.app-shell > footer { display: flex; min-height: 62px; padding: 0 clamp(24px, 4vw, 64px); gap: 18px; align-items: center; border-top: 1px solid rgba(255,255,255,.06); color: #626969; font-size: 11px; letter-spacing: 1px; }
.app-shell > footer > span:first-child { color: #8c9494; font-weight: 700; }
.security-label { margin-left: auto; color: #657472; }

@media (max-width: 1250px) {
  .public-nav, .app-nav { gap: 28px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .faction-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .management-row { grid-template-columns: 48px 1fr auto; }
  .management-row .row-detail { display: none; }
}

@media (max-width: 980px) {
  .side-rail { display: none; }
  .app-shell { padding-left: 0; }
  main { width: calc(100vw - 40px); }
  .site-header { min-height: 76px; padding: 0 22px; grid-template-columns: auto 1fr auto; }
  .mobile-menu-button { display: grid; grid-column: 1; width: 40px; height: 40px; place-items: center; border: 1px solid var(--line); color: var(--text); background: #151717; cursor: pointer; }
  .mobile-menu-button:hover { color: var(--accent-light); border-color: var(--accent-light); }
  .site-nav { position: absolute; top: 68px; left: 20px; display: none; width: min(320px, calc(100vw - 40px)); grid-column: auto; flex-direction: column; gap: 0; align-items: stretch; padding: 12px 20px 20px; border: 1px solid var(--line); background: #111313; }
  .site-nav.open { display: flex; }
  .public-nav, .app-nav { flex-direction: column; gap: 0; align-items: stretch; }
  .public-nav > button, .public-nav > a, .app-nav button { padding: 13px 2px; font-size: 16px; text-align: left; }
  .account-slot { grid-column: 3; }
  .environment-pill { display: none; }
  .login-view { padding-top: 18vh; }
  .login-visual { width: 75vw; opacity: .42; }
  .workspace-grid { grid-template-columns: 1fr; }
  .page-heading { align-items: start; flex-direction: column; }
  .selector-row { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .site-header { padding: 0 18px; }
  .site-nav { gap: 18px; }
  .account-login span:last-child { display: none; }
  .account-button span, .logout-button { display: none; }
  .account-button { min-height: 42px; padding: 3px; border: 0; }
  .login-view { padding-top: 14vh; }
  .login-copy h1 { font-size: 33px; }
  .lead { max-width: 90%; font-size: 18px; }
  .stats-grid { width: 100%; max-width: none; grid-template-columns: 1fr; gap: 12px; }
  .stat-card { min-height: 90px; padding: 18px; }
  .login-visual { width: 100vw; opacity: .24; }
  .dashboard-view { padding: 42px 18px 60px; }
  .app-nav { gap: 15px; }
  .app-nav button { font-size: 14px; }
  .faction-grid { grid-template-columns: 1fr; }
  .management-heading .primary-button { width: 100%; }
  .management-row { grid-template-columns: 42px minmax(0,1fr) auto; gap: 10px; }
  .modal { padding: 0; }
  .modal-card { max-height: 100vh; min-height: 100vh; border: 0; }
  .modal-header { min-height: 78px; padding: 16px 18px; }
  .modal-body { max-height: calc(100vh - 218px); padding: 20px 18px; }
  .form-grid, .type-selector { grid-template-columns: 1fr; }
  .image-input-group { grid-template-columns: minmax(0, 1fr) 62px; }
  .faction-image-preview { width: 62px; height: 62px; }
  .person-row { grid-template-columns: 1fr 36px; }
  .person-row input[data-person-id] { grid-column: 1; }
  .person-row .remove-person { grid-column: 2; grid-row: 1 / span 2; }
  .modal-footer { padding: 12px 18px; }
  .required-note { display: none; }
  .confirm-card { min-height: auto; margin: 18px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 120px; }
  .panel { padding: 21px 16px; }
  .module-row { padding: 0 12px; grid-template-columns: 38px 1fr; }
  .module-state { display: none; }
}

@media (max-width: 560px) {
  .management-heading .primary-button { width: 100%; }
  .modal-footer .primary-button, .confirm-actions .primary-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
