:root {
  --navy: #16233a;
  --navy-soft: #263955;
  --line: #d9e1ea;
  --line-soft: #e8eef4;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --blue: #1f5f99;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

button,
input,
textarea {
  font: inherit;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin-top: 0;
}

a {
  color: inherit;
}

.page-shell {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 12px;
}

.topbar,
.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px 16px;
  color: #fff;
  background: var(--navy);
  border-radius: 10px;
}

.topbar h1,
.detail-topbar h1 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.25;
}

.detail-topbar p {
  margin: 4px 0 0;
  color: #d7e1ee;
  font-size: 13px;
}

.today-label {
  display: grid;
  gap: 2px;
  justify-items: end;
  min-width: max-content;
}

.today-label span {
  color: #b9c7d8;
  font-size: 12px;
}

.today-label strong {
  font-size: 13px;
}

.mobile-stack {
  display: grid;
  gap: 12px;
}

.business-overview {
  display: grid;
  gap: 12px;
}

.overview-nav { text-align: right; }
.overview-nav a { color: var(--blue); font-size: 13px; font-weight: 800; }
.workitem-table-wrap { overflow-x: auto; }
.workitem-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.workitem-table th, .workitem-table td { padding: 12px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; font-size: 13px; }
.workitem-table th { color: var(--muted); background: #f8fafc; white-space: nowrap; }
.workitem-table td strong, .workitem-table td span, .workitem-table td small { display: block; }
.workitem-table td strong { color: var(--navy); margin-bottom: 3px; }
.workitem-table td span, .workitem-table td small { color: var(--muted); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; }

.warning-panel {
  padding: 12px 14px;
  color: #7a4c12;
  background: #fff1d6;
  border: 1px solid #e7c987;
  border-radius: 10px;
}

.warning-panel ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.panel {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-heading h2 {
  margin-bottom: 0;
  color: var(--navy);
  font-size: 17px;
  line-height: 1.2;
}

.panel-heading > span {
  color: var(--muted);
  font-size: 12px;
}

.panel-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 12px;
}

.danger-link {
  padding: 6px 9px;
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #f2b8b5;
  border-radius: 7px;
  font-weight: 800;
  text-decoration: none;
}

.panel-subnav {
  padding: 8px 14px 0;
  text-align: right;
}

.panel-subnav a {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.section-kicker {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.schedule-list,
.case-list {
  display: grid;
  padding: 8px;
}

.schedule-list.compact,
.case-list.compact {
  gap: 6px;
}

.case-row {
  position: relative;
  display: grid;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  background: #fbfcfe;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
}

.schedule-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 74px;
  padding: 10px 11px;
  color: inherit;
  text-decoration: none;
  background: #fbfcfe;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
}

.schedule-row.is-current {
  background: #eef6fc;
  border-color: #a8cde9;
  box-shadow: inset 4px 0 0 var(--blue);
}

.schedule-row.is-next {
  box-shadow: inset 4px 0 0 var(--navy-soft);
}

.schedule-row.is-completed {
  background: #f5f7fa;
}

.schedule-row.is-completed time,
.schedule-row.is-completed .row-main h3 {
  color: #5f6b7a;
}

.schedule-row.is-completed .row-main p {
  color: #7a8491;
}

.completion-form {
  margin: 0;
}

.completion-check {
  display: grid;
  grid-template-columns: 22px auto;
  gap: 4px;
  align-items: center;
  min-height: 44px;
  padding: 4px 6px 4px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.completion-check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--blue);
}

.schedule-link {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.schedule-link time {
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.row-main {
  min-width: 0;
}

.row-main h3,
.case-row h3 {
  overflow-wrap: anywhere;
  margin-bottom: 3px;
  color: var(--navy);
  font-size: 15px;
  line-height: 1.35;
}

.row-main p,
.case-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.next-line {
  color: #3d4a5c;
  font-weight: 700;
}

.detail-cue {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.detail-cue::after {
  content: ">";
  margin-left: 3px;
}

textarea {
  display: block;
  width: calc(100% - 24px);
  min-height: 172px;
  margin: 12px;
  padding: 14px;
  resize: vertical;
  color: var(--text);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 9px;
  line-height: 1.7;
}

textarea:focus {
  outline: 3px solid rgba(31, 95, 153, 0.2);
  border-color: var(--blue);
}

.input-footer {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.segmented,
.button-row,
.memo-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.button-row,
.memo-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label,
.button {
  min-height: 46px;
  padding: 10px 8px;
  color: var(--navy-soft);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  text-align: center;
  text-decoration: none;
  cursor: default;
}

.segmented label,
.button {
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

.segmented input:checked + label {
  color: #fff;
  background: var(--navy-soft);
  border-color: var(--navy-soft);
}

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

.button.danger {
  color: #fff;
  background: #b42318;
  border-color: #b42318;
}

.button.secondary {
  background: #f8fafc;
}

.button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.logout-form {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.logout-form button {
  border: 0;
  padding: 4px 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  text-decoration: underline;
}

.login-panel {
  width: min(100%, 360px);
  margin: min(18vh, 120px) auto 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(25, 55, 88, 0.08);
}

.login-panel h1 {
  margin: 4px 0 20px;
  font-size: 24px;
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form label {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.login-form .button {
  width: 100%;
  margin-top: 12px;
}

.login-error {
  margin: 0 0 12px;
  color: #b42318;
  font-size: 13px;
}

.completed-cases-link {
  margin: 14px 0 0;
  text-align: center;
  font-size: 14px;
}

.completed-case-list {
  display: grid;
  gap: 1px;
}

.completed-case-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
}

.completed-case-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.completed-case-heading,
.completed-case-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.completed-case-heading strong {
  margin-left: 6px;
  color: var(--ink);
  font-size: 14px;
}

.completed-case-note {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.completed-case-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.restore-case-link {
  color: #9a6700;
  font-weight: 700;
}

.restore-confirm .panel {
  max-width: 520px;
}

.restore-confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.case-row {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 8px 10px;
}

.case-completion-form {
  margin: 0;
}

.case-complete-button {
  min-height: 38px;
  padding: 6px 9px;
  color: var(--blue);
  background: #eef6fc;
  border: 1px solid #b8d7ee;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.case-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.case-link p {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.case-link p span:first-child {
  color: #3d4a5c;
  font-weight: 700;
}

.back-link {
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 8px 12px;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  font-weight: 800;
}

.detail-topbar.simple {
  justify-content: flex-start;
}

.detail-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
}

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

.message {
  padding: 10px 12px;
  color: #185b39;
  background: #e5f4ec;
  border: 1px solid #b9dec9;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
}

.summary-box {
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #fbfcfe;
}

.inline-heading {
  background: #fff;
}

.summary-list {
  display: grid;
  gap: 0;
  margin-bottom: 0;
  padding: 4px 12px 12px;
}

.summary-list div {
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.summary-list div:last-child {
  border-bottom: 0;
}

.summary-list dt {
  margin-bottom: 4px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
}

.summary-list dd {
  margin-bottom: 0;
  color: #3d4a5c;
  line-height: 1.65;
}

.memo-form {
  display: grid;
  gap: 10px;
}

.memo-field {
  display: grid;
  gap: 6px;
}

.memo-field span {
  color: var(--navy);
  font-size: 18px;
  font-weight: 800;
}

.memo-field small {
  color: var(--muted);
  line-height: 1.55;
}

.memo-field textarea {
  width: 100%;
  min-height: 240px;
  margin: 0;
}

.schedule-list-topbar {
  justify-content: flex-start;
}

.schedule-overview-header,
.schedule-overview-row {
  display: grid;
  grid-template-columns: 112px 92px minmax(0, 1fr) 62px 62px 45px;
  gap: 10px;
  align-items: center;
}

.schedule-overview-header {
  padding: 10px 14px;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 800;
}

.schedule-overview-list {
  display: grid;
}

.schedule-overview-row {
  min-width: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.schedule-overview-row:last-child {
  border-bottom: 0;
}

.schedule-overview-date,
.schedule-overview-time {
  color: #3d4a5c;
  font-size: 13px;
  font-weight: 700;
}

.schedule-overview-main {
  min-width: 0;
}

.schedule-overview-main h2 {
  overflow-wrap: anywhere;
  margin-bottom: 3px;
  color: var(--navy);
  font-size: 15px;
}

.schedule-overview-main p {
  overflow-wrap: anywhere;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.schedule-status {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.schedule-status.is-incomplete {
  color: #185b39;
  background: #e5f4ec;
}

.schedule-status.is-completed {
  color: #475467;
  background: #e9edf2;
}

.schedule-status.is-hidden {
  color: #7a4c12;
  background: #fff1d6;
}

.schedule-status.is-visible {
  color: #475467;
  background: #f2f4f7;
}

.empty-state {
  margin: 0;
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
}

.history-list,
.overview-case-list {
  display: grid;
}

.history-row,
.overview-case-row {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.history-row:last-child,
.overview-case-row:last-child {
  border-bottom: 0;
}

.history-row > div,
.overview-case-row {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
}

.history-row > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.history-row p,
.overview-case-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.history-body {
  color: var(--text) !important;
  font-size: 13px !important;
}

.input-status {
  width: max-content;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.attention-text {
  color: #9a3412 !important;
}

.overview-case-row h2 {
  margin-bottom: 3px;
  color: var(--navy);
  font-size: 15px;
}

.delete-confirm-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.delete-confirm-panel form {
  margin: 0;
}

.delete-confirm-panel .button {
  width: 100%;
}

.delete-warning {
  margin-bottom: 0;
  padding: 14px;
  color: #8f1d14;
  background: #fff1f0;
  border: 1px solid #f2b8b5;
  border-radius: 9px;
  font-weight: 800;
  line-height: 1.6;
}

@media (min-width: 760px) {
  .page-shell {
    padding: 20px;
  }

  .topbar,
  .detail-topbar {
    padding: 16px 18px;
  }

  .schedule-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .schedule-link {
    grid-template-columns: 120px minmax(0, 1fr) 52px;
  }

  .case-list.compact {
    gap: 0;
  }

  .case-row {
    grid-template-columns: auto minmax(0, 1fr);
    border-radius: 0;
    border-right: 0;
    border-left: 0;
    border-bottom: 0;
  }

  .case-row:first-child {
    border-top: 0;
    border-radius: 9px 9px 0 0;
  }

  .case-row:last-child {
    border-radius: 0 0 9px 9px;
  }

  .case-link p {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
  }
}

@media (max-width: 420px) {
  body {
    font-size: 14px;
  }

  .topbar,
  .detail-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .today-label {
    justify-items: start;
  }

  .schedule-row {
    grid-template-columns: 1fr auto;
  }

  .completion-form {
    grid-column: 1 / -1;
  }

  .completion-check {
    display: inline-grid;
    width: max-content;
  }

  .schedule-link {
    grid-column: 1 / -1;
    grid-template-columns: 1fr auto;
  }

  .schedule-link time {
    grid-column: 1 / -1;
  }

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

  .memo-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 759px) {
  .schedule-overview-header {
    display: none;
  }

  .schedule-overview-list {
    gap: 8px;
    padding: 8px;
  }

  .schedule-overview-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 10px;
    padding: 11px;
    background: #fbfcfe;
    border: 1px solid var(--line-soft);
    border-radius: 9px;
  }

  .schedule-overview-date,
  .schedule-overview-time {
    grid-column: 1;
  }

  .schedule-overview-time {
    color: var(--navy);
  }

  .schedule-overview-main {
    grid-column: 1 / -1;
  }

  .schedule-status {
    grid-column: 2;
  }

  .schedule-status.is-incomplete,
  .schedule-status.is-completed {
    grid-row: 1;
  }

  .schedule-status.is-visible,
  .schedule-status.is-hidden {
    grid-row: 2;
  }

  .schedule-overview-row .detail-cue {
    grid-column: 2;
    grid-row: 3;
    justify-self: end;
  }

  .overview-case-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .overview-case-row > div {
    grid-column: 1 / -1;
  }
}
