@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("/assets/fonts/ibm-plex-sans-cyrillic-400-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("/assets/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("/assets/fonts/ibm-plex-sans-cyrillic-500-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("/assets/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url("/assets/fonts/ibm-plex-sans-cyrillic-600-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url("/assets/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url("/assets/fonts/ibm-plex-sans-cyrillic-700-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url("/assets/fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --sidebar-width: 268px;
  --bg: #121318;
  --bg-subtle: #191a20;
  --surface: #24252b;
  --surface-raised: #2e3037;
  --surface-strong: #393b44;
  --sidebar: #0d0e12;
  --text: #f4f4f5;
  --text-soft: #d4d4d8;
  --muted: #a1a1aa;
  --faint: #85858f;
  --line: rgb(255 255 255 / 0.1);
  --line-strong: rgb(255 255 255 / 0.18);
  --gold: #c7a24a;
  --gold-strong: #e2c469;
  --gold-soft: rgb(199 162 74 / 0.13);
  --gold-line: rgb(199 162 74 / 0.32);
  --gold-ink: #111217;
  --success: #34c978;
  --success-soft: rgb(52 201 120 / 0.12);
  --danger: #f06a6a;
  --danger-soft: rgb(240 106 106 / 0.12);
  --warning: #e2b85e;
  --warning-soft: rgb(226 184 94 / 0.13);
  --info: #72a7f5;
  --info-soft: rgb(114 167 245 / 0.12);
  --focus: rgb(199 162 74 / 0.32);
  --sidebar-text: #f4f4f5;
  --sidebar-soft: #c4c4ca;
  --sidebar-muted: #8d8d97;
  --sidebar-line: rgb(255 255 255 / 0.1);
  --sidebar-hover: rgb(255 255 255 / 0.055);
  --sidebar-active: rgb(199 162 74 / 0.14);
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --duration: 200ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z-sidebar: 30;
  --z-backdrop: 20;
  --z-toast: 60;
  --z-help: 50;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e9eaec;
  --bg-subtle: #dfe1e4;
  --surface: #f9f9fa;
  --surface-raised: #f0f1f3;
  --surface-strong: #d7d9dd;
  --text: #18191d;
  --text-soft: #383a42;
  --muted: #555861;
  --faint: #6d7079;
  --line: rgb(24 25 29 / 0.13);
  --line-strong: rgb(24 25 29 / 0.23);
  --gold: #b28c2f;
  --gold-strong: #8d6a12;
  --gold-soft: rgb(178 140 47 / 0.15);
  --gold-line: rgb(141 106 18 / 0.34);
  --gold-ink: #fff;
  --success: #187a43;
  --success-soft: rgb(24 122 67 / 0.11);
  --danger: #b93434;
  --danger-soft: rgb(185 52 52 / 0.1);
  --warning: #8c6516;
  --warning-soft: rgb(140 101 22 / 0.1);
  --info: #245db3;
  --info-soft: rgb(36 93 179 / 0.1);
  --focus: rgb(178 140 47 / 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: "IBM Plex Sans", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  transition: color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

code,
pre,
textarea {
  font-family: "IBM Plex Mono", Consolas, monospace;
}

/* Application shell */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.app-sidebar {
  position: fixed;
  z-index: var(--z-sidebar);
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  color: var(--sidebar-text);
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-line);
}

.sidebar-brand {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--sidebar-line);
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand strong {
  max-width: 170px;
  font-size: 14px;
  line-height: 1.25;
}

.sidebar-brand span {
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 11px;
}

.sidebar-nav {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding-top: 16px;
  overflow-y: auto;
}

.sidebar-nav__label {
  margin: 14px 10px 5px;
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 600;
}

.sidebar-nav__label:first-child {
  margin-top: 0;
}

.sidebar-nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-soft);
  text-decoration: none;
  transition: color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.sidebar-nav a > i {
  flex: 0 0 auto;
  color: var(--sidebar-muted);
  font-size: 20px;
  transition: color var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.sidebar-nav a:hover {
  color: #fff;
  background: var(--sidebar-hover);
}

.sidebar-nav a:hover > i {
  color: var(--gold-strong);
  transform: translateX(1px);
}

.sidebar-nav a.active {
  color: #fff;
  background: var(--sidebar-active);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 34%, transparent);
}

.sidebar-nav a.active > i {
  color: var(--gold-strong);
}

.sidebar-account {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 13px 8px 0;
  border-top: 1px solid var(--sidebar-line);
}

.account-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--gold-ink);
  background: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

.account-avatar--image {
  object-fit: cover;
}

.account-copy {
  min-width: 0;
}

.account-copy strong,
.account-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong {
  font-size: 12px;
}

.account-copy span {
  color: var(--sidebar-muted);
  font-size: 10px;
}

.account-actions {
  display: flex;
}

.account-actions button,
.account-actions a,
.mobile-header button,
.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  color: inherit;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.account-actions button:hover,
.account-actions a:hover {
  color: var(--gold-strong);
  background: var(--sidebar-hover);
}

.app-content {
  grid-column: 2;
  width: 100%;
  min-width: 0;
  max-width: 1560px;
  margin: 0 auto;
  padding: 34px 38px 56px;
  animation: content-in 220ms var(--ease) both;
}

.mobile-header,
.sidebar-backdrop {
  display: none;
}

/* Page headings and shared controls */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.page-header h1 {
  max-width: 860px;
  margin: 4px 0 7px;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.page-header p:not(.page-context) {
  max-width: 70ch;
  margin-bottom: 0;
  color: var(--muted);
}

.page-context,
.section-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--gold-strong);
  font-size: 12px;
  font-weight: 600;
}

.header-actions,
.row-actions,
.form-actions,
.editor-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--duration) var(--ease), background-color var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button--primary {
  color: var(--gold-ink);
  background: var(--gold);
  border-color: var(--gold);
}

.button--primary:hover {
  background: var(--gold-strong);
  border-color: var(--gold-strong);
}

.button--secondary {
  color: var(--text);
  background: var(--surface-raised);
  border-color: var(--line);
}

.button--secondary:hover,
.button--ghost:hover {
  background: var(--surface-strong);
  border-color: var(--line-strong);
}

.button--ghost {
  color: var(--text-soft);
  background: transparent;
  border-color: var(--line);
}

.button--danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.button--danger:hover {
  color: #fff;
  background: var(--danger);
}

.button--compact {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.button--wide {
  width: 100%;
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel {
  padding: 24px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.section-icon {
  color: var(--gold-strong);
  font-size: 30px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status i {
  font-size: 7px;
}

.status--success {
  color: var(--success);
}

.status--warning {
  color: var(--warning);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-blue {
  color: var(--info);
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 28%, transparent);
}

.badge-gold {
  color: var(--gold-strong);
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 32%, transparent);
}

.badge-gray {
  color: var(--text-soft);
  background: var(--surface-raised);
  border-color: var(--line);
}

.empty-state {
  min-height: 210px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty-state i {
  margin-bottom: 5px;
  color: var(--gold);
  font-size: 38px;
}

.empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.empty-state span {
  max-width: 48ch;
}

/* Dashboard */

.live-time {
  min-width: 64px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.overview-primary,
.quick-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.overview-primary {
  padding: 24px;
}

.overview-primary__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.overview-primary__head h2 {
  margin: 0;
  font-size: 20px;
}

.leadership-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 20px 0;
}

.leadership-icon,
.quick-icon {
  display: grid;
  place-items: center;
  color: var(--gold-strong);
  background: var(--gold-soft);
}

.leadership-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 24px;
}

.leadership-row small,
.leadership-row strong {
  display: block;
}

.leadership-row small {
  color: var(--muted);
}

.leadership-row strong {
  margin-top: 2px;
  font-size: 17px;
}

.leadership-row > a {
  color: var(--gold-strong);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.staff-breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.staff-breakdown > div {
  padding: 0 16px;
  border-right: 1px solid var(--line);
}

.staff-breakdown > div:first-child {
  padding-left: 0;
}

.staff-breakdown > div:last-child {
  padding-right: 0;
  border-right: 0;
}

.staff-breakdown strong,
.staff-breakdown span {
  display: block;
}

.staff-breakdown strong {
  font-size: 24px;
}

.staff-breakdown span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.quick-panel {
  padding: 18px;
}

.quick-panel__header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--gold-strong);
  font-size: 12px;
  font-weight: 600;
}

.quick-panel > a {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.quick-panel > a:last-child {
  border-bottom: 0;
}

.quick-panel > a:hover strong {
  color: var(--gold-strong);
}

.quick-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: 20px;
}

.quick-panel strong,
.quick-panel small {
  display: block;
}

.quick-panel strong {
  transition: color var(--duration) var(--ease);
}

.quick-panel small {
  margin-top: 2px;
  color: var(--muted);
}

.quick-panel > a > i {
  color: var(--faint);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-strip > div {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-right: 1px solid var(--line);
}

.metric-strip > div:last-child {
  border-right: 0;
}

.metric-strip > div > i {
  color: var(--gold);
  font-size: 24px;
}

.metric-strip span,
.metric-strip strong {
  display: block;
}

.metric-strip span {
  color: var(--muted);
  font-size: 11px;
}

.metric-strip strong {
  color: var(--text);
  font-size: 17px;
}

.activity-section {
  margin-top: 18px;
}

/* Forms */

form {
  margin: 0;
}

.form-panel {
  padding: 26px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
}

.form-panel > .section-heading + .form-grid {
  margin-top: 22px;
}

.field,
.template-field,
.person-subfield {
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin: 0 0 6px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  background: var(--bg-subtle);
  transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--bg-subtle) 80%, var(--surface-raised));
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--focus);
}

input[type="checkbox"] {
  width: 17px;
  min-height: 17px;
  accent-color: var(--gold);
}

.checkbox-row,
.checkbox-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.checkbox-group {
  display: grid;
  gap: 9px;
  padding: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 7px;
}

.inline-form select {
  min-width: 100px;
}

.template-form {
  display: grid;
  gap: 15px;
  margin-top: 18px;
}

.template-field > label,
.person-subfield > label {
  margin-bottom: 5px;
}

.field-hint {
  display: block;
  margin: -1px 0 7px;
  color: var(--muted);
  font-size: 11px;
}

.required-mark {
  color: var(--danger);
}

.field-error-message {
  display: block;
  margin-top: 5px;
  color: var(--danger);
  font-size: 11px;
}

.form-error-summary {
  padding: 11px 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent);
  border-radius: var(--radius-sm);
}

.template-field.has-error input,
.template-field.has-error select,
.template-field.has-error textarea,
.person-subfield.has-error input,
.person-subfield.has-error select,
[aria-invalid="true"] {
  border-color: var(--danger);
}

.repeatable-people > [data-people-list],
#staffRows {
  display: grid;
  gap: 10px;
}

.repeatable-person-row,
.staff-row {
  display: grid;
  grid-template-columns: 0.7fr 1.25fr 0.8fr auto;
  align-items: end;
  gap: 10px;
  padding: 13px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  animation: row-in 180ms var(--ease) both;
}

.staff-row {
  grid-template-columns: 0.8fr 1.1fr 0.8fr 1fr auto;
}

.person-remove,
.person-add,
.staff-remove {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: transparent;
  cursor: pointer;
}

.person-remove:hover,
.staff-remove:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}

.person-remove:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.person-add {
  margin-top: 10px;
  color: var(--gold-strong);
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 32%, transparent);
}

/* Tables */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.section-heading + .table-wrap {
  margin-top: 8px;
}

.table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.table th {
  padding: 12px 13px;
  color: var(--muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--line-strong);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 13px;
  color: var(--text-soft);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr {
  transition: background-color var(--duration) var(--ease);
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-raised) 60%, transparent);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table td strong {
  color: var(--text);
}

.table code {
  color: var(--gold-strong);
  font-size: 12px;
}

details summary {
  color: var(--gold-strong);
  cursor: pointer;
}

details pre {
  max-width: 680px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
  color: var(--text-soft);
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}

/* Document generators */

.generator-tabs {
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  margin-bottom: 18px;
  padding: 4px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.generator-tabs button,
.output-tabs button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.generator-tabs button:hover,
.output-tabs button:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.generator-tabs button.active,
.output-tabs button.active {
  color: var(--text);
  background: var(--surface-strong);
}

.document-workbench {
  display: grid;
  grid-template-columns: minmax(430px, 0.9fr) minmax(500px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.generator-compose,
.generator-result {
  min-width: 0;
}

.generator-compose > [data-template-tab] {
  margin-top: 20px;
}

.generator-result {
  position: sticky;
  top: 18px;
}

.output-tabs {
  display: flex;
  gap: 4px;
  margin: 18px 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.generator-result textarea {
  min-height: 560px;
}

.preview-box {
  min-height: 560px;
  max-height: 68vh;
  padding: 20px;
  overflow: auto;
  color: var(--text-soft);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.editor-actions {
  margin-top: 14px;
}

.bbcode-table {
  width: 100%;
  border-collapse: collapse;
}

.bbcode-table td {
  padding: 12px;
  border: 1px solid var(--line);
}

.bbcode-center {
  text-align: center;
}

.bbcode-right {
  text-align: right;
}

.bbcode-georgia {
  font-family: Georgia, serif;
}

.bbcode-muted {
  color: var(--muted);
}

.bbcode-gold {
  color: var(--gold-strong);
}

.preview-box img {
  max-width: 100%;
  height: auto;
}

.preview-box a {
  color: var(--gold-strong);
}

/* Profile and roster */

.profile-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.65fr) minmax(520px, 1.35fr);
  gap: 18px;
  align-items: start;
}

.profile-summary {
  text-align: center;
}

.profile-summary > img,
.profile-summary__avatar {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  object-fit: cover;
  border-radius: 50%;
  color: var(--gold-ink);
  background: var(--gold);
  font-size: 24px;
  font-weight: 700;
}

.profile-summary h2 {
  margin-bottom: 4px;
}

.profile-summary > p {
  color: var(--muted);
}

.profile-summary dl {
  margin: 22px 0 0;
  text-align: left;
}

.profile-summary dl > div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.profile-summary dt {
  color: var(--muted);
}

.profile-summary dd {
  margin: 0;
  color: var(--text-soft);
}

.roster-total {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.roster-total > i {
  color: var(--gold);
  font-size: 25px;
}

.roster-total span,
.roster-total strong {
  display: block;
}

.roster-total span {
  color: var(--muted);
  font-size: 11px;
}

.roster-total strong {
  color: var(--text);
  font-size: 17px;
}

.org-chart {
  max-width: 1240px;
  margin: 0 auto;
}

.org-section {
  --rank: var(--text-soft);
  --rank-soft: var(--surface-raised);
  --rank-line: var(--line-strong);
  position: relative;
  padding-bottom: 38px;
}

.org-section:not(:last-child)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 1px;
  height: 28px;
  background: var(--rank-line);
}

.org-section-title {
  display: grid;
  grid-template-columns: minmax(24px, 1fr) auto minmax(24px, 1fr);
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.org-section-title > span {
  height: 1px;
  background: var(--rank-line);
}

.org-section-title__label {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 54px;
  padding: 9px 15px;
  color: var(--rank);
  background: var(--rank-soft);
  border: 1px solid var(--rank-line);
  border-radius: var(--radius);
}

.org-section-title__label > i {
  flex: 0 0 auto;
  font-size: 25px;
}

.org-section-title h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  letter-spacing: 0.01em;
  text-align: center;
}

.org-section-title small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.org-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.org-card {
  width: min(100%, 278px);
  min-height: 116px;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  align-items: center;
  gap: 15px;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--rank-line);
  border-radius: var(--radius);
  transition:
    transform var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    background-color var(--duration) var(--ease);
}

.org-card:hover {
  transform: translateY(-2px);
  background: var(--rank-soft);
  border-color: var(--rank);
}

.org-avatar-wrap {
  width: 66px;
  height: 66px;
  padding: 3px;
  background: var(--rank-soft);
  border: 1px solid var(--rank-line);
  border-radius: 50%;
}

.org-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.org-info {
  min-width: 0;
}

.org-info h3,
.org-info small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-info h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
}

.org-info small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.developer-badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 4px 7px;
  color: var(--gold-strong);
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.roster-rank-ag {
  --rank: var(--gold-strong);
  --rank-soft: var(--gold-soft);
  --rank-line: var(--gold-line);
}

.roster-rank-ag .org-card {
  width: min(100%, 334px);
  min-height: 138px;
  grid-template-columns: 80px minmax(0, 1fr);
  padding: 21px;
}

.roster-rank-ag .org-avatar-wrap {
  width: 80px;
  height: 80px;
}

.roster-rank-ag .org-info h3 {
  font-size: 17px;
}

.roster-rank-deputy {
  --rank: var(--gold);
  --rank-soft: color-mix(in srgb, var(--gold-soft) 64%, var(--surface));
  --rank-line: color-mix(in srgb, var(--gold-line) 75%, var(--line));
}

.roster-rank-advisor {
  --rank: var(--info);
  --rank-soft: color-mix(in srgb, var(--info) 8%, var(--surface));
  --rank-line: color-mix(in srgb, var(--info) 30%, var(--line));
}

.roster-rank-senior {
  --rank: var(--success);
  --rank-soft: color-mix(in srgb, var(--success) 7%, var(--surface));
  --rank-line: color-mix(in srgb, var(--success) 28%, var(--line));
}

.roster-rank-prosecutor {
  --rank: var(--text-soft);
  --rank-soft: var(--surface-raised);
  --rank-line: var(--line-strong);
}

.roster-rank-assistant {
  --rank: var(--muted);
  --rank-soft: color-mix(in srgb, var(--surface-raised) 70%, var(--surface));
  --rank-line: var(--line);
}

/* Template editor and help */

.template-editor {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(430px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.template-preview-panel {
  position: sticky;
  top: 18px;
}

.template-help-panel {
  position: fixed;
  z-index: var(--z-help);
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(560px, calc(100vw - 36px));
  padding: 22px;
  overflow: auto;
  visibility: hidden;
  opacity: 0;
  transform: translateX(20px);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 8px rgb(0 0 0 / 0.18);
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease), visibility var(--duration);
}

.template-help-panel.open {
  visibility: visible;
  opacity: 1;
  transform: translateX(0);
}

.template-help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.template-help-header h2 {
  margin: 0;
}

.icon-button {
  flex: 0 0 auto;
  color: var(--text-soft);
  background: var(--surface-raised);
  border: 1px solid var(--line);
}

.checkbox-row {
  padding: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* Authentication and errors */

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(440px, 0.75fr);
  background: var(--bg);
}

.auth-context {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 8vw;
  overflow: hidden;
  color: var(--sidebar-text);
  background: var(--sidebar);
}

.auth-context::after {
  content: "";
  position: absolute;
  right: -14vw;
  bottom: -18vw;
  width: min(42vw, 560px);
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--gold) 28%, transparent);
  border-radius: 50%;
}

.auth-context__seal {
  position: absolute;
  top: 8%;
  right: 7%;
  width: min(28vw, 360px);
  opacity: 0.055;
}

.auth-context__content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 690px;
}

.auth-context h1 {
  margin: 10px 0 18px;
  font-size: 52px;
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.auth-context p {
  max-width: 60ch;
  color: var(--sidebar-soft);
  font-size: 16px;
}

.security-note {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 470px;
  margin-top: 52px;
  padding-top: 20px;
  border-top: 1px solid var(--sidebar-line);
}

.security-note > i {
  color: var(--gold-strong);
  font-size: 28px;
}

.security-note strong,
.security-note span {
  display: block;
}

.security-note strong {
  font-size: 13px;
}

.security-note span {
  color: var(--sidebar-muted);
  font-size: 11px;
}

.auth-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 34px 48px;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-brand img {
  width: 40px;
  height: 40px;
}

.auth-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  color: #17130a;
  background: var(--gold);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-brand strong,
.auth-brand span {
  display: block;
}

.auth-brand strong {
  font-size: 13px;
}

.auth-brand span {
  color: var(--muted);
  font-size: 10px;
}

.auth-panel__content {
  width: 100%;
  max-width: 430px;
  margin: auto;
}

.auth-panel__content--form {
  max-width: 540px;
}

.auth-panel__content h2 {
  margin: 7px 0 10px;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.auth-panel__content > p {
  margin-bottom: 28px;
  color: var(--muted);
}

.auth-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 11px;
}

.auth-status i {
  color: var(--success);
  font-size: 8px;
}

.auth-discord-button {
  width: 100%;
  min-height: 48px;
  justify-content: center;
}

.auth-panel footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 10px;
}

.auth-link {
  margin: 15px 0 0 !important;
  text-align: center;
}

.auth-link a {
  color: var(--gold-strong);
}

.auth-shell--register .auth-panel {
  overflow-y: auto;
}

.error-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--bg);
}

.error-panel {
  width: min(560px, 100%);
  padding: 30px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.error-panel .auth-brand {
  justify-content: center;
  margin-bottom: 36px;
  text-align: left;
}

.error-code {
  display: block;
  color: var(--gold-strong);
  font-size: 13px;
  font-weight: 700;
}

.error-icon {
  margin: 12px 0;
  color: var(--gold);
  font-size: 58px;
}

.error-panel h1 {
  margin-bottom: 8px;
  font-size: 30px;
}

.error-panel p {
  max-width: 48ch;
  margin: 0 auto 24px;
  color: var(--muted);
}

/* Toasts and motion */

.toast-container {
  position: fixed;
  z-index: var(--z-toast);
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 9px;
  pointer-events: none;
}

.toast {
  width: min(340px, calc(100vw - 36px));
  display: grid;
  gap: 2px;
  padding: 13px 15px;
  opacity: 0;
  transform: translateY(8px);
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 4px 8px rgb(0 0 0 / 0.18);
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast span {
  color: var(--muted);
  font-size: 12px;
}

@keyframes content-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes row-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */

@media (max-width: 1180px) {
  .overview-layout,
  .document-workbench,
  .template-editor {
    grid-template-columns: 1fr;
  }

  .generator-result,
  .template-preview-panel {
    position: static;
  }

  .profile-layout {
    grid-template-columns: minmax(240px, 0.5fr) minmax(430px, 1fr);
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    width: min(310px, 86vw);
    transform: translateX(-101%);
    transition: transform 240ms var(--ease);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .mobile-header {
    position: sticky;
    z-index: 15;
    top: 0;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    color: var(--text);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
  }

  .mobile-brand img {
    width: 30px;
    height: 30px;
  }

  .mobile-brand strong {
    font-size: 12px;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: var(--z-backdrop);
    inset: 0;
    display: block;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
    background: rgb(3 3 5 / 0.68);
    transition: opacity 240ms var(--ease);
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .app-content {
    max-width: none;
    padding: 24px 20px 44px;
  }

  .page-header {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .staff-breakdown,
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .staff-breakdown > div:nth-child(2),
  .metric-strip > div:nth-child(2) {
    border-right: 0;
  }

  .staff-breakdown > div:nth-child(-n + 2),
  .metric-strip > div:nth-child(-n + 2) {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }

  .staff-breakdown > div:nth-child(n + 3),
  .metric-strip > div:nth-child(n + 3) {
    padding-top: 14px;
  }

  .profile-layout {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    display: block;
  }

  .auth-context {
    min-height: 390px;
    padding: 46px 28px;
  }

  .auth-context h1 {
    font-size: 40px;
  }

  .auth-panel {
    min-height: 560px;
    padding: 30px 28px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .app-content {
    padding-inline: 14px;
  }

  .page-header h1 {
    font-size: 27px;
  }

  .panel,
  .overview-primary,
  .quick-panel,
  .generator-compose,
  .generator-result {
    padding: 17px;
  }

  .header-actions .button {
    flex: 1 1 auto;
  }

  .leadership-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .leadership-row > a {
    grid-column: 1 / -1;
  }

  .staff-breakdown,
  .metric-strip,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .staff-breakdown > div,
  .staff-breakdown > div:first-child,
  .staff-breakdown > div:last-child,
  .metric-strip > div {
    padding: 11px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .staff-breakdown > div:last-child,
  .metric-strip > div:last-child {
    border-bottom: 0;
  }

  .repeatable-person-row,
  .staff-row {
    grid-template-columns: 1fr;
  }

  .editor-actions,
  .row-actions,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-actions .button,
  .row-actions .button,
  .inline-form .button {
    width: 100%;
  }

  .generator-result textarea,
  .preview-box {
    min-height: 420px;
  }

  .org-section {
    padding-bottom: 32px;
  }

  .org-section-title {
    gap: 9px;
  }

  .org-section-title__label {
    padding-inline: 11px;
  }

  .org-section-title h2 {
    max-width: 220px;
    font-size: 13px;
  }

  .org-card,
  .roster-rank-ag .org-card {
    width: min(100%, 360px);
  }

  .auth-panel footer {
    display: grid;
  }

  .auth-context {
    min-height: 340px;
  }

  .auth-context h1 {
    font-size: 34px;
  }

  .auth-panel {
    padding-inline: 20px;
  }

  .auth-shell--register .auth-context {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
