:root {
  color-scheme: light;
  --paper: #f2f4f1;
  --surface: #ffffff;
  --surface-soft: #f7f8f6;
  --ink: #172824;
  --ink-muted: #56645f;
  --line: #d8e0db;
  --line-strong: #becbc3;
  --green: #145f4c;
  --green-hover: #0d4b3b;
  --green-soft: #e6f2ec;
  --amber: #704800;
  --amber-soft: #fbf1d8;
  --red: #9c302d;
  --red-soft: #fff0ed;
  --white: #fff;
  --focus: #087eaf;
  --radius: 10px;
  --control-height: 42px;
  --shadow-raised: 0 10px 28px rgb(25 46 38 / 8%);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--paper);
  color: var(--ink);
  accent-color: var(--green);
  caret-color: var(--green);
  scrollbar-color: var(--line-strong) var(--paper);
  scrollbar-width: thin;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

::selection {
  background: #c8e6d7;
  color: #102a22;
}

a {
  color: var(--green);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--green-hover);
  text-decoration-thickness: 2px;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 5;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: 6px;
  background: var(--ink);
  color: var(--white);
  font-weight: 650;
}

.skip-link:focus {
  transform: translateY(0);
}

.brand-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark span {
  color: var(--ink-muted);
  font-weight: 500;
  letter-spacing: 0;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(320px, 470px) minmax(240px, 390px);
  align-items: stretch;
  gap: clamp(48px, 9vw, 140px);
  width: min(100% - 48px, 1080px);
  min-height: min(760px, 100vh);
  margin: 0 auto;
  padding: 72px 0;
}

.login-panel {
  align-self: center;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.login-panel h1,
.page-heading h1 {
  margin: 30px 0 9px;
  font-size: 2rem;
  font-weight: 680;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.login-panel .brand-mark {
  font-size: 1.05rem;
}

.lede {
  max-width: 62ch;
  margin: 0;
  color: var(--ink-muted);
  line-height: 1.6;
}

.form-stack,
.create-user {
  display: grid;
  gap: 9px;
}

.form-stack {
  margin-top: 30px;
}

label {
  margin-top: 8px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 640;
}

input,
select {
  width: 100%;
  min-height: var(--control-height);
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
}

input::placeholder {
  color: #66746f;
  opacity: 1;
}

input:hover,
select:hover {
  border-color: #879a90;
}

input:disabled,
select:disabled {
  background: #edf0ed;
  color: #66736e;
  cursor: not-allowed;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}

.button-primary {
  background: var(--green);
  color: var(--white);
}

.button-primary:hover:not(:disabled) {
  background: var(--green-hover);
  color: var(--white);
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled) {
  border-color: #94a69c;
  background: #f4f7f4;
}

.button:disabled {
  border-color: var(--line);
  background: #e9ece9;
  color: #64716c;
  cursor: not-allowed;
}

.form-stack .button {
  width: 100%;
  margin-top: 14px;
}

.support-note,
.login-aside p {
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.support-note {
  margin: 24px 0 0;
}

.login-aside {
  display: flex;
  flex-direction: column;
  align-self: center;
  justify-content: flex-end;
  min-height: 410px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line-strong);
}

.login-aside::before {
  width: 36px;
  height: 3px;
  margin-bottom: 22px;
  background: var(--green);
  content: "";
}

.environment-label,
.section-label {
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.login-aside p {
  max-width: 32ch;
  margin: 10px 0 0;
  font-size: 1.05rem;
}

.topbar {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
}

.topbar nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.topbar nav > a {
  font-weight: 600;
}

.user-name {
  color: var(--ink);
  font-weight: 600;
}

.role-badge,
.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-muted);
  font-size: 0.76rem;
  font-weight: 620;
  white-space: nowrap;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.link-button {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.link-button:hover {
  color: var(--green-hover);
  text-decoration-thickness: 2px;
}

.page-shell {
  width: min(100% - 48px, 1240px);
  margin: 0 auto;
  padding: 52px 0 80px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.page-heading h1 {
  margin: 8px 0 0;
  font-size: 2.2rem;
}

.section-label {
  margin: 0;
}

.notice {
  margin: 0 0 20px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.notice p {
  margin: 0;
}

.notice-local {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--green-soft);
  border-color: #c3dfcf;
}

.notice-success {
  background: var(--green-soft);
  border-color: #c3dfcf;
}

.notice-error {
  background: var(--red-soft);
  border-color: #f1c7c1;
  color: #762420;
}

.notice-warning {
  background: var(--amber-soft);
  border-color: #ead7a7;
  color: #563700;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
}

.project-list {
  overflow: visible;
  border-top: 1px solid var(--line-strong);
}

.list-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0 18px;
}

.list-heading h2,
.user-table-wrap h2,
.create-user h2,
.detail-placeholder h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.12rem;
  font-weight: 680;
  letter-spacing: -0.015em;
}

.muted {
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.list-heading .muted {
  display: block;
  margin-top: 5px;
}

.search-form {
  display: flex;
  gap: 8px;
  width: min(100%, 420px);
}

.search-form input {
  min-width: 0;
}

.table-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: var(--surface-soft);
  color: var(--ink-muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
}

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

tbody tr:hover {
  background: #f8faf8;
}

.project-table th:first-child,
.project-table td:first-child {
  width: 42%;
  padding-left: 20px;
}

.project-link {
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

.project-link:hover {
  color: var(--green-hover);
  text-decoration: underline;
}

.project-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--ink-muted);
  font-size: 0.76rem;
  font-weight: 620;
  line-height: 1.25;
  white-space: nowrap;
}

.status-unverified {
  border-color: #d7ded9;
  background: #eff2f0;
  color: #394b44;
}

.status-warning {
  border-color: #e8d39d;
  background: var(--amber-soft);
  color: var(--amber);
}

.status-active,
.entry-yes {
  color: var(--green);
  font-weight: 620;
}

.empty-state {
  padding: 45px 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.empty-state p {
  max-width: 56ch;
  margin: 0 auto;
  color: var(--ink-muted);
}

.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.list-footer form {
  margin: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.breadcrumb a {
  color: var(--green);
}

.detail-shell .page-heading {
  align-items: center;
}

.project-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 40px;
  margin: 0;
  border-top: 1px solid var(--line-strong);
}

.project-facts > div {
  display: grid;
  grid-template-columns: minmax(130px, 0.75fr) minmax(0, 1.25fr);
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.project-facts dt {
  color: var(--ink-muted);
  font-size: 0.87rem;
}

.project-facts dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.detail-placeholder {
  margin-top: 38px;
  padding-top: 20px;
  border-top: 1px solid var(--line-strong);
}

.detail-placeholder p {
  max-width: 68ch;
  color: var(--ink-muted);
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, 0.85fr);
  align-items: start;
  gap: 38px;
}

.user-table-wrap,
.create-user {
  min-width: 0;
}

.user-table-wrap > h2 {
  margin-bottom: 16px;
}

.user-table-wrap table {
  border-top: 1px solid var(--line-strong);
  background: var(--surface);
}

.user-table-wrap td:first-child strong,
.user-table-wrap td:first-child small {
  display: block;
}

.user-table-wrap td:first-child small {
  margin-top: 2px;
  color: var(--ink-muted);
}

.create-user {
  gap: 7px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.create-user .muted {
  margin: 0 0 8px;
}

.create-user label {
  margin-top: 8px;
}

.create-user .button {
  margin-top: 16px;
}

.row-actions {
  position: relative;
}

.row-actions summary {
  color: var(--green);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.row-actions form {
  position: absolute;
  z-index: 1;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.danger-text {
  padding: 7px 4px;
  border: 0;
  background: transparent;
  color: var(--red);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
}

.upload-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: min(88vh, 820px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 28px 90px rgb(16 33 28 / 24%);
}

.upload-dialog::backdrop {
  background: rgb(12 25 22 / 50%);
  backdrop-filter: blur(3px);
}

.upload-panel {
  display: grid;
  gap: 14px;
  padding: clamp(20px, 5vw, 32px);
}

.upload-panel h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.025em;
}

.dialog-heading,
.progress-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-muted);
  background: var(--surface);
  font-size: 1.5rem;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.upload-panel label {
  margin-bottom: -8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.upload-panel input[type="text"],
.upload-panel input:not([type]) {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: var(--surface);
}

.upload-panel input[type="file"] {
  width: 100%;
  min-height: 48px;
  padding: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface-soft);
}

.upload-panel input:focus-visible,
.upload-panel button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.field-help {
  margin: -7px 0 0;
  color: var(--ink-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.upload-panel .notice {
  margin: 0;
}

.upload-progress {
  display: grid;
  gap: 8px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.upload-progress progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  color: var(--green);
  background: #e6ece8;
}

.upload-progress progress::-webkit-progress-bar {
  border-radius: 999px;
  background: #e6ece8;
}

.upload-progress progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--green);
}

.upload-progress progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--green);
}

.upload-progress .muted {
  min-height: 1.4em;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 6px;
}

.dialog-actions [disabled] {
  cursor: wait;
  opacity: 0.66;
}

.danger-text:hover {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.sr-only {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 820px) {
  .login-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 34px;
    width: min(100% - 32px, 560px);
    padding: 32px 0;
  }

  .login-panel {
    padding: 30px 26px;
  }

  .login-aside {
    min-height: 0;
    padding: 0 0 15px;
  }

  .topbar {
    padding: 0 20px;
  }

  .topbar nav {
    gap: 12px;
  }

  .page-shell {
    width: min(100% - 32px, 1240px);
    padding-top: 38px;
  }

  .admin-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
  }

  .create-user {
    max-width: 620px;
  }
}

@media (max-width: 600px) {
  .topbar {
    min-height: 62px;
    padding: 0 16px;
  }

  .topbar nav {
    gap: 10px;
  }

  .topbar nav .user-name {
    max-width: 18ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .role-badge {
    display: none;
  }

  .page-shell {
    width: min(100% - 28px, 1240px);
    padding: 30px 0 56px;
  }

  .page-heading {
    align-items: flex-start;
    gap: 14px;
  }

  .page-heading h1 {
    font-size: 1.85rem;
  }

  .page-heading > .button {
    padding: 0 11px;
    font-size: 0.84rem;
  }

  .list-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 15px;
  }

  .search-form {
    width: 100%;
  }

  .search-form .button {
    flex: 0 0 auto;
  }

  .project-table {
    min-width: 740px;
  }

  .table-scroll {
    margin-right: -14px;
    padding-right: 14px;
  }

  .list-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .project-facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .project-facts > div {
    grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1.3fr);
  }

  .user-table-wrap {
    overflow-x: auto;
  }

  .user-table-wrap table {
    min-width: 560px;
  }

  .login-panel {
    padding: 26px 21px;
  }

  .login-panel h1 {
    font-size: 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
