:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --ink: #19211f;
  --muted: #67716d;
  --panel: #ffffff;
  --line: #dfe5dd;
  --accent: #116a63;
  --accent-dark: #0c4f4a;
  --warm: #b85c38;
  --soft: #e9f2ef;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #f6f7f2 0%, #eef4f1 52%, #f8eee8 100%);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 760;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
  padding: 0 18px;
}

.ghost:hover {
  background: var(--soft);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  gap: 28px;
  align-content: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  color: var(--muted);
  margin-top: 6px;
}

.brand.compact h1 {
  font-size: 1.45rem;
}

.mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 1.45rem;
  font-weight: 850;
}

.panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 45px rgba(35, 48, 43, 0.08);
}

.login-panel {
  max-width: 430px;
  padding: 24px;
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 720;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 106, 99, 0.14);
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--warm);
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tabs {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.tab {
  min-height: 42px;
  border-radius: 0;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
}

.tab:hover,
.tab.active {
  background: var(--ink);
  color: #fff;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  padding: 18px;
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 720;
}

.summary strong {
  display: block;
  margin-top: 7px;
  font-size: 1.9rem;
}

.report-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.report-filters {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.report-filters fieldset {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.report-filters legend {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
  padding: 0 4px;
}

.radio-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 0.86rem;
}

.radio-option input {
  width: auto;
}

.report-filters label:not(.radio-option) {
  min-width: 145px;
}

.report-filters input[type="date"] {
  min-height: 44px;
  padding: 8px 10px;
}

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

.report-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.report-header h2 {
  font-size: 1.15rem;
}

.report-header h2,
.report-header p {
  margin: 0;
}

.report-header p,
.report-header span {
  color: var(--muted);
}

.report-header strong {
  display: block;
  margin-top: 4px;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.report-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8faf7;
}

.report-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.report-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

.report-notes {
  color: var(--muted);
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.report-notes p {
  margin: 4px 0;
}

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

.report-table th,
.report-table td {
  border: 1px solid var(--line);
  padding: 6px 7px;
  text-align: left;
  vertical-align: top;
}

.report-table th {
  background: #eef4f1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  align-items: start;
  gap: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(300px, 390px) 1fr;
  align-items: start;
  gap: 18px;
}

.entry-form,
.list-panel {
  padding: 20px;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

.entry-form {
  display: grid;
  gap: 16px;
}

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

.readings {
  display: grid;
  gap: 10px;
}

.reading,
.user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.reading strong {
  display: block;
  font-size: 1.35rem;
}

.reading span,
.reading p {
  color: var(--muted);
  margin: 3px 0 0;
}

.users {
  display: grid;
  gap: 10px;
}

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

.user-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.user-meta {
  color: var(--muted);
  margin-top: 4px;
}

.user-controls {
  display: grid;
  grid-template-columns: 116px 104px 132px 40px;
  gap: 8px;
  align-items: center;
}

.user-controls input,
.user-controls select {
  min-height: 40px;
  padding: 8px 10px;
}

.small-button {
  min-height: 40px;
  padding: 0 12px;
}

.delete-button {
  width: 40px;
  min-height: 40px;
  background: #f3e6df;
  color: #934323;
}

.delete-button:hover {
  background: #ead5c9;
}

.empty {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 22px, 1120px);
    padding: 18px 0;
  }

  .topbar,
  .workspace,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .actions {
    display: grid;
  }

  .report-actions,
  .report-filters {
    display: grid;
  }

  .report-filters fieldset {
    align-items: start;
    display: grid;
    padding: 10px 12px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

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

  .report-header,
  .report-summary {
    grid-template-columns: 1fr;
  }

  .report-header {
    display: grid;
  }

  .report-table {
    display: block;
    overflow-x: auto;
  }

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

  .ghost {
    width: 100%;
  }

  .user-row,
  .user-controls {
    grid-template-columns: 1fr;
  }

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

@media print {
  @page {
    margin: 10mm;
  }

  body {
    background: #fff;
    color: #111;
    font-size: 10px;
  }

  .topbar,
  .report-actions,
  #readingsView,
  #usersView {
    display: none !important;
  }

  .shell {
    width: 100%;
    padding: 0;
  }

  #appView,
  #reportView {
    display: block !important;
  }

  .report {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .report-header {
    gap: 8px;
    padding-bottom: 6px;
    margin-bottom: 8px;
  }

  .report-header h2 {
    font-size: 14px;
  }

  .report-header p,
  .report-header span,
  .report-header strong {
    font-size: 10px;
  }

  .report-summary {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-bottom: 7px;
  }

  .report-summary article {
    break-inside: avoid;
    border-radius: 0;
    padding: 5px 6px;
    background: #fff;
  }

  .report-summary span {
    font-size: 8px;
  }

  .report-summary strong {
    font-size: 13px;
    margin-top: 1px;
  }

  .report-notes {
    margin-bottom: 7px;
    font-size: 9px;
  }

  .report-notes p {
    margin: 1px 0;
  }

  .report-table {
    font-size: 8px;
    line-height: 1.15;
  }

  .report-table th,
  .report-table td {
    padding: 2px 3px;
  }

  .report-table th:nth-child(1),
  .report-table td:nth-child(1) {
    width: 19%;
  }

  .report-table th:nth-child(2),
  .report-table td:nth-child(2) {
    width: 10%;
  }

  .report-table th:nth-child(3),
  .report-table td:nth-child(3),
  .report-table th:nth-child(4),
  .report-table td:nth-child(4),
  .report-table th:nth-child(5),
  .report-table td:nth-child(5) {
    width: 10%;
    text-align: center;
  }

  .report-table tr {
    break-inside: avoid;
  }
}
