:root {
  --kh-bg: #ffffff;
  --kh-bg-soft: #fafafa;
  --kh-border: #e2e2e2;
  --kh-text: #222222;
  --kh-text-muted: #6b6b6b;
  --kh-accent: #c28152;
  --kh-pill-ok: #1b8f5a;
  --kh-pill-watch: #c28c2d;
  --kh-pill-risk: #c2463d;
  --kh-radius: 8px;
  --kh-shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--kh-bg);
  color: var(--kh-text);
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select {
  font: inherit;
}

.kh-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
}

.kh-header {
  background: #ffffff;
  border-bottom: 1px solid var(--kh-border);
}

.kh-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
}

.kh-logo {
  height: 72px;
  width: auto;
}

.kh-login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 80px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(4px);
  z-index: 20;
}

.kh-login__card {
  width: min(420px, 100%);
  background: #ffffff;
  border-radius: var(--kh-radius);
  border: 1px solid var(--kh-border);
  box-shadow: var(--kh-shadow-soft);
  padding: 32px;
  text-align: center;
}

.kh-login__logo {
  height: 120px;
  width: auto;
  margin: 0 auto 16px;
}

.kh-login__title {
  font-size: 22px;
  font-weight: 600;
}

.kh-login__subtitle {
  margin-top: 8px;
  color: var(--kh-text-muted);
  font-size: 14px;
}

.kh-login__form {
  margin-top: 20px;
  display: grid;
  gap: 16px;
  text-align: left;
}

.kh-auth-locked #main-content {
  filter: grayscale(0.9) blur(2px);
  pointer-events: none;
}

.kh-auth-locked .kh-nav,
.kh-auth-locked .kh-user,
.kh-auth-locked #page-footer {
  opacity: 0.4;
  pointer-events: none;
}

.kh-alert {
  margin-top: 24px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--kh-border);
  background: #fafafa;
  color: var(--kh-text-muted);
  font-size: 14px;
}

.kh-nav {
  display: flex;
  gap: 18px;
  font-size: 14px;
  color: var(--kh-text-muted);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kh-nav a {
  padding: 4px 8px;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}

.kh-nav a:hover,
.kh-nav a.is-active {
  background: #f7f7f7;
  color: var(--kh-text);
}

.kh-user {
  font-size: 13px;
  color: var(--kh-text-muted);
  white-space: nowrap;
}

.kh-main {
  padding: 40px 0 72px;
}

.kh-hero {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: center;
  background: var(--kh-bg-soft);
  border: 1px solid var(--kh-border);
  border-radius: var(--kh-radius);
  padding: 28px 32px;
  box-shadow: var(--kh-shadow-soft);
}

.kh-hero__title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.kh-hero__subtitle {
  color: var(--kh-text-muted);
  max-width: 520px;
}

.kh-button {
  border: none;
  background: var(--kh-accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease, transform 0.2s ease;
}

.kh-button:hover {
  background: #b36f40;
  transform: translateY(-1px);
}

.kh-button--ghost {
  background: #ffffff;
  color: var(--kh-text);
  border: 1px solid var(--kh-border);
  box-shadow: none;
}

.kh-button--ghost:hover {
  background: #f7f7f7;
  transform: translateY(-1px);
}

.kh-summary {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.kh-card {
  background: #ffffff;
  border-radius: var(--kh-radius);
  border: 1px solid var(--kh-border);
  padding: 20px 22px;
  box-shadow: var(--kh-shadow-soft);
}

.kh-card__label {
  font-size: 12px;
  color: var(--kh-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.kh-card__value {
  font-size: 28px;
  font-weight: 600;
  margin-top: 6px;
}

.kh-card__desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--kh-text-muted);
}

.kh-panel {
  margin-top: 32px;
  background: #ffffff;
  border: 1px solid var(--kh-border);
  border-radius: var(--kh-radius);
  padding: 22px 24px;
  box-shadow: var(--kh-shadow-soft);
}


.kh-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.kh-panel__title {
  font-size: 18px;
  font-weight: 600;
}

.kh-panel__subtitle {
  font-size: 14px;
  color: var(--kh-text-muted);
}

.kh-filters {
  display: flex;
  gap: 12px;
}

.kh-select {
  border: 1px solid var(--kh-border);
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  color: var(--kh-text-muted);
}

.kh-input--compact {
  min-width: 180px;
}

.kh-form {
  display: grid;
  gap: 20px;
}

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

.kh-field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--kh-text-muted);
}

.kh-field span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.kh-input {
  border: 1px solid var(--kh-border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--kh-text);
}

.kh-input:focus {
  outline: 2px solid rgba(194, 129, 82, 0.2);
  border-color: var(--kh-accent);
}

.kh-form-section {
  display: grid;
  gap: 12px;
}

.kh-section-title {
  font-weight: 600;
}

.kh-section-subtitle {
  color: var(--kh-text-muted);
  font-size: 13px;
}

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

.kh-form-message {
  font-size: 13px;
  color: var(--kh-text-muted);
}

.kh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.kh-table th {
  text-align: left;
  color: var(--kh-text-muted);
  font-weight: 600;
  padding: 12px 0;
}

.kh-table td {
  padding: 14px 0;
  border-top: 1px solid var(--kh-border);
}

.kh-table__row {
  cursor: pointer;
  transition: background 0.2s ease;
}

.kh-table__row:hover {
  background: #fafafa;
}

.kh-table--line-items td,
.kh-table--line-items th {
  padding-right: 16px;
}

.kh-table--line-items input,
.kh-table--line-items select,
.kh-table--line-items textarea {
  width: 100%;
  border: 1px solid var(--kh-border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

.kh-table--line-items textarea {
  min-height: 44px;
  resize: vertical;
}

.kh-table--documents td {
  vertical-align: top;
}

.kh-table--documents tr.is-trashed {
  opacity: 0.5;
}

.kh-doc-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kh-doc-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #f5f5f5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--kh-accent);
}

.kh-doc-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.kh-doc-meta {
  color: var(--kh-text-muted);
  font-size: 12px;
}

.kh-job__name {
  font-weight: 600;
}

.kh-job__meta {
  color: var(--kh-text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.kh-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 600;
  background: #ffffff;
}

.kh-pill--stage {
  color: var(--kh-accent);
}

.kh-pill--ok {
  color: var(--kh-pill-ok);
}

.kh-pill--watch {
  color: var(--kh-pill-watch);
}

.kh-pill--risk {
  color: var(--kh-pill-risk);
}

.kh-footer {
  padding: 24px 0 36px;
  color: var(--kh-text-muted);
  font-size: 13px;
  border-top: 1px solid var(--kh-border);
  background: #f5f5f5;
  text-align: center;
}

.kh-footer__inner {
  display: grid;
  gap: 6px;
}

.kh-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.kh-detail-title {
  font-size: 24px;
  font-weight: 600;
}

.kh-detail-subtitle {
  color: var(--kh-text-muted);
  margin-top: 6px;
}

.kh-detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kh-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.kh-panel__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.kh-panel__list-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.kh-panel__list-item span {
  color: var(--kh-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.kh-note {
  margin-top: 12px;
  color: var(--kh-text-muted);
  font-size: 13px;
}

.kh-milestones {
  list-style: none;
  margin-top: 16px;
  display: grid;
  gap: 16px;
}

.kh-milestone {
  position: relative;
  padding-left: 26px;
}

.kh-milestone::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--kh-accent);
  position: absolute;
  left: 2px;
  top: 7px;
}

.kh-milestone--done::before {
  content: "✓";
  font-size: 10px;
  color: #fff;
  background: var(--kh-pill-ok);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  top: 2px;
  left: 0;
}

.kh-milestone__title {
  font-weight: 600;
}

.kh-milestone__date {
  color: var(--kh-text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.kh-empty {
  background: var(--kh-bg-soft);
  border-radius: var(--kh-radius);
  border: 1px dashed var(--kh-border);
  padding: 36px;
  text-align: center;
}

.kh-link {
  color: var(--kh-accent);
  font-weight: 600;
}

.kh-documents {
  list-style: none;
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.kh-documents li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--kh-border);
}

.kh-documents li.is-trashed {
  opacity: 0.5;
}

.kh-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--kh-text-muted);
}

.kh-toggle input {
  accent-color: var(--kh-accent);
}

.kh-documents a {
  color: var(--kh-text);
}

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

@media (max-width: 960px) {
  .kh-header__inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .kh-user {
    order: 2;
  }

  .kh-nav {
    order: 3;
    justify-content: flex-start;
  }

  .kh-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .kh-summary {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .kh-panel__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .kh-filters {
    width: 100%;
    flex-wrap: wrap;
  }

  .kh-table {
    font-size: 13px;
  }

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

  .kh-panel__list {
    grid-template-columns: 1fr;
  }

  .kh-form-grid {
    grid-template-columns: 1fr;
  }
}
