:root {
  --bg: #f4efe7;
  --bg-strong: #efe5d6;
  --panel: rgba(255, 251, 246, 0.92);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: #d7cab7;
  --line-strong: #c5b294;
  --text: #1f2730;
  --muted: #697281;
  --brand: #1d4c4a;
  --brand-strong: #123533;
  --accent: #d46f33;
  --accent-strong: #b4561f;
  --danger: #b53f3f;
  --ok: #22795d;
  --shadow: 0 20px 50px rgba(31, 39, 48, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-body: "Bahnschrift", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-title: "Georgia", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  color: var(--text);
  font: 15px/1.55 var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(212, 111, 51, 0.16), transparent 27%),
    radial-gradient(circle at top right, rgba(29, 76, 74, 0.16), transparent 25%),
    linear-gradient(180deg, var(--bg) 0%, #edf1f4 100%);
}

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

button {
  cursor: pointer;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 100vh;
}

.shell.is-auth-locked {
  grid-template-columns: 1fr;
}

.shell.is-auth-locked .sidebar,
.shell.is-auth-locked .topbar,
.shell.is-auth-locked .view {
  display: none !important;
}

.shell.is-auth-locked .main {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding-top: 48px;
}

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  align-content: start;
  gap: 22px;
  min-height: 100vh;
  padding: 26px 22px;
  background:
    linear-gradient(180deg, rgba(18, 53, 51, 0.96), rgba(31, 39, 48, 0.96)),
    linear-gradient(160deg, rgba(255, 255, 255, 0.04), transparent);
  color: #f4efe8;
}

.brand {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, #efc289, #d46f33);
  color: #18212d;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand__title {
  font-family: var(--font-title);
  font-size: 24px;
  line-height: 1.05;
}

.brand__text {
  color: rgba(244, 239, 232, 0.72);
  font-size: 13px;
}

.sidebar__section {
  display: grid;
  gap: 10px;
}

.sidebar__label {
  color: rgba(244, 239, 232, 0.66);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.session-card,
.status-box {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.1);
}

.session-card__title {
  font-weight: 700;
}

.session-card__text {
  color: rgba(244, 239, 232, 0.76);
  font-size: 13px;
}

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

.nav__button {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-align: left;
  font-weight: 700;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.nav__button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
}

.nav__button.is-active {
  border-color: rgba(239, 194, 137, 0.5);
  background: linear-gradient(135deg, rgba(212, 111, 51, 0.24), rgba(239, 194, 137, 0.16));
}

.status-box {
  min-height: 84px;
  color: rgba(255, 255, 255, 0.88);
}

.main {
  padding: 26px;
  overflow-x: clip;
}

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

.topbar__title {
  margin: 0 0 8px;
  font-family: var(--font-title);
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.02;
}

.topbar__text {
  margin: 0;
  max-width: 760px;
  color: var(--muted);
}

.topbar__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.panel {
  border: 1px solid rgba(213, 201, 185, 0.7);
  border-radius: var(--radius-xl);
  background: rgba(255, 251, 246, 0.98);
  box-shadow: var(--shadow);
}

.auth-panel,
.view {
  display: none;
}

.auth-panel.is-visible,
.view.is-active {
  display: block;
}

.auth-panel {
  padding: 24px;
  margin-bottom: 24px;
}

.panel {
  padding: 22px;
}

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

.panel__title {
  margin: 0;
  font-family: var(--font-title);
  font-size: 29px;
  line-height: 1.04;
}

.panel__text {
  margin: 6px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 20px;
}

.grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--workspace {
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 18px 20px;
  border: 1px solid rgba(197, 178, 148, 0.72);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.panel,
.stat-card,
.document-card,
.list-item,
.timeline-item {
  content-visibility: auto;
  contain-intrinsic-size: 1px 220px;
}

.stat-card__label {
  color: var(--muted);
  font-size: 13px;
}

.stat-card__value {
  margin-top: 6px;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(31, 39, 48, 0.1);
}

.button--accent {
  border-color: rgba(212, 111, 51, 0.4);
  background: linear-gradient(135deg, var(--accent), #e99a5e);
  color: #fff8f2;
}

.button--accent:hover {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
}

.button--ghost {
  background: rgba(255, 255, 255, 0.62);
}

.filters,
.form-grid,
.upload-form {
  display: grid;
  gap: 14px;
}

.filters {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid--compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field,
.field--wide {
  display: grid;
  gap: 7px;
}

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

.field__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.field--checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 28px;
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.input:focus {
  outline: none;
  border-color: rgba(29, 76, 74, 0.5);
  box-shadow: 0 0 0 4px rgba(29, 76, 74, 0.1);
}

.input[disabled],
.button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(215, 202, 183, 0.85);
  border-radius: var(--radius-md);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.table th,
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(215, 202, 183, 0.85);
  text-align: left;
  vertical-align: top;
}

.table th {
  position: sticky;
  top: 0;
  background: rgba(249, 243, 235, 0.96);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.table tbody tr {
  cursor: pointer;
  transition: background-color 0.18s ease;
}

.table tbody tr:hover {
  background: rgba(239, 229, 214, 0.52);
}

.table tbody tr.is-selected {
  background: rgba(29, 76, 74, 0.1);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.subsection {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(215, 202, 183, 0.85);
}

.subsection__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.subsection__head h3 {
  margin: 0;
  font-size: 20px;
}

.document-list,
.list,
.timeline {
  display: grid;
  gap: 12px;
}

.document-card,
.list-item,
.timeline-item,
.capability-item {
  padding: 14px 16px;
  border: 1px solid rgba(215, 202, 183, 0.86);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
}

.document-card {
  display: grid;
  gap: 12px;
}

.document-card[data-preview-url] {
  cursor: pointer;
}

.document-card__preview-wrap {
  overflow: hidden;
  border: 1px solid rgba(215, 202, 183, 0.86);
  border-radius: 14px;
  background: rgba(248, 242, 233, 0.92);
}

.document-card__open {
  display: grid;
  gap: 12px;
}

.document-card__image {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(239, 229, 214, 0.62));
}

.document-card__frame {
  display: block;
  width: 100%;
  min-height: 260px;
  border: 0;
  background: #fff;
}

.document-card__kind {
  display: grid;
  place-items: center;
  min-height: 160px;
  padding: 24px 18px;
  color: var(--brand-strong);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(239, 229, 214, 0.62));
}

.document-card__fallback {
  padding: 24px 18px;
  color: var(--muted);
  text-align: center;
}

.document-card__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.document-card__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(197, 178, 148, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.document-card__button:hover {
  text-decoration: none;
}

.input--readonly {
  display: flex;
  align-items: center;
  background: rgba(244, 239, 231, 0.92);
  color: var(--text);
}

.dialog-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 24px;
}

.dialog-modal.is-hidden {
  display: none;
}

.dialog-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 27, 37, 0.66);
  backdrop-filter: blur(8px);
}

.dialog-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  background: rgba(255, 251, 246, 0.98);
  box-shadow: 0 30px 70px rgba(18, 27, 37, 0.32);
}

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

.dialog-modal__title {
  margin: 0;
  font-family: var(--font-title);
  font-size: 30px;
}

.dialog-modal__close {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(197, 178, 148, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  padding: 24px;
}

.preview-modal.is-hidden {
  display: none;
}

.preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 27, 37, 0.72);
  backdrop-filter: blur(8px);
}

.preview-modal__dialog {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  width: min(1100px, 100%);
  max-height: calc(100vh - 48px);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  background: rgba(255, 251, 246, 0.98);
  box-shadow: 0 30px 70px rgba(18, 27, 37, 0.32);
}

.preview-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.preview-modal__title {
  margin: 0;
  font-family: var(--font-title);
  font-size: 30px;
}

.preview-modal__close {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(197, 178, 148, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.preview-modal__body {
  overflow: auto;
}

.preview-modal__frame,
.preview-modal__image {
  display: block;
  width: 100%;
  min-height: 70vh;
  border: 0;
  border-radius: 18px;
  background: #fff;
}

.preview-modal__image {
  min-height: auto;
  max-height: 78vh;
  object-fit: contain;
}

.preview-modal__fallback {
  padding: 36px 24px;
  border: 1px dashed rgba(197, 178, 148, 0.86);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.document-card__meta,
.timeline-item__meta {
  color: var(--muted);
  font-size: 12px;
}

.list--plain .capability-item {
  background: rgba(255, 255, 255, 0.66);
}

.empty-state {
  padding: 22px;
  border: 1px dashed rgba(197, 178, 148, 0.9);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.status-pill[data-status="submitted"] {
  background: rgba(212, 111, 51, 0.16);
  color: var(--accent-strong);
}

.status-pill[data-status="under_review"] {
  background: rgba(29, 76, 74, 0.16);
  color: var(--brand-strong);
}

.status-pill[data-status="need_documents"] {
  background: rgba(239, 194, 137, 0.22);
  color: #8a5715;
}

.status-pill[data-status="in_work"] {
  background: rgba(52, 124, 129, 0.16);
  color: #205d68;
}

.status-pill[data-status="approved"] {
  background: rgba(34, 121, 93, 0.14);
  color: var(--ok);
}

.status-pill[data-status="rejected"] {
  background: rgba(181, 63, 63, 0.12);
  color: var(--danger);
}

.status-pill[data-status="archived"] {
  background: rgba(105, 114, 129, 0.14);
  color: #495262;
}

.is-hidden {
  display: none !important;
}

.clickable-link {
  font-weight: 700;
}

.summary-title {
  font-weight: 800;
}

.summary-text {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1280px) {
  .shell {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid--two,
  .grid--workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    min-height: auto;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
  }

  .filters,
  .form-grid,
  .form-grid--compact {
    grid-template-columns: 1fr;
  }

  .field--checkbox {
    padding-top: 0;
  }

  .stats {
    grid-template-columns: 1fr;
  }
}
