* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --text: #1d2939;
  --muted: #667085;
  --line: #d0d7de;
  --line-soft: #e4e7ec;
  --primary: #1f6feb;
  --primary-dark: #175cd3;
  --danger: #b42318;
  --success: #027a48;
  --tap: 48px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.page {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  margin: -20px -16px 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 245, 247, 0.94);
  backdrop-filter: blur(10px);
}

.topnav a,
button,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.button-secondary,
.topnav a {
  background: #fff;
  color: var(--primary);
}

.panel {
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

h1,
h2 {
  margin: 0 0 16px;
  letter-spacing: 0;
  line-height: 1.25;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.hint,
.empty {
  color: var(--muted);
}

.status {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid #d0d7de;
  border-radius: 7px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
}

.status.loading {
  border-color: #84caff;
  background: #eff8ff;
  color: #175cd3;
}

.status.success {
  border-color: #75e0a7;
  background: #ecfdf3;
  color: var(--success);
}

.status.error {
  border-color: #fda29b;
  background: #fffbfa;
  color: var(--danger);
}

.is-loading {
  opacity: 0.72;
}

button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.notice {
  color: var(--danger);
  font-weight: 800;
}

.success {
  color: var(--success);
  font-weight: 800;
}

.upload-form,
.actions,
.section-title,
.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title,
.calendar-toolbar {
  justify-content: space-between;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid #c8d0d9;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

input[type="file"] {
  padding: 9px;
}

input:focus,
select:focus,
button:focus,
.button-secondary:focus,
.topnav a:focus {
  outline: 3px solid rgba(31, 111, 235, 0.18);
  outline-offset: 2px;
}

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

.wide {
  grid-column: 1 / -1;
}

.report-form .actions {
  margin-top: 18px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f8fafc;
}

.num {
  text-align: right;
}

.ocr-text {
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  border-radius: 7px;
  background: #101828;
  color: #f9fafb;
  white-space: pre-wrap;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays span {
  padding: 10px;
  color: #475467;
  font-weight: 900;
  text-align: center;
}

.calendar-grid {
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.day {
  min-height: 118px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-top: 0;
  border-left: 0;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.day b,
.day strong,
.day span,
.day small {
  display: block;
}

.day b {
  margin-bottom: 8px;
}

.day strong {
  color: var(--primary-dark);
}

.day.has-report {
  background: #f8fbff;
}

.day.selected {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.day span {
  margin-top: 4px;
  color: var(--danger);
}

.day small {
  margin-top: 4px;
  color: var(--muted);
}

.day.muted {
  background: #f8fafc;
}

.empty-day {
  color: #98a2b3;
}

.loading {
  grid-column: 1 / -1;
  padding: 24px;
}

.detail-panel {
  scroll-margin-top: 72px;
}

.detail-summary {
  color: var(--muted);
  font-weight: 800;
}

.detail-empty,
.detail-loading {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
}

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

.report-detail-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.detail-card-head strong {
  font-size: 17px;
}

.detail-card-head span {
  color: var(--primary-dark);
  font-weight: 900;
}

.detail-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 12px 0 0;
}

.detail-fields div {
  min-width: 0;
}

.detail-fields dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.detail-fields dd {
  margin: 0;
  min-height: 20px;
  overflow-wrap: anywhere;
}

.detail-image-link {
  display: inline-flex;
  margin-top: 12px;
  color: var(--primary);
  font-weight: 900;
}

@media (max-width: 900px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    background: #fff;
  }

  .page {
    width: 100%;
    padding: 0 0 28px;
  }

  .topnav {
    margin: 0;
    padding: 8px;
  }

  .topnav a {
    flex: 1;
  }

  .panel {
    margin: 0;
    padding: 18px 14px;
    border-width: 0 0 1px;
    border-radius: 0;
  }

  h1 {
    font-size: 21px;
  }

  h2 {
    font-size: 17px;
  }

  .upload-form,
  .actions,
  .section-title,
  .calendar-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-form label,
  .upload-form button,
  .actions button,
  .actions a,
  .section-title a,
  .calendar-toolbar button,
  .calendar-toolbar h1 {
    width: 100%;
  }

  .calendar-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .calendar-toolbar h1 {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-bottom: 4px;
    text-align: center;
  }

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

  .report-form .actions {
    position: sticky;
    bottom: 0;
    z-index: 9;
    margin: 16px -14px -18px;
    padding: 10px 14px 14px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
  }

  .table-wrap {
    margin: 0 -14px;
    padding: 0 14px;
  }

  th,
  td {
    padding: 9px 10px;
    font-size: 14px;
  }

  .calendar-panel {
    padding-left: 8px;
    padding-right: 8px;
  }

  .calendar-weekdays span {
    padding: 8px 2px;
    font-size: 13px;
  }

  .calendar-grid {
    border-left: 0;
  }

  .day {
    min-height: 76px;
    padding: 6px 4px;
    font-size: 11px;
  }

  .day b {
    margin-bottom: 3px;
    font-size: 12px;
  }

  .day strong,
  .day span,
  .day small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ocr-text {
    max-height: 220px;
    font-size: 13px;
  }

  .detail-fields {
    grid-template-columns: 1fr;
  }

  .detail-card-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 380px) {
  .day {
    min-height: 66px;
    font-size: 10px;
  }

  .topnav a,
  button,
  .button-secondary {
    padding-left: 10px;
    padding-right: 10px;
  }
}
