:root {
  --blue-25: #f7fafc;
  --blue-50: #eef7fc;
  --blue-100: #dceef8;
  --blue-200: #b9daec;
  --blue-500: #2878aa;
  --blue-650: #18567e;
  --ink: #17212b;
  --muted: #526372;
  --line: #cfdbe5;
  --panel: #ffffff;
  --green: #177b72;
  --green-soft: #e6f4f1;
  --amber: #9a6815;
  --amber-soft: #fff3da;
  --gold: #b57b23;
  --rose: #a44242;
  --rose-soft: #ffedf1;
  --violet-soft: #edf1f6;
  --shadow: 0 12px 34px rgba(34, 71, 96, 0.09);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f7fafc;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

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

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef7fc;
}

.auth-panel {
  width: min(100%, 440px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.auth-brand h1,
.auth-brand p,
.auth-form h2,
.auth-form p {
  margin: 0;
}

.auth-brand h1 {
  font-size: 22px;
}

.auth-brand p,
.auth-form > div p,
.password-hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 15px;
  padding-top: 22px;
}

.auth-form label,
.dialog-field {
  display: grid;
  gap: 7px;
  color: #3d4b5d;
  font-size: 13px;
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--rose);
  font-size: 13px;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 18px;
  background: #edf5f8;
  border-right: 1px solid var(--line);
}

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

.brand-mark {
  position: relative;
  width: 48px;
  height: 48px;
  border: 1px solid var(--blue-500);
  border-radius: 4px;
  background: #ffffff;
}

.brand-mark span {
  position: absolute;
  left: 12px;
  width: 24px;
  height: 6px;
  border-radius: 1px;
  background: var(--blue-500);
}

.brand-mark span:nth-child(1) {
  top: 13px;
}

.brand-mark span:nth-child(2) {
  top: 21px;
  opacity: 0.74;
}

.brand-mark span:nth-child(3) {
  top: 29px;
  opacity: 0.48;
}

.brand h1,
.brand p,
.panel h3,
.panel p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #34445a;
  text-align: left;
}

.nav-item:hover,
.nav-item:focus-visible {
  background: #ffffff;
  border-color: var(--line);
}

.nav-item.is-active {
  background: var(--blue-650);
  border-color: var(--blue-650);
  color: #ffffff;
  box-shadow: none;
}

.compliance-note {
  margin-top: auto;
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
}

.compliance-note p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--green);
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.topbar h2 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.15;
}

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

.account-status {
  display: grid;
  gap: 3px;
  width: 235px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
}

.account-status strong {
  overflow: hidden;
  color: var(--blue-650);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status > span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.storage-meter {
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--blue-100);
}

.storage-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width 180ms ease;
}

.user-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.user-summary > div {
  display: grid;
  min-width: 130px;
}

.user-summary strong {
  font-size: 13px;
}

.user-summary span {
  color: var(--muted);
  font-size: 11px;
}

.search-box,
.language-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.search-box input {
  width: 230px;
}

.language-box select {
  width: 136px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(40, 120, 170, 0.16);
}

.button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  color: var(--ink);
}

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

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

.button.small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.button.danger {
  border-color: #d57989;
  background: #fff7f8;
  color: var(--rose);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 18px;
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
  border-top: 3px solid var(--blue-500);
}

.metric-card:nth-child(2) {
  border-top-color: var(--green);
}

.metric-card:nth-child(3) {
  border-top-color: var(--gold);
}

.metric-card:nth-child(4) {
  border-top-color: #537895;
}

.metric-card span,
.metric-card p {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 34px;
  line-height: 1;
}

.metric-card p {
  margin: 0;
}

.content-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.users-layout {
  display: grid;
  gap: 18px;
}

.organization-layout {
  display: grid;
  gap: 18px;
}

.user-form,
.organization-form {
  max-width: 980px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

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

.panel-header h3,
.panel h3 {
  font-size: 18px;
  line-height: 1.25;
}

.panel-header p,
.panel > p {
  margin-top: 4px;
  color: var(--muted);
}

.panel-header .document-quota {
  color: var(--blue-650);
  font-size: 13px;
  font-weight: 700;
}

.readiness-list {
  display: grid;
  gap: 14px;
}

.readiness-item {
  display: grid;
  gap: 7px;
}

.readiness-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #2b3a4d;
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eef7;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue-500);
}

.table-wrap {
  overflow: auto;
  border: 1px solid #e4edf6;
  border-radius: 8px;
}

.table-wrap.compact {
  max-height: 300px;
}

.table-wrap.compact table {
  min-width: 100%;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--blue-25);
  color: #526274;
  font-size: 12px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.archive-row {
  cursor: pointer;
}

.archive-row:hover {
  background: #f8fbff;
}

.archive-row.is-selected {
  background: #f2f8ff;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--violet-soft);
  color: #5947a8;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.captured,
.pill.internal,
.pill.moderate,
.pill.manual,
.pill.not-started {
  background: var(--blue-100);
  color: var(--blue-650);
}

.pill.archived,
.pill.low,
.pill.public,
.pill.completed,
.pill.approved,
.pill.active {
  background: var(--green-soft);
  color: var(--green);
}

.pill.qa-review,
.pill.high,
.pill.restricted,
.pill.needs-engine {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.very-high,
.pill.secret,
.pill.hold,
.pill.unsupported,
.pill.rejected,
.pill.inactive {
  background: var(--rose-soft);
  color: var(--rose);
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-list.full {
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.activity-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  padding: 12px;
  border: 1px solid #e4edf6;
  border-radius: 8px;
  background: #fbfdff;
}

.activity-time {
  color: var(--muted);
  font-size: 12px;
}

.activity-body strong {
  display: block;
}

.activity-body p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.intake-form {
  gap: 16px;
}

.drop-zone {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  min-height: 132px;
  margin-bottom: 16px;
  border: 1px dashed #8bbde8;
  border-radius: 8px;
  background: var(--blue-25);
  text-align: center;
}

.drop-zone.is-over {
  background: var(--blue-100);
  border-color: var(--blue-500);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone strong,
.drop-zone span {
  display: block;
}

.drop-zone span {
  margin-top: 5px;
  color: var(--muted);
}

.metadata-suggestion,
.organization-trial-note {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-left: 3px solid var(--green);
  background: #eef8f6;
  color: #285e59;
  font-size: 13px;
  line-height: 1.45;
}

.organization-trial-note {
  margin-top: 16px;
  border-left-color: var(--blue-500);
  background: var(--blue-50);
  color: var(--blue-650);
}

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

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

.form-grid label,
.toggle-row,
.toggle {
  min-width: 0;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: #3d4b5d;
  font-size: 13px;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #34445a;
}

.toggle input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  accent-color: var(--blue-650);
}

.archive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.filter-row {
  display: flex;
  gap: 10px;
}

.filter-row select {
  width: 160px;
}

.action-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 250px;
}

.compact-select {
  width: 190px;
  min-height: 34px;
  font-size: 13px;
}

.preview-panel {
  align-self: start;
  position: sticky;
  top: 28px;
}

.record-preview {
  display: grid;
  gap: 14px;
}

.empty-state {
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--blue-25);
}

.detail-stack {
  display: grid;
  gap: 10px;
}

.detail-stack div {
  display: grid;
  gap: 3px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2f7;
}

.detail-stack dt {
  color: var(--muted);
  font-size: 12px;
}

.detail-stack dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.export-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-tile {
  padding: 14px;
  border: 1px solid #e4edf6;
  border-radius: 8px;
  background: var(--blue-25);
}

.summary-tile span {
  color: var(--muted);
  font-size: 12px;
}

.summary-tile strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

.definition-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
}

.definition-list div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf2f7;
}

.definition-list div:last-child {
  border-bottom: 0;
}

.definition-list dt {
  color: var(--muted);
  font-weight: 700;
}

.definition-list dd {
  margin: 0;
}

.hash-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid #b7d7f5;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.action-dialog {
  width: min(92vw, 560px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 26px 80px rgba(26, 54, 84, 0.28);
}

.action-dialog::backdrop {
  background: rgba(23, 32, 51, 0.42);
}

.action-dialog form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.dialog-header h3,
.dialog-header p {
  margin: 0;
}

.dialog-header h3 {
  font-size: 19px;
}

.dialog-header p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.dialog-toggle {
  margin: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding-top: 4px;
}

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

  .content-grid,
  .archive-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar,
  .top-actions,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .account-status {
    width: 100%;
  }

  .user-summary {
    width: 100%;
    flex-wrap: wrap;
    padding: 10px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .search-box input,
  .language-box select,
  .filter-row select {
    width: 100%;
  }

  .metric-grid,
  .form-grid,
  .form-grid.two,
  .export-summary {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 18px;
  }

  .activity-item,
  .definition-list div {
    grid-template-columns: 1fr;
  }
}
