:root {
  --bg: #081733;
  --bg-2: #0f2242;
  --panel: #12295a;
  --card: rgba(255, 255, 255, 0.07);
  --text: #eaf2ff;
  --muted: #b4c4ec;
  --accent: #50d7ff;
  --accent-2: #6b72ff;
  --ok: #36d89a;
  --warn: #ffcc66;
  --danger: #ff7c7c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 500 16px/1.45 "Inter", "Segoe UI", "Trebuchet MS", Arial, sans-serif;
  background:
    radial-gradient(1150px 650px at 20% -5%, #1d3f78 0%, transparent 60%),
    radial-gradient(900px 560px at 90% 0%, #26458d 0%, transparent 58%),
    linear-gradient(180deg, #040d23 0%, #081733 48%, #0a1d3d 100%);
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.25;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

a {
  color: var(--accent);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 12px;
  z-index: 20;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(6, 16, 38, 0.82);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #56dcff, #6f78ff);
  color: #061329;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow: 0 10px 24px rgba(12, 26, 58, 0.4);
}

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

#langSelect {
  min-width: 122px;
  width: auto;
  height: 34px;
  background: #f8fbff;
  color: #1e293b;
}

.ghost-link {
  text-decoration: none;
}

.role-badge {
  height: 32px;
  min-width: 104px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.role-badge.role-admin {
  background: rgba(99, 255, 188, 0.2);
  color: #d4ffee;
  border-color: rgba(54, 216, 154, 0.45);
}

.role-badge.role-approver {
  background: rgba(128, 195, 255, 0.2);
  color: #d8edff;
  border-color: rgba(89, 164, 255, 0.45);
}

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
  backdrop-filter: blur(8px);
  animation: enter 240ms ease;
  scroll-margin-top: 92px;
}

.identity-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.identity-actions {
  display: flex;
  gap: 10px;
}

.role-shell {
  display: grid;
  gap: 12px;
}

.role-card {
  display: none;
  padding: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.26);
}

.role-card p,
.role-card ul {
  margin: 0;
}

.role-card h3 {
  margin-bottom: 8px;
}

.role-card ul {
  margin-top: 10px;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.role-card.is-visible {
  display: block;
  animation: enter 230ms ease;
}

.stat-grid {
  margin-top: 4px;
}

.stat-card {
  min-height: 102px;
}

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

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

  .role-shell {
    grid-template-columns: repeat(3, 1fr);
  }
}

label {
  color: var(--muted);
  font-size: 14px;
}

input,
button,
select,
textarea,
.pick-button {
  font: inherit;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--text);
  background: rgba(2, 8, 24, 0.8);
  border-radius: 11px;
  padding: 10px 12px;
  min-height: 44px;
  transition: all 150ms ease;
}

button,
.pick-button {
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #45d2ff, #5a67ff);
  color: #061329;
  font-weight: 700;
  text-align: center;
  touch-action: manipulation;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(74, 138, 219, 0.2);
}

.secondary {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text);
}

button:disabled,
.pick-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.pick-button.is-disabled {
  pointer-events: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.pick-button:focus-visible {
  outline: 2px solid rgba(95, 201, 254, 0.9);
  outline-offset: 2px;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--text);
  animation: spin 0.8s linear infinite;
  display: inline-block;
  margin-right: 8px;
  vertical-align: text-bottom;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.upload-form {
  align-items: stretch;
  gap: 12px;
}

.upload-input-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
}

.hidden-file-input {
  display: none;
}

.pick-button {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-label {
  display: inline-block;
  padding: 10px 12px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.document-console {
  padding: 18px;
  border-color: rgba(80, 215, 255, 0.22);
  background: rgba(8, 20, 46, 0.82);
}

.console-head {
  align-items: flex-start;
  gap: 16px;
}

.console-head h2 {
  margin-bottom: 4px;
}

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

.status-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.status-tab {
  min-width: 132px;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status-tab:hover {
  transform: none;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.1);
}

.status-tab.is-active {
  background: #eaf2ff;
  color: #07152f;
}

.status-tab b {
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(8, 23, 51, 0.12);
  font-size: 12px;
}

.toolbar-grid {
  margin: 16px 0 12px;
  align-items: flex-end;
}

.toolbar-grid .input-card {
  min-width: 240px;
}

.document-table-wrap {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(2, 8, 24, 0.28);
}

.document-table-wrap table {
  min-width: 940px;
}

.document-table-wrap td strong {
  display: block;
  max-width: 280px;
  overflow-wrap: anywhere;
}

.document-table-wrap td small {
  display: block;
  margin-top: 4px;
}

.legacy-doc-section {
  display: none;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
}

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

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
  padding: 10px;
  vertical-align: top;
}

th {
  text-align: left;
  color: var(--muted);
  font-size: 13px;
}

td {
  font-size: 14px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: #061329;
  font-weight: 700;
}

.pill.pending {
  background: var(--warn);
}

.pill.approved {
  background: var(--ok);
}

.pill.rejected {
  background: var(--danger);
  color: #1b0d13;
}

.status-line {
  color: var(--muted);
}

small {
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-btn {
  min-width: 98px;
}

#refreshState {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.state-indicator.hidden {
  display: none !important;
}

.dot-loader {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.toast {
  margin-top: 6px;
}

.progress-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}

.upload-progress {
  width: 100%;
  height: 8px;
}

.upload-progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.upload-progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.hidden {
  display: none !important;
}

.input-card {
  min-width: 220px;
  flex: 1 1 220px;
}

.settings-wide {
  flex-basis: 320px;
}

.compact-input {
  min-width: 150px;
  flex: 0 1 180px;
}

.input-card select {
  width: 100%;
}

.input-card input {
  width: 100%;
}

.input-card textarea {
  width: 100%;
  min-height: 46px;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

li::marker {
  color: var(--accent);
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .identity-card {
    align-items: stretch;
  }

  .identity-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .header {
    top: 0;
    border-radius: 0 0 16px 16px;
  }

  .console-actions,
  .status-tabs {
    width: 100%;
  }

  .status-tabs {
    display: grid;
    grid-template-columns: 1fr;
  }

  .status-tab {
    width: 100%;
  }

  .row {
    gap: 8px;
  }

  .upload-input-wrap,
  .upload-form {
    flex-direction: column;
    width: 100%;
  }

  #uploadBtn,
  #pickFileBtn,
  .file-label,
  button,
  input,
  textarea,
  .pick-button {
    width: 100%;
  }

  #langSelect {
    width: 120px;
  }

  .input-card {
    min-width: auto;
    width: 100%;
  }
}

.dashboard-page {
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 340px;
  grid-template-rows: 66px auto;
  grid-auto-rows: min-content;
  align-items: start;
  gap: 0;
}

.dashboard-sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(5, 18, 38, 0.86);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 22px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 1px;
}

.sidebar-brand small {
  display: block;
  font-size: 10px;
  letter-spacing: 1.8px;
}

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

.sidebar-nav a,
.sidebar-nav span {
  min-height: 44px;
  padding: 11px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-nav > span {
  min-height: 32px;
  padding-top: 18px;
  text-transform: uppercase;
  font-size: 12px;
  opacity: 0.85;
}

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
  color: var(--text);
  background: rgba(54, 121, 255, 0.72);
}

.sidebar-nav b {
  min-width: 26px;
  height: 24px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  font-size: 12px;
}

.dashboard-page > .header {
  grid-column: 2 / 4;
  grid-row: 1;
  position: sticky;
  top: 0;
  margin: 0;
  border-radius: 0;
  border-width: 0 0 1px;
  padding: 12px 28px;
}

.dashboard-page > .card,
.dashboard-page > .grid,
.dashboard-page > .role-shell,
.dashboard-page > .toast {
  grid-column: 2;
  margin-left: 18px;
  margin-right: 14px;
}

.dashboard-page > .identity-card,
.dashboard-page > .role-shell {
  display: none;
}

.dashboard-page > .stat-grid {
  grid-column: 2;
  margin-top: 22px;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.dashboard-page .stat-card {
  min-height: 132px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.dashboard-page .stat-card strong {
  font-size: 28px;
  line-height: 1;
}

.dashboard-page .stat-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-page > #contactSummarySection,
.dashboard-page > #leadSection {
  grid-column: 3;
  margin-left: 0;
  margin-right: 18px;
}

.dashboard-page > #contactSummarySection {
  grid-row: 3 / span 2;
}

.dashboard-page > #leadSection {
  grid-row: auto;
}

.contact-summary dl {
  margin: 0;
  display: grid;
  gap: 16px;
}

.contact-summary div {
  display: grid;
  gap: 4px;
}

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

.contact-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.mini-link {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
  font-size: 13px;
}

.dashboard-page > #documentConsole {
  grid-column: 2;
}

.dashboard-page > .stat-grid {
  order: 1;
  grid-row: 2;
}

.dashboard-page > #contactSummarySection {
  order: 1;
  grid-row: 2 / 4;
}

.dashboard-page > #documentConsole {
  order: 2;
  grid-row: 3;
}

.dashboard-page > #leadSection {
  order: 2;
  grid-row: 4;
}

.dashboard-page > #uploadSection {
  order: 3;
  grid-row: 5;
}

.dashboard-page > #userSection {
  order: 4;
  grid-row: 6;
}

.dashboard-page > #settingsSection {
  order: 5;
  grid-row: 7;
}

.dashboard-page > #auditSection {
  order: 6;
  grid-row: 8;
}

.dashboard-page > #profileSection {
  order: 7;
  grid-column: 2 / 4;
  grid-row: 9;
}

.dashboard-page > #userSection,
.dashboard-page > #settingsSection,
.dashboard-page > #auditSection {
  grid-column: 2 / 4;
}

.dashboard-page #leadSection .table-wrap {
  max-height: 360px;
}

.dashboard-page #leadSection table {
  min-width: 520px;
}

@media (max-width: 1180px) {
  .dashboard-page {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .dashboard-page > .header,
  .dashboard-page > #userSection,
  .dashboard-page > #settingsSection,
  .dashboard-page > #auditSection {
    grid-column: 2;
  }

  .dashboard-page > #contactSummarySection,
  .dashboard-page > #leadSection {
    grid-column: 2;
    grid-row: auto;
    margin-left: 18px;
    margin-right: 14px;
  }

  .dashboard-page > .stat-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 760px) {
  .dashboard-page {
    display: block;
    padding: 0 12px 16px;
  }

  .dashboard-sidebar {
    position: static;
    height: auto;
    margin: 0 -12px 12px;
  }

  .dashboard-page > .header,
  .dashboard-page > .card,
  .dashboard-page > .grid,
  .dashboard-page > .toast {
    margin-left: 0;
    margin-right: 0;
  }

  .dashboard-page > .stat-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-page {
  display: block;
  padding: 0 340px 24px 248px;
}

.dashboard-sidebar {
  position: fixed;
  left: 0;
}

.dashboard-page > .header {
  margin: 0 -340px 18px 0;
}

.dashboard-page > .card,
.dashboard-page > .grid,
.dashboard-page > .role-shell,
.dashboard-page > .toast {
  margin-left: 18px;
  margin-right: 14px;
}

.dashboard-page > .stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  margin-top: 22px;
}

.dashboard-page > #contactSummarySection,
.dashboard-page > #leadSection {
  position: fixed;
  right: 18px;
  width: 322px;
  margin: 0;
  z-index: 6;
}

.dashboard-page > #contactSummarySection {
  top: 88px;
}

.dashboard-page > #leadSection {
  top: 470px;
  max-height: calc(100vh - 488px);
  overflow: auto;
}

.dashboard-page > #userSection,
.dashboard-page > #settingsSection,
.dashboard-page > #auditSection,
.dashboard-page > #profileSection {
  grid-column: auto;
}

@media (max-width: 1180px) {
  .dashboard-page {
    display: block;
    padding: 0 16px 24px 226px;
  }

  .dashboard-page > .header {
    margin-right: 0;
  }

  .dashboard-page > #contactSummarySection,
  .dashboard-page > #leadSection {
    position: static;
    width: auto;
    max-height: none;
    margin-left: 18px;
    margin-right: 14px;
  }

  .dashboard-page > .stat-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 760px) {
  .dashboard-page {
    padding: 0 12px 16px;
  }

  .dashboard-sidebar {
    position: static;
  }

  .dashboard-page > .stat-grid {
    grid-template-columns: 1fr;
  }
}
