:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-subtle: #f8f9f7;
  --text: #262a27;
  --muted: #667068;
  --line: #d9ded9;
  --line-strong: #bdc5bd;
  --green: #35a533;
  --green-dark: #257d25;
  --green-soft: #e8f5e7;
  --charcoal: #30322f;
  --red: #ad2e24;
  --amber: #8a5b00;
  --shadow: 0 10px 28px rgba(38, 42, 39, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button,
a.secondary-button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

button:hover,
a.secondary-button:hover {
  border-color: #909b91;
  background: var(--surface-subtle);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(53, 165, 51, 0.24);
  outline-offset: 1px;
}

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

.primary-button {
  color: #ffffff;
  background: var(--green);
  border-color: var(--green);
  font-weight: 700;
}

.primary-button:hover {
  color: #ffffff;
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.secondary-button {
  background: var(--surface);
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.text-button {
  min-height: auto;
  border: 0;
  border-radius: 0;
  padding: 2px 0;
  justify-content: flex-start;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.text-button:hover {
  border: 0;
  background: transparent;
  color: var(--text);
}

.full-button {
  width: 100%;
}

.eyebrow {
  display: block;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef1ed;
}

.login-panel {
  width: min(420px, 100%);
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 5px solid var(--green);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  width: min(260px, 100%);
  height: auto;
  margin: 0 auto 30px;
}

.login-heading {
  margin-bottom: 22px;
}

.login-heading h1 {
  margin: 5px 0 0;
  font-size: 28px;
  line-height: 1.2;
}

.login-owner {
  margin: 24px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.field > span,
.check-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
}

.field textarea {
  resize: vertical;
  line-height: 1.45;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #959d96;
}

.field.compact {
  width: 180px;
}

.field.compact select,
.field.compact input {
  min-height: 40px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.search-field {
  width: 230px !important;
}

.check-field {
  min-height: 40px;
  margin-top: 21px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  white-space: nowrap;
}

.check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.form-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-message.error,
.error {
  color: var(--red);
}

.success {
  color: var(--green-dark);
}

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

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

.brand {
  padding: 5px 4px 18px;
  border-bottom: 1px solid var(--line);
}

.brand img {
  display: block;
  width: 190px;
  max-width: 100%;
  height: auto;
}

.portal-identity {
  display: grid;
  gap: 3px;
  padding: 0 5px;
}

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

.portal-identity strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

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

.nav-item {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: #4b534d;
  font-weight: 650;
}

.nav-item:hover {
  border-color: transparent;
  background: var(--surface-subtle);
}

.nav-item.active {
  background: var(--charcoal);
  border-color: var(--charcoal);
  color: #ffffff;
}

.nav-symbol {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
}

.account-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 16px 5px 0;
  border-top: 1px solid var(--line);
}

.account-box strong,
.account-box span {
  display: block;
}

.account-box strong {
  font-size: 14px;
}

.account-box span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 28px 30px 20px;
  display: flex;
  flex-direction: column;
}

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

.page-heading {
  min-width: 190px;
}

.page-heading h1 {
  margin: 4px 0 0;
  font-size: 29px;
  line-height: 1.15;
}

.page-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.actions > button,
.actions > a {
  margin-top: 21px;
}

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

.metric {
  min-height: 108px;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 11px;
  overflow-wrap: anywhere;
  font-size: 27px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metric.accent {
  border-top: 3px solid var(--green);
  padding-top: 15px;
}

.metric.accent strong {
  color: var(--green-dark);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.panel,
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.panel-header {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.section-toolbar h2 {
  margin: 0;
  font-size: 16px;
}

.rank-list {
  min-height: 64px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid #edf0ed;
}

.rank-row:last-child {
  border-bottom: 0;
}

.rank-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 23px 16px;
  color: var(--muted);
  text-align: left;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr[data-clickable="true"] {
  cursor: pointer;
}

tbody tr[data-clickable="true"]:hover {
  background: #f6faf5;
}

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

.cell-main {
  display: block;
  max-width: 290px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.cell-sub {
  display: block;
  max-width: 320px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #ecefec;
  color: #566057;
  font-size: 11px;
  font-weight: 800;
}

.pill.lead,
.pill.active {
  background: var(--green-soft);
  color: var(--green-dark);
}

.pill.inactive {
  background: #f4e7e5;
  color: var(--red);
}

.section-toolbar {
  min-height: 64px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-table {
  min-width: 900px;
}

.site-stack {
  display: grid;
  gap: 7px;
}

.site-row {
  display: grid;
  gap: 2px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.row-actions button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 12px;
}

.actions-column {
  min-width: 300px;
  text-align: right;
}

.app-footer {
  margin-top: auto;
  padding: 28px 2px 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 70px rgba(38, 42, 39, 0.28);
}

dialog.wide-dialog {
  width: min(920px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(29, 32, 29, 0.5);
}

.dialog-head {
  min-height: 82px;
  padding: 17px 19px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2,
.dialog-head p {
  margin: 0;
}

.dialog-head h2 {
  margin-top: 4px;
  font-size: 21px;
}

.dialog-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.close-dialog {
  flex: 0 0 40px;
}

.dialog-content {
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding: 19px;
  display: grid;
  gap: 17px;
}

.dialog-content h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

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

.split-actions {
  justify-content: space-between;
  align-items: flex-end;
}

.split-actions > div {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

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

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

.company-summary {
  padding: 15px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 6px;
}

.company-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 13px;
}

.company-summary-head h3 {
  margin: 0;
}

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

.detail-grid div {
  min-width: 0;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 650;
}

.timeline {
  display: grid;
}

.timeline-item {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
}

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

.candidate-list {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-subtle);
}

.candidate-button {
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  display: grid;
  justify-items: start;
  text-align: left;
  white-space: normal;
}

.candidate-button strong,
.candidate-button span {
  max-width: 100%;
  overflow-wrap: anywhere;
}

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

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

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

@media (max-width: 1180px) {
  .topbar {
    display: grid;
    width: 100%;
    justify-content: stretch;
  }

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

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

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 15px 18px;
    display: grid;
    grid-template-columns: 160px minmax(120px, 1fr);
    gap: 12px 18px;
  }

  .brand {
    padding: 0;
    border: 0;
  }

  .brand img {
    width: 150px;
  }

  .portal-identity {
    align-self: center;
  }

  .nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 5px;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
  }

  .account-box {
    grid-column: 1 / -1;
    margin: 0;
    padding: 11px 0 0;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
  }

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

@media (max-width: 680px) {
  .login-screen {
    padding: 14px;
  }

  .login-panel {
    padding: 25px 20px;
  }

  .main {
    padding: 20px 14px 16px;
  }

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

  .portal-identity,
  .nav,
  .account-box {
    grid-column: 1;
  }

  .brand img {
    width: 170px;
  }

  .account-box {
    grid-template-columns: 1fr auto;
  }

  .account-box > div {
    grid-column: 1 / -1;
  }

  .actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    justify-content: stretch;
  }

  .field.compact,
  .search-field {
    width: 100% !important;
  }

  .nav {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .nav-item {
    flex: 1 1 calc(33.333% - 5px);
    justify-content: center;
  }

  .check-field,
  .actions > button,
  .actions > a {
    margin-top: 0;
  }

  .check-field {
    align-self: end;
  }

  .metrics,
  .dashboard-grid,
  .form-grid,
  .detail-grid,
  .credential-block {
    grid-template-columns: 1fr;
  }

  .full-field {
    grid-column: auto;
  }

  .metric {
    min-height: 96px;
  }

  .section-toolbar,
  .split-actions,
  .app-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .split-actions > div {
    display: grid;
  }

  .dialog-head,
  .dialog-content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .copy-row {
    grid-template-columns: 1fr;
  }
}

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

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

  .nav-symbol {
    display: none;
  }

  .nav-item {
    padding-left: 10px;
    padding-right: 10px;
  }
}
