:root {
  color-scheme: light;
  --bg: #fff8ea;
  --surface: #ffffff;
  --ink: #24302f;
  --muted: #5f6b5b;
  --line: #d9d0bd;
  --primary: #4f6f45;
  --primary-dark: #385631;
  --accent: #8fae45;
  --warm: #c9b28a;
  --sun: #e8be4e;
  --soft: #f1f6e8;
  --warn: #f4e4bd;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(246, 247, 244, 0.96);
  padding: 18px;
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 60px rgb(36 48 47 / 0.12);
}

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

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--primary);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

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

.sync-banner {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  color: var(--muted);
  background: #fff;
}

.sync-banner:empty {
  display: none;
}

.sync-banner.ok {
  border-color: #b8d398;
  color: var(--primary-dark);
  background: #f4faeb;
}

.sync-banner.warn {
  border-color: var(--sun);
  color: #72510d;
  background: #fff4cf;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  font-size: 18px;
}

.top-actions,
.dialog-actions,
.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 16px;
}

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

.primary-button:hover {
  background: var(--primary-dark);
}

.danger-button {
  color: #9d2f22;
  border-color: #efb3aa;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  min-height: 32px;
  padding: 0 4px;
}

.icon-button {
  min-width: 42px;
  padding: 0 10px;
  font-weight: 700;
}

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

.stat,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 16px;
}

.stat span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.employee-section {
  min-width: 0;
}

.detail-panel {
  margin-top: 14px;
  border-color: #b9ca91;
  background: linear-gradient(180deg, #f4f8ea 0%, #fffdf8 46%);
  box-shadow: 0 14px 34px rgb(79 111 69 / 0.14);
}

.detail-panel:focus {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.detail-panel .panel-heading {
  border-bottom: 1px solid #cfdcab;
  padding-bottom: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.detail-item {
  border: 1px solid #d7c69e;
  border-radius: 8px;
  padding: 11px;
  min-height: 74px;
  background: #fffefa;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.detail-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-bottom: 10px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.document-list {
  display: grid;
  gap: 10px;
  margin: 10px 22px 22px;
}

.document-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #d7c69e;
  border-radius: 8px;
  padding: 12px;
  background: #fffefa;
}

.document-item h3 {
  margin: 6px 0 4px;
  font-size: 16px;
}

.timeline-item h3 {
  margin: 8px 0 4px;
  font-size: 16px;
}

.timeline-item p {
  margin: 0 0 5px;
}

.timeline-side {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 8px;
}

.download-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.download-link:hover {
  text-decoration: underline;
}

.file-current {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  margin: -2px 0 12px;
  font-size: 13px;
}

.selected-row {
  background: #f1f7f4;
}

.panel {
  padding: 16px;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

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

.employee-table-wrap {
  max-height: min(640px, 58vh);
  overflow: auto;
}

.employee-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fffdf8;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.person {
  display: grid;
  gap: 3px;
}

.person strong {
  font-size: 15px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--soft);
  color: var(--primary-dark);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.badge.warn {
  background: var(--warn);
  color: #8a4a12;
}

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

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

dialog {
  border: 0;
  border-radius: 10px;
  padding: 0;
  width: min(920px, calc(100% - 22px));
  max-height: calc(100vh - 28px);
  overflow: auto;
}

dialog::backdrop {
  background: rgb(20 30 28 / 0.45);
}

.dialog-card {
  padding: 0;
  background: #fffdf8;
}

.dialog-card > .panel-heading {
  margin: 0;
  padding: 18px 22px;
  background: var(--primary);
  color: #fff;
}

.dialog-card > .panel-heading .muted {
  color: #f5eddc;
}

.dialog-card > .panel-heading .icon-button {
  background: #fffdf8;
  color: var(--primary-dark);
  border-color: #fffdf8;
}

.dialog-card > .form-grid,
.dialog-card > label,
.dialog-card > .file-current,
.dialog-card > .section-title {
  margin-left: 22px;
  margin-right: 22px;
}

.dialog-card > .form-grid {
  padding-top: 16px;
}

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

.dialog-card label {
  color: var(--primary-dark);
}

.dialog-card input,
.dialog-card select,
.dialog-card textarea {
  border-color: #cfc3a9;
  background: #fffefa;
}

.dialog-card input:focus,
.dialog-card select:focus,
.dialog-card textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgb(143 174 69 / 0.2);
}

.dialog-card select:disabled {
  background: #eef5df;
  border-color: #b7cd82;
  color: var(--primary-dark);
  opacity: 1;
}

.money-grid {
  display: grid;
  grid-template-columns: 90px repeat(3, minmax(130px, 1fr));
  gap: 6px;
  margin: 4px 22px 16px;
  padding: 12px;
  border: 1px solid #d8c598;
  border-radius: 8px;
  background: #fff6d9;
}

.money-head {
  min-height: 30px;
  display: flex;
  align-items: end;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  padding: 0 4px;
}

.money-caption {
  margin: 8px 22px 6px;
  color: var(--primary-dark);
  font-weight: 700;
}

.money-grid input {
  min-height: 38px;
  padding: 8px 10px;
  text-align: right;
  background: #fffefa;
  border-color: #cfbf95;
  font-weight: 700;
}

.money-grid input[readonly] {
  background: #eef5df;
  border-color: #b7cd82;
  color: var(--primary-dark);
  cursor: default;
}

.money-grid input[readonly]:focus {
  outline: 0;
  border-color: #b7cd82;
}

.dialog-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 16px 22px 18px;
  background: #f7ecd2;
  border-top: 1px solid #ddcda7;
  box-shadow: 0 -10px 24px rgb(79 111 69 / 0.12);
}

.spacer {
  flex: 1;
}

@media (max-width: 820px) {
  .topbar,
  .workspace,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

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

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

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

  .timeline-side {
    justify-items: start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 14px;
  }

  .stats-grid,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    flex-wrap: wrap;
  }

  .money-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-left: 12px;
    margin-right: 12px;
  }

  .dialog-card > .panel-heading,
  .dialog-actions {
    padding-left: 12px;
    padding-right: 12px;
  }

  .dialog-card > .form-grid,
  .dialog-card > label,
  .dialog-card > .file-current,
  .dialog-card > .section-title {
    margin-left: 12px;
    margin-right: 12px;
  }

  .dialog-actions button {
    flex: 1 1 120px;
  }
}
