:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #20231d;
  background: #f4f1e9;
  font-size: 16px;
  font-synthesis: none;
  --ink: #20231d;
  --muted: #686d62;
  --surface: #fffefa;
  --surface-soft: #f4f1e9;
  --line: #dddcd3;
  --forest: #275b3a;
  --forest-dark: #18241d;
  --forest-soft: #e5eee5;
  --gold: #f2be30;
  --danger: #a33a36;
  --shadow: 0 12px 34px rgba(31, 35, 28, .07);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 95% 0, rgba(242, 190, 48, .12), transparent 24rem),
    var(--surface-soft);
}

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

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 70px;
  padding: max(.7rem, env(safe-area-inset-top)) clamp(1rem, 3vw, 2rem) .7rem;
  gap: .8rem;
  align-items: center;
  color: white;
  background: rgba(24, 36, 29, .97);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  margin-right: auto;
  gap: .7rem;
  align-items: center;
  color: white;
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #171914;
  background: var(--gold);
  border-radius: 12px;
  font-size: .78rem;
  letter-spacing: -.04em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12);
}

.brand-name { font-size: 1.05rem; letter-spacing: -.02em; }
.brand-name span { color: #c5d0c7; font-weight: 450; }

.header-actions { display: flex; gap: .55rem; align-items: center; }

#identity {
  max-width: 15rem;
  overflow: hidden;
  color: #cbd3cd;
  font-size: .76rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-toggle { display: none; }

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

nav {
  position: sticky;
  top: 70px;
  display: flex;
  height: calc(100vh - 70px);
  height: calc(100dvh - 70px);
  padding: 1.25rem 1rem 2rem;
  flex-direction: column;
  gap: .3rem;
  overflow-y: auto;
  background: rgba(247, 245, 238, .72);
  border-right: 1px solid var(--line);
}

nav::before {
  margin: .25rem .75rem .65rem;
  content: "HR workspace";
  color: #85897f;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

nav a {
  display: flex;
  min-height: 44px;
  padding: .68rem .75rem;
  align-items: center;
  color: #3f463d;
  border-radius: 11px;
  font-size: .86rem;
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
}

nav a:hover { background: rgba(255, 255, 255, .72); }

nav a[aria-current="page"] {
  color: #173d26;
  background: var(--forest-soft);
  box-shadow: inset 3px 0 0 var(--forest);
}

main {
  width: 100%;
  max-width: 1320px;
  padding: clamp(2rem, 4vw, 3.75rem);
  overflow: hidden;
}

main:focus { outline: none; }

h1, h2, h3 { color: var(--ink); letter-spacing: -.025em; }

h1 {
  max-width: 800px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.15rem, 4.5vw, 4rem);
  font-weight: 600;
  line-height: 1.03;
}

h1 + .muted {
  max-width: 680px;
  margin: .75rem 0 2rem;
  font-size: .95rem;
}

h2 { margin: 2rem 0 .8rem; font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { line-height: 1.55; }

button, .button {
  display: inline-flex;
  min-height: 44px;
  padding: .65rem .95rem;
  align-items: center;
  justify-content: center;
  color: #27382d;
  background: var(--surface);
  border: 1px solid #aeb5ad;
  border-radius: 10px;
  font: inherit;
  font-size: .85rem;
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

button:hover, .button:hover { background: #f0f3ed; border-color: #7f8c82; }
button:active, .button:active { transform: scale(.98); }

.header-link {
  min-height: 40px;
  padding: .5rem .75rem;
  color: white;
  background: transparent;
  border-color: #66776c;
}

.header-link:hover { background: rgba(255, 255, 255, .08); border-color: #94a197; }

button.primary {
  color: white;
  background: var(--forest);
  border-color: var(--forest);
  box-shadow: 0 6px 16px rgba(39, 91, 58, .16);
}

button.primary:hover { background: #1f4c30; border-color: #1f4c30; }
button.danger { color: var(--danger); border-color: #d7aaa7; }
button:disabled { opacity: .55; cursor: wait; transform: none; }

button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid #d69420;
  outline-offset: 2px;
}

.toolbar {
  display: flex;
  margin: 1rem 0;
  gap: .55rem;
  flex-wrap: wrap;
  align-items: center;
}

.tabs {
  margin: 1.35rem 0 1.5rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--line);
}

[role="tab"][aria-selected="true"] {
  color: #173d26;
  background: var(--forest-soft);
  border-color: #7c9b83;
}

.card, fieldset {
  min-width: 0;
  margin: 0 0 1rem;
  padding: 1.25rem;
  background: rgba(255, 254, 250, .94);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

fieldset { padding-top: 1.35rem; }
form > fieldset { margin-bottom: 1rem; }
form.card { max-width: 920px; }
form.card > h2:first-child { margin-top: 0; }
form > button { margin-top: .25rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.metric {
  position: relative;
  min-height: 126px;
  padding: 1.15rem;
  overflow: hidden;
}

.metric::after {
  position: absolute;
  width: 78px;
  height: 78px;
  right: -30px;
  bottom: -42px;
  content: "";
  background: var(--gold);
  border-radius: 50%;
  opacity: .2;
}

.metric span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: .7rem;
  color: #183c25;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.35rem;
  font-weight: 600;
  line-height: 1;
}

form .grid { gap: 1rem; }

label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: .4rem;
  color: #4e554c;
  font-size: .78rem;
  font-weight: 750;
}

.field-label {
  display: inline-flex;
  gap: .22rem;
  align-items: baseline;
}

.required-marker {
  color: var(--danger);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: .72rem .8rem;
  color: var(--ink);
  background: white;
  border: 1px solid #aab1a8;
  border-radius: 10px;
  font: inherit;
  font-size: 16px;
}

select { padding-right: 2rem; }
textarea { min-height: 110px; resize: vertical; }

.check-field {
  min-height: 48px;
  padding: .65rem .75rem;
  flex-direction: row;
  gap: .7rem;
  align-items: center;
  background: #f5f6f2;
  border: 1px solid #dde0d8;
  border-radius: 10px;
}

.check-field input[type="checkbox"] {
  width: 24px;
  height: 24px;
  min-height: 24px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--forest);
}

legend {
  padding: 0 .4rem;
  color: #30372f;
  font-size: .85rem;
  font-weight: 850;
}

.table-wrap {
  width: 100%;
  margin-bottom: 1rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}

caption {
  padding: 1rem;
  color: #333a32;
  font-weight: 800;
  text-align: left;
}

th, td {
  padding: .8rem 1rem;
  overflow-wrap: anywhere;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid #e5e4dd;
}

th {
  color: #596057;
  background: #f2f3ee;
  font-size: .7rem;
  font-weight: 850;
  letter-spacing: .055em;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }
td button { min-height: 38px; padding: .48rem .7rem; }

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

.error, [role="alert"] {
  padding: 1rem;
  color: #802a27;
  background: #fff0ed;
  border: 1px solid #ecc4be;
  border-radius: 12px;
}

#notice {
  position: fixed;
  z-index: 40;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: none;
  width: min(390px, calc(100vw - 2rem));
  padding: 1rem 1.1rem;
  color: white;
  background: #20372a;
  border-radius: 12px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, .22);
  font-size: .88rem;
}

.empty { padding: 2rem; color: var(--muted); text-align: center; }

.pill {
  display: inline-flex;
  padding: .3rem .65rem;
  color: #235033;
  background: #e4efe2;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
}

dl {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 2fr;
  gap: .8rem 1rem;
}

dt { color: var(--muted); font-size: .78rem; font-weight: 750; }
dd { margin: 0; overflow-wrap: anywhere; }
pre { max-width: 100%; padding: 1rem; overflow: auto; background: #20251f; color: #eef2eb; border-radius: 12px; }
.phase4-workspace { min-height: 12rem; }
.phase4-workspace .empty { margin-top: 1rem; }

@media (max-width: 820px) {
  body.nav-open { overflow: hidden; }
  body::after {
    position: fixed;
    z-index: 18;
    inset: 0;
    content: "";
    background: rgba(12, 17, 13, .48);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  body.nav-open::after { opacity: 1; pointer-events: auto; }
  .app-header { min-height: 64px; padding-right: .75rem; padding-left: .75rem; }
  .brand { gap: .55rem; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand-name { font-size: .95rem; }
  .header-link {
    width: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 0;
  }
  .header-link::before { content: "⌂"; font-size: 1.2rem; line-height: 1; }
  .menu-toggle {
    display: inline-grid;
    width: 42px;
    min-height: 42px;
    padding: 0;
    place-items: center;
    color: white;
    background: transparent;
    border-color: #66776c;
    font-size: 1.2rem;
  }
  .shell { display: block; min-height: calc(100dvh - 64px); }
  nav {
    position: fixed;
    z-index: 19;
    top: 0;
    left: 0;
    width: min(86vw, 330px);
    height: 100vh;
    height: 100dvh;
    padding: calc(75px + env(safe-area-inset-top)) .8rem max(1.5rem, env(safe-area-inset-bottom));
    background: #f8f6ef;
    border: 0;
    box-shadow: 18px 0 44px rgba(12, 17, 13, .18);
    transform: translateX(-105%);
    transition: transform .22s ease;
  }
  body.nav-open nav { transform: translateX(0); }
  nav a { min-height: 48px; padding: .78rem; }
  main { padding: 2rem 1rem 3rem; }
  h1 { font-size: clamp(2rem, 10vw, 3rem); }
  h1 + .muted { margin-bottom: 1.5rem; }
  h2 { margin-top: 1.6rem; }
  .grid, form .grid { grid-template-columns: 1fr; }
  .card, fieldset { padding: 1rem; border-radius: 14px; }
  .metric { min-height: 104px; }
  .metric strong { font-size: 2rem; }
  .tabs {
    margin-right: -1rem;
    margin-left: -1rem;
    padding: 0 1rem .8rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { min-height: 46px; flex: 0 0 auto; scroll-snap-align: start; }
  form > button { width: 100%; min-height: 48px; }
  .table-wrap {
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  table, tbody { display: block; width: 100%; }
  thead { display: none; }
  caption { display: block; padding: .25rem 0 .7rem; }
  tbody { display: grid; gap: .75rem; }
  tr {
    display: block;
    padding: .45rem .85rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(31, 35, 28, .055);
  }
  td {
    display: grid;
    min-height: 38px;
    padding: .58rem 0;
    grid-template-columns: minmax(7rem, .8fr) minmax(0, 1.2fr);
    gap: .75rem;
    align-items: start;
    border-bottom: 1px solid #eceae3;
  }
  td::before {
    content: attr(data-label);
    color: #71766c;
    font-size: .68rem;
    font-weight: 850;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  tbody tr:last-child td { border-bottom: 1px solid #eceae3; }
  td:last-child { border-bottom: 0 !important; }
  td > button, td > .toolbar, td > div { width: 100%; }
  td button { min-height: 44px; }
  td .toolbar { display: grid; margin: 0; gap: .4rem; }
  dl { grid-template-columns: 1fr; gap: .25rem; }
  dd { margin-bottom: .75rem; }
  #app > button, [role="tabpanel"] > button, .phase4-workspace > button { margin: .25rem .4rem .25rem 0; }
  #notice { right: .75rem; bottom: max(.75rem, env(safe-area-inset-bottom)); width: calc(100vw - 1.5rem); }
}

@media (max-width: 480px) {
  #identity { display: none; }
  .brand-name span { display: none; }
  main { padding-top: 1.65rem; }
  td { grid-template-columns: minmax(6.5rem, .8fr) minmax(0, 1.2fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
