:root {
  color-scheme: light;
  --ink: #1b2526;
  --muted: #61706f;
  --line: #d7e2df;
  --paper: #fbfdfb;
  --wash: #eef5f2;
  --mint: #2f8f76;
  --mint-dark: #176a57;
  --coral: #c95642;
  --gold: #a66b1f;
  --blue: #2f6f9f;
  --shadow: 0 18px 48px rgba(25, 55, 48, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(47, 143, 118, 0.14), transparent 34%),
    linear-gradient(225deg, rgba(201, 86, 66, 0.12), transparent 30%),
    var(--wash);
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 20px 14px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 2px 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.date-pill,
.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.date-pill {
  transform: translateY(-8px);
}

.date-pill input,
.field input,
.field select {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.date-pill input:focus,
.field input:focus,
.field select:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(47, 143, 118, 0.14);
}

.entry-panel,
.daily-panel,
.report-panel,
.log-panel,
.recognition-panel {
  background: rgba(251, 253, 251, 0.86);
  border: 1px solid rgba(215, 226, 223, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.ward-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.ward-tab,
.segment,
.project-chip,
.preset-button,
.ghost-button,
.add-draft-button,
.charged-button,
.primary-button,
.secondary-button,
.delete-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.ward-tab {
  min-height: 44px;
  font-weight: 700;
}

.ward-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.entry-panel,
.daily-panel,
.report-panel,
.log-panel,
.recognition-panel {
  padding: 16px;
  margin-bottom: 14px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.entry-panel .section-heading {
  align-items: center;
  min-height: 34px;
}

#toggleEntryPanel {
  margin-right: 12px;
}

.section-heading p,
.muted-label {
  color: var(--muted);
  font-size: 12px;
}

.daily-changes {
  display: grid;
  gap: 7px;
}

.daily-empty {
  min-height: 76px;
  font-size: 15px;
  font-weight: 800;
}

.ward-change-group {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(215, 226, 223, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.ward-change-group h3 {
  margin: 0;
  font-size: 14px;
}

.ward-empty {
  color: var(--muted);
  font-size: 13px;
}

.change-lines {
  display: grid;
  gap: 5px;
  transition: gap 120ms ease-out;
}

.is-dragging-entry .change-lines {
  gap: 8px;
}

.is-dragging-entry {
  user-select: none;
  -webkit-user-select: none;
}

.change-line {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  padding: 5px 7px;
  border-radius: 8px;
  background: rgba(238, 245, 242, 0.78);
  transition:
    background-color 120ms ease-out,
    box-shadow 120ms ease-out,
    outline-color 120ms ease-out,
    opacity 120ms ease-out,
    transform 120ms ease-out;
  will-change: transform;
}

.change-line.editing-line {
  background: rgba(238, 245, 242, 0.42);
}

.change-line.moving-line {
  background: rgba(255, 245, 219, 0.95);
  outline: 1px solid rgba(166, 107, 31, 0.24);
}

.change-line.drag-source-line {
  opacity: 0.38;
}

.change-line.drag-over-before,
.change-line.drag-over-after {
  background: rgba(222, 236, 229, 0.98);
  outline: 1px solid rgba(94, 132, 122, 0.34);
  transform: scale(1.008);
}

.change-line.drag-over-before {
  box-shadow: 0 -8px 0 rgba(94, 132, 122, 0.18);
}

.change-line.drag-over-after {
  box-shadow: 0 8px 0 rgba(94, 132, 122, 0.18);
}

.change-line.drag-over-before::before,
.change-line.drag-over-after::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  z-index: 4;
  height: 6px;
  border-radius: 999px;
  background: #5e847a;
  box-shadow: 0 3px 10px rgba(61, 80, 75, 0.22);
}

.change-line.drag-over-before::before {
  top: -10px;
}

.change-line.drag-over-after::after {
  bottom: -10px;
}

.drag-floating-line {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.82;
  outline: 1px solid rgba(94, 132, 122, 0.24);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 34px rgba(61, 80, 75, 0.26);
  transform: scale(1.045) rotate(-0.6deg);
  transform-origin: center;
  will-change: transform;
  backface-visibility: hidden;
  contain: layout paint style;
  filter: saturate(1.04);
}

.change-line.editing-line .change-text {
  color: rgba(97, 112, 111, 0.68);
}

.change-line.editing-line em {
  color: rgba(97, 112, 111, 0.82);
}

.change-line span {
  min-width: 0;
  font-size: 14px;
  line-height: 1.35;
}

.change-text {
  flex: 1;
  display: inline;
  word-spacing: 0.28em;
}

.bed-label {
  font-weight: 400;
}

.change-line em {
  color: var(--ink);
  font-style: normal;
  font-weight: 900;
  margin: 0 0.75em;
}

.change-line em.neutral {
  color: var(--ink);
}

.change-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.visibility-tools {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

#dailyRestorePopover,
#tomorrowRestorePopover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
}

.visibility-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 4px 7px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.restore-popover {
  width: min(82vw, 340px);
  padding: 9px;
  border: 1px solid rgba(215, 226, 223, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(25, 55, 48, 0.16);
}

.restore-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 7px;
}

.restore-options {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.restore-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 8px;
  background: rgba(238, 245, 242, 0.78);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
}

.restore-option.selected,
.change-line.selected {
  background: rgba(217, 232, 226, 0.95);
}

.restore-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 2px 2px;
}

.visibility-done {
  width: 54px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.visibility-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0;
  font-weight: 800;
}

.visibility-check input {
  width: 16px;
  height: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.draft-list {
  display: grid;
  gap: 12px;
}

.entry-panel.collapsed .draft-list {
  display: none;
}

.entry-panel.collapsed .section-heading {
  margin-bottom: 0;
}

.draft-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(215, 226, 223, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.draft-card-head,
.draft-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.draft-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.draft-row .field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.draft-row .field span {
  font-size: 15px;
}

.draft-row .field input,
.draft-row .field select {
  min-height: 38px;
  padding: 0 10px;
  font-size: 15px;
}

.draft-controls {
  display: grid;
  gap: 10px;
}

.add-draft-button {
  width: 42px;
  height: 42px;
  background: var(--ink);
  border-color: var(--ink);
  color: white;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.hidden {
  display: none;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.action-segments {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stop-type-row {
  width: calc((100% - 18px) / 4);
  margin-left: calc((100% - 18px) / 4 + 6px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.segment {
  min-height: 44px;
  padding: 0 6px;
  font-weight: 700;
}

.stop-type-button {
  min-height: 34px;
  border: 1px solid rgba(201, 86, 66, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--coral);
  font-size: 12px;
  font-weight: 800;
}

.stop-type-button.active {
  background: rgba(201, 86, 66, 0.14);
  border-color: rgba(201, 86, 66, 0.72);
}

.segment.active[data-action="start"],
.segment.active[data-action="restore"] {
  background: rgba(47, 143, 118, 0.14);
  border-color: var(--mint);
  color: var(--mint-dark);
}

.segment.active[data-action="stop"] {
  background: rgba(201, 86, 66, 0.14);
  border-color: var(--coral);
  color: var(--coral);
}

.segment.active[data-action="pause"] {
  background: rgba(47, 111, 159, 0.13);
  border-color: var(--blue);
  color: var(--blue);
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 4px 0 0;
}

.preset-button {
  min-height: 34px;
  padding: 0 4px;
  border-color: rgba(97, 112, 111, 0.12);
  background: rgba(97, 112, 111, 0.025);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.project-chip {
  position: relative;
  min-height: 46px;
  padding: 6px 4px;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.project-chip span {
  grid-area: 1 / 1;
}

.project-chip .project-suffix {
  font-weight: 400;
}

.project-chip small {
  position: absolute;
  right: 4px;
  top: 4px;
  color: var(--mint-dark);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.project-chip.active.action-stop,
.project-chip.active.action-pause {
  background: rgba(201, 86, 66, 0.13);
  border-color: rgba(201, 86, 66, 0.65);
  color: var(--coral);
}

.project-chip.active.action-start,
.project-chip.active.action-restore {
  background: rgba(47, 143, 118, 0.13);
  border-color: rgba(47, 143, 118, 0.65);
  color: var(--mint-dark);
}

.project-chip.charged {
  background: rgba(47, 143, 118, 0.18);
  border-color: var(--mint);
  color: var(--mint-dark);
  box-shadow: inset 0 0 0 1px rgba(47, 143, 118, 0.22);
}

.project-chip.charged.action-start {
  background: rgba(201, 86, 66, 0.13);
  border-color: rgba(201, 86, 66, 0.65);
  color: var(--coral);
  box-shadow: inset 0 0 0 1px rgba(201, 86, 66, 0.18);
}

.project-chip.charged.action-start small {
  color: var(--coral);
}

.charged-button {
  min-height: 36px;
  justify-self: start;
  padding: 0 14px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
}

.charged-button.active {
  background: rgba(47, 143, 118, 0.14);
  border-color: var(--mint);
  color: var(--mint-dark);
}

.charged-button.active.action-start {
  background: rgba(201, 86, 66, 0.13);
  border-color: rgba(201, 86, 66, 0.65);
  color: var(--coral);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  min-height: 50px;
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.secondary-button {
  width: 100%;
  margin-top: 10px;
  background: white;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
}

.compact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  min-width: 50px;
  min-height: 34px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.compact-delete {
  width: 46px;
  min-width: 46px;
  height: 32px;
  font-size: 13px;
}

.move-button {
  width: 34px;
  min-width: 34px;
  font-size: 18px;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.move-button:active {
  cursor: grabbing;
}

.clear-button {
  font-size: 14px;
}

.restore-draft-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.editing-badge {
  color: #c95642;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.moving-badge {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.complete-button {
  margin-top: 0;
}

.summary-table {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.summary-ward-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: -4px 0 12px;
}

.summary-ward-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.summary-ward-tab.active {
  background: rgba(47, 111, 159, 0.13);
  border-color: var(--blue);
  color: var(--blue);
}

.summary-card {
  position: relative;
  min-height: 68px;
  padding: 9px 42px 8px 9px;
  border: 1px solid rgba(215, 226, 223, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.summary-card-title {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.short-name {
  display: grid;
  place-items: center;
  width: max-content;
  min-width: 34px;
  height: 27px;
  padding: 0 4px;
  border-radius: 8px;
  background: rgba(47, 143, 118, 0.12);
  color: var(--mint-dark);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.full-name {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delta {
  position: absolute;
  right: 9px;
  font-weight: 900;
  font-size: 14px;
  line-height: 1;
}

.delta.plus {
  top: 9px;
  color: var(--mint-dark);
}

.delta.minus {
  bottom: 9px;
  color: var(--coral);
}

.change-pair {
  display: contents;
}

.summary-empty {
  grid-column: 1 / -1;
  min-height: 58px;
}

.entry-list {
  display: grid;
  gap: 8px;
}

.entry-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.entry-main {
  display: grid;
  gap: 5px;
}

.entry-title {
  font-weight: 900;
}

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

.delete-button {
  width: 42px;
  height: 38px;
  color: var(--coral);
  font-weight: 900;
}

.hidden-file {
  display: none;
}

.recognition-textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
}

.recognition-textarea:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(47, 143, 118, 0.14);
}

.recognition-button {
  margin-top: 10px;
}

.recognition-result {
  min-height: 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.empty-state {
  min-height: 52px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 24px;
  }

  .date-pill {
    width: 142px;
  }

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

  .preset-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .summary-table {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-inline: 10px;
  }

  .entry-panel,
  .daily-panel,
  .report-panel,
  .log-panel,
  .recognition-panel {
    padding: 12px;
  }

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

  .draft-row {
    grid-template-columns: 0.86fr 1fr;
  }

  .summary-table {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ward-tabs {
    gap: 5px;
  }
}
