:root {
  color-scheme: light;
  --ink: #17191f;
  --muted: #737984;
  --muted-dark: #565d68;
  --surface: #ffffff;
  --surface-soft: #f8f8fa;
  --canvas: #f4f5f7;
  --line: #e7e8ec;
  --line-strong: #d8dae0;
  --accent: #f04438;
  --accent-dark: #cc2e24;
  --accent-soft: #fff0ee;
  --green: #16845b;
  --green-soft: #eaf8f1;
  --shadow: 0 12px 34px rgba(21, 24, 32, 0.07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--canvas); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(240, 68, 56, 0.07), transparent 30%),
    var(--canvas);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(34px, env(safe-area-inset-bottom));
}
.hero {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 5px 5px 19px;
}
.brand-mark {
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 15px;
  color: white;
  background: linear-gradient(145deg, #ff6555, #e8372c);
  box-shadow: 0 8px 18px rgba(240, 68, 56, 0.24);
  font-size: 20px;
  font-weight: 900;
}
.hero-copy { min-width: 0; }
.eyebrow {
  margin-bottom: 3px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
h1 { margin: 0; font-size: 23px; line-height: 1.2; letter-spacing: -0.03em; }
.hero p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.panel { padding: 0; }
.employee-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(21, 24, 32, 0.035);
}
.employee-copy { display: flex; min-width: 0; align-items: center; gap: 10px; }
.employee-copy > div { display: grid; min-width: 0; gap: 2px; }
.employee-copy small { color: var(--muted); font-size: 10px; font-weight: 700; }
.employee-copy span:not(.employee-dot) { overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.employee-dot {
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.employee-row strong {
  flex: 0 0 auto;
  max-width: 42%;
  overflow: hidden;
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--ink);
  background: #f0f1f3;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab-list {
  position: sticky;
  z-index: 10;
  top: max(8px, env(safe-area-inset-top));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 12px 0;
  padding: 4px;
  border: 1px solid rgba(223, 225, 230, 0.92);
  border-radius: 16px;
  background: rgba(236, 237, 240, 0.9);
  box-shadow: 0 5px 18px rgba(21, 24, 32, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.tab-button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  color: var(--muted-dark);
  background: transparent;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.tab-button.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 3px 10px rgba(21, 24, 32, 0.08);
}
.tab-button:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(240, 68, 56, 0.2);
  outline-offset: 2px;
}
.tab-panel { scroll-margin-top: 78px; }
.entry-card {
  padding: 20px;
  border: 1px solid rgba(231, 232, 236, 0.92);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.section-heading, .history-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.section-heading { margin-bottom: 21px; }
.section-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
}
.section-heading h2, .history-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.sync-badge, .history-hint {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}
.sync-badge { color: var(--green); background: var(--green-soft); }
.history-hint { color: var(--muted-dark); background: #e9eaed; }
.field-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 18px 0 5px;
  font-size: 13px;
  font-weight: 800;
}
.section-heading + .field-label { margin-top: 0; }
.field-label > span {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 7px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 900;
}
.field-help { margin: 0 0 9px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-group { min-width: 0; }
input[type="date"], input[type="number"], textarea {
  width: 100%;
  min-height: 52px;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface-soft);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
input[type="number"] { font-size: 22px; font-weight: 800; }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #a3a7ae; }
input:focus, textarea:focus {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.1);
}
.primary-button {
  display: flex;
  width: 100%;
  min-height: 52px;
  margin-top: 22px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, #f65447, var(--accent));
  box-shadow: 0 9px 20px rgba(240, 68, 56, 0.2);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.primary-button::after { content: "→"; font-size: 17px; line-height: 1; }
.primary-button:hover { background: linear-gradient(135deg, #f04438, var(--accent-dark)); }
.primary-button:active { transform: translateY(1px); box-shadow: 0 5px 14px rgba(240, 68, 56, 0.18); }
button:disabled { cursor: wait; opacity: 0.58; }
.status {
  min-height: 20px;
  margin: 11px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}
.status:empty { min-height: 0; margin-top: 0; }
.status.error { color: #b42318; }
.status.success { color: var(--green); }
.history-section { margin-top: 25px; }
.history-section > .status { text-align: left; }
.history-list { display: grid; gap: 10px; margin-top: 10px; }
.history-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 5px 18px rgba(21, 24, 32, 0.035);
}
.history-card > header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.history-card > header > * { min-width: 0; }
.history-card > header span { color: var(--green); font-size: 11px; font-weight: 800; }
.history-summary { margin: 10px 0 0; color: var(--ink); font-size: 15px; font-weight: 700; line-height: 1.5; }
.record-link {
  overflow: hidden;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-link.unavailable { color: var(--muted); background: #eff0f2; }
.history-card > header .record-number {
  max-width: 48%;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-label { display: block; margin: 14px 0 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.record-comment { min-height: 72px; background: var(--surface-soft); font-size: 13px; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.secondary-button, .danger-button {
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 11px;
  background: white;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.secondary-button { border: 1px solid #20232a; color: #20232a; }
.danger-button { border: 1px solid #efc7c2; color: #b42318; background: #fffafa; }
.comment-card > .status { margin-top: 8px; }
.empty-state {
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: white;
  box-shadow: var(--shadow);
  text-align: center;
}
.empty-state h2 { margin-top: 0; }
.empty-state p { margin-bottom: 0; color: var(--muted); line-height: 1.6; }
footer { padding: 22px 6px 0; color: #8a8f98; text-align: center; font-size: 11px; line-height: 1.6; }

@media (max-width: 380px) {
  .shell { padding-right: 11px; padding-left: 11px; }
  .entry-card { padding: 17px; border-radius: 20px; }
  .hero { padding-right: 3px; padding-left: 3px; }
  .history-card { padding: 13px; }
}

@media (min-width: 640px) {
  .shell { padding-top: 34px; }
}

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