:root {
  --bg: #edf2f5;
  --surface: #ffffff;
  --surface-soft: #f6f9fb;
  --line: #d8e1e8;
  --line-strong: #c7d2db;
  --text: #16202a;
  --muted: #667685;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dff4f0;
  --shadow: 0 18px 48px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(237, 242, 245, 0.98)),
    repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.03) 0 1px, transparent 1px 96px);
  font-family: "Segoe UI", Arial, sans-serif;
}

body.is-locked {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(237, 242, 245, 0.94);
  backdrop-filter: blur(10px);
}

body:not(.is-locked) .auth-gate {
  display: none;
}

.auth-card {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.auth-logo,
.brand-logo {
  width: 64px;
  height: auto;
  display: block;
}

.auth-kicker,
.brand-kicker,
.section-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-brand h1,
.brand-copy h1,
.band-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #405162;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field-control {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  background: #ffffff;
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.field-control:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.75);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.field-textarea {
  min-height: 110px;
  resize: vertical;
}

.auth-input {
  margin-bottom: 16px;
}

.auth-error {
  min-height: 20px;
  margin: 14px 0 0;
  color: #b42318;
  font-size: 13px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(216, 225, 232, 0.92);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.topbar-inner,
.page-shell {
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-copy h1 {
  font-size: 24px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.button:hover {
  border-color: var(--line-strong);
  background: #fbfcfd;
  transform: translateY(-1px);
}

.button.primary {
  border-color: transparent;
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.primary svg {
  stroke: currentColor;
}

.button.ghost {
  background: transparent;
}

.button.wide {
  width: 100%;
}

.button path[fill] {
  fill: currentColor;
}

.page-shell {
  padding: 24px 0 36px;
  display: grid;
  gap: 24px;
}

.hub-band,
.viewer-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.hub-band {
  padding: 22px;
}

.viewer-band {
  padding: 18px;
}

.band-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.band-head.compact {
  margin-bottom: 14px;
}

.band-head h2 {
  font-size: 22px;
}

.band-status {
  min-height: 24px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.doc-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.doc-tab {
  min-height: 98px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  display: grid;
  gap: 8px;
  align-content: start;
}

.doc-tab.is-active {
  border-color: rgba(15, 118, 110, 0.4);
  background: var(--accent-soft);
}

.doc-tab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.doc-tab-title {
  font-size: 16px;
  font-weight: 700;
}

.doc-tab-meta,
.doc-tab-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.doc-pill,
.viewer-chip,
.group-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.doc-pill.is-ready {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-strong);
}

.shared-band {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.shared-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.field-group {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  display: grid;
  gap: 14px;
  align-content: start;
}

.field-group[hidden],
.field[hidden] {
  display: none !important;
}

.field-group-wide {
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.group-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.viewer-head {
  margin-bottom: 14px;
}

.viewer-info {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.viewer-stage {
  position: relative;
  min-height: 920px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
  overflow: hidden;
}

.frame-stack {
  height: 100%;
}

.viewer-frame {
  width: 100%;
  height: var(--frame-height, 1240px);
  border: 0;
  display: none;
  background: #ffffff;
}

.viewer-frame.is-active {
  display: block;
}

.viewer-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(247, 250, 252, 0.92), rgba(247, 250, 252, 0.98)),
    repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.03) 0 1px, transparent 1px 96px);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.viewer-stage.is-ready .viewer-loading {
  display: none;
}

@media (max-width: 1220px) {
  .shared-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-group-wide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .topbar-inner,
  .page-shell {
    width: min(100%, calc(100% - 20px));
  }

  .topbar-inner,
  .band-head,
  .group-head {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions,
  .viewer-info {
    justify-content: stretch;
  }

  .top-actions .button {
    width: 100%;
  }

  .doc-switcher,
  .shared-grid {
    grid-template-columns: 1fr;
  }

  .viewer-stage {
    min-height: 760px;
  }

  .viewer-frame {
    height: 980px;
  }
}
