:root {
  --orange: #ff9300;
  --orange-dark: #e17700;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --line: #e2e7ef;
  --text: #182230;
  --muted: #667085;
  --sidebar: #1f2937;
  --green: #147a4d;
  --red: #ba3b25;
  --amber: #9a5b00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 13px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

.auth-brand {
  color: var(--text);
  padding: 0 0 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.auth-brand small {
  color: var(--muted);
}

a {
  color: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 230px;
  background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  color: #fff;
  padding: 16px 12px;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--orange);
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #b9c3cf;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 4px;
  margin-top: 18px;
}

nav a {
  padding: 10px 12px;
  border-radius: 6px;
  color: #e8eef5;
  text-decoration: none;
}

nav a:hover,
nav a.active {
  background: rgba(255, 255, 255, 0.1);
}

nav a.active {
  color: #fff;
  border-left: 3px solid var(--orange);
}

.nav-section {
  margin: 12px 8px 4px;
  color: #fbbf24;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app {
  margin-left: 230px;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.search {
  display: flex;
  min-width: 380px;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 147, 0, 0.15);
  outline: none;
}

textarea {
  resize: vertical;
}

button,
.btn-mini {
  border: 0;
  border-radius: 6px;
  background: var(--orange);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

button {
  padding: 8px 13px;
}

.btn-mini {
  display: inline-block;
  padding: 6px 10px;
  white-space: nowrap;
}

.search input {
  border-radius: 5px 0 0 5px;
}

.search button {
  border-radius: 0 5px 5px 0;
}

.primary:hover,
button:hover,
.btn-mini:hover {
  background: var(--orange-dark);
}

.ghost {
  background: #202938;
}

.danger {
  background: #b42318;
}

.danger:hover {
  background: #8f1d14;
}

.flash {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.flash.success {
  background: #e9f7ef;
  color: #17633a;
}

.flash.error {
  background: #fff0f0;
  color: #a12828;
}

.import-wizard {
  border-color: #ffc36f;
}

.wizard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 14px;
  padding: 14px;
}

.wizard-copy {
  margin: 8px 0 14px;
  color: var(--muted);
}

.wizard-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.wizard-form input {
  font-size: 14px;
}

.example-link {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.inline-error,
.progress-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 6px;
}

.inline-error {
  background: #fff0f0;
  color: #a12828;
  border: 1px solid #f2b8b8;
}

.progress-box {
  background: #fff7e8;
  color: #8a4d00;
  border: 1px solid #ffc36f;
  font-weight: 700;
}

button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.login-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fffaf2;
}

.login-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.login-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.login-card div {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 8px;
}

.login-card dt {
  color: var(--muted);
  font-weight: 700;
}

.login-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.import-steps {
  margin: 0;
  padding: 0 14px 14px 38px;
  color: #344054;
}

.import-steps li {
  padding: 3px 0;
}

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

.stats div,
.summary-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.stats div,
.summary-card {
  padding: 14px;
}

.stats strong {
  display: block;
  color: var(--orange);
  font-size: 24px;
}

.stats span {
  color: var(--muted);
}

.summary-card {
  display: grid;
  gap: 5px;
  align-content: start;
  border-top: 3px solid transparent;
}

.summary-card.wide {
  grid-column: span 2;
}

.summary-card span {
  color: var(--muted);
  font-weight: 700;
}

.summary-card strong {
  color: #111827;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.summary-card small {
  color: var(--text);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.warning-card {
  border-top-color: var(--orange);
  background: #fffaf2;
}

.inline-form {
  margin-top: 6px;
}

.panel {
  margin-bottom: 14px;
  overflow: hidden;
}

.panel h2,
.panel-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  margin: 0;
  padding: 10px 14px;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
}

.main-grid {
  min-height: 420px;
  max-height: calc(100vh - 260px);
}

.detail-grid {
  max-height: 260px;
}

.docs-grid {
  min-height: 260px;
  max-height: calc(100vh - 300px);
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f58b00;
  color: #fff;
  padding: 8px 7px;
  text-align: left;
  font-size: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.35);
}

.sortable-heading {
  cursor: pointer;
  user-select: none;
}

.sortable-heading::after {
  content: " ↕";
  opacity: 0.7;
  font-weight: 400;
}

.sortable-heading.sort-asc::after {
  content: " ↑";
}

.sortable-heading.sort-desc::after {
  content: " ↓";
}

td {
  padding: 7px;
  border-right: 1px solid #e4e7ec;
  border-bottom: 1px solid #e4e7ec;
  vertical-align: top;
}

tbody tr:nth-child(even) td {
  background: #f8fafc;
}

tbody tr.selected td,
tbody tr:hover td {
  background: #fff1d6;
}

tbody tr.at-risk td {
  background: #fff8e8;
}

tbody tr.is-disabled td {
  color: #8a94a6;
  background: #f3f4f6;
}

.clickable-row {
  cursor: pointer;
}

.icon-link {
  font-size: 17px;
  text-decoration: none;
}

.empty {
  color: var(--muted);
  padding: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

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

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(160px, 0.8fr)) auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.compact-filter {
  grid-template-columns: minmax(280px, 1fr) auto auto;
}

.prospectus-form {
  border-bottom: 1px solid var(--line);
}

label {
  display: grid;
  gap: 5px;
  color: #475467;
  font-weight: 700;
}

.span-2 {
  grid-column: span 2;
}

.checkbox-label {
  display: flex;
  gap: 8px;
  align-items: center;
  align-self: end;
}

.checkbox-label input {
  width: auto;
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.collapsible {
  display: none;
}

.collapsible.open {
  display: block;
}

.doc-list,
.favorite-list {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin: 0;
}

.doc-list a,
.favorite-list li {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafafa;
  text-decoration: none;
  list-style: none;
}

.doc-list span,
.favorite-list span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-delete {
  display: inline;
  margin: 0;
}

.inline-delete button {
  padding: 6px 10px;
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-ok {
  color: var(--green);
  background: #e8f6ef;
}

.badge-warn {
  color: var(--amber);
  background: #fff0c2;
}

.badge-role {
  color: #344054;
  background: #eef2f7;
}

.compact-table {
  min-width: 620px;
}

.alert-log {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.alert-log h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.alert-log p {
  margin: 6px 0;
  color: #475467;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 12px;
}

.detail-list div {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid #edf0f4;
}

.detail-list dt {
  color: #475467;
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .app {
    margin-left: 0;
    padding: 12px;
  }

  .topbar,
  .split,
  .wizard-grid,
  .wizard-form {
    display: block;
  }

  .wizard-form button {
    margin-top: 10px;
    width: 100%;
  }

  .search {
    min-width: 0;
    margin-top: 12px;
  }

  .stats,
  .market-dashboard,
  .filter-grid,
  .form-grid,
  .form-grid.compact,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .main-grid,
  .docs-grid,
  .detail-grid {
    max-height: none;
  }

  .detail-list div {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .summary-card.wide {
    grid-column: auto;
  }
}
