:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #18201d;
  --muted: #68736c;
  --line: #d8dfd8;
  --field: #f9fbf8;
  --accent: #126a5a;
  --accent-strong: #0b4e43;
  --warn: #b8422e;
  --shadow: 0 14px 40px rgba(22, 34, 28, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

body.locked {
  overflow: hidden;
}

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

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #123b35;
}

.login-screen[hidden] {
  display: none;
}

.login-panel {
  display: grid;
  gap: 15px;
  width: min(430px, 100%);
  padding: 24px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
}

.login-panel h1 {
  color: var(--ink);
  font-size: 25px;
}

.login-error {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--warn);
  font-weight: 800;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 42px);
  background: #123b35;
  color: #fff;
  border-bottom: 5px solid #d29c30;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.nav-button {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0 14px;
}

.nav-button.active {
  background: #d29c30;
  color: #102d28;
  border-color: #d29c30;
}

.exit-button {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.eyebrow {
  margin: 0 0 4px;
  color: #e9d59a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 14px;
  font-size: 16px;
}

main {
  display: grid;
  gap: 14px;
  padding: 16px clamp(14px, 3vw, 34px) 34px;
}

.app-view {
  display: grid;
  gap: 14px;
}

.app-view[hidden] {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(14px, 2vw, 22px);
}

.entry-panel {
  padding: 12px clamp(12px, 1.8vw, 18px);
}

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

.clock {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.form-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.smtp-address-grid {
  margin-bottom: 10px;
}

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

.status-line {
  display: grid;
  grid-template-columns: repeat(2, minmax(210px, 1fr));
  gap: 10px;
}

.status-line.single {
  grid-template-columns: minmax(210px, 1fr);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

label span,
legend {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cbd4cd;
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  padding: 7px 9px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 106, 90, 0.16);
  outline: none;
}

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

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #e5ece7;
  color: #17382f;
  padding: 0 14px;
}

.secondary-button:hover {
  background: #d3ded7;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  background: rgba(255, 255, 255, 0.13);
  color: currentColor;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 22px;
}

fieldset {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-weight: 800;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--ink);
  font-weight: 700;
}

fieldset input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.trend-heading {
  align-items: flex-start;
}

.trend-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

.date-select {
  min-width: 180px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 4px 0 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.legend-swatch {
  width: 22px;
  height: 4px;
  border-radius: 999px;
}

.chart-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

canvas {
  display: block;
  width: 100%;
  min-width: 760px;
  height: 430px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 6px;
  text-align: left;
  vertical-align: top;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3ef;
  color: #32423b;
  font-size: 12px;
  line-height: 1.12;
  text-transform: uppercase;
}

th:nth-child(1),
td:nth-child(1) {
  width: 68px;
}

th:nth-child(2),
th:nth-child(3),
td:nth-child(2),
td:nth-child(3) {
  width: 72px;
}

th:nth-child(4),
td:nth-child(4),
th:nth-child(8),
td:nth-child(8),
th:nth-child(12),
td:nth-child(12),
th:nth-child(16),
td:nth-child(16) {
  width: 54px;
}

th:nth-child(5),
th:nth-child(7),
th:nth-child(9),
th:nth-child(11),
th:nth-child(13),
th:nth-child(15),
td:nth-child(5),
td:nth-child(7),
td:nth-child(9),
td:nth-child(11),
td:nth-child(13),
td:nth-child(15) {
  width: 68px;
}

th:nth-child(6),
th:nth-child(10),
th:nth-child(14),
td:nth-child(6),
td:nth-child(10),
td:nth-child(14) {
  width: 86px;
}

th:nth-child(17),
td:nth-child(17) {
  width: 160px;
}

th:nth-child(18),
td:nth-child(18) {
  width: 94px;
}

.admin-record-actions {
  display: none;
}

body.admin-user .admin-record-actions {
  display: table-cell;
}

.table-input {
  width: 100%;
  min-height: 28px;
  padding: 4px 5px;
  font-size: 12px;
}

.observation-input {
  min-width: 130px;
  resize: vertical;
}

.record-actions {
  display: grid;
  gap: 5px;
}

.row-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

.danger-button {
  background: #f4e4e0;
  color: #8d2d1f;
  padding: 0 10px;
}

.danger-button:hover {
  background: #edd0c8;
}

.status-on {
  color: var(--warn);
  font-weight: 800;
}

.settings-dialog {
  width: min(880px, calc(100vw - 24px));
  border: 0;
  border-radius: 8px;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.28);
  padding: 0;
}

.settings-dialog::backdrop {
  background: rgba(12, 23, 20, 0.54);
}

.settings-form {
  display: grid;
  gap: 20px;
  padding: 20px;
}

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

.dialog-heading .icon-button {
  background: #eef3ef;
  color: var(--ink);
  border-color: var(--line);
}

.recipient-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.recipient-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.recipient-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.trash-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  background: #f4e4e0;
  color: #8d2d1f;
  padding: 0;
}

.settings-note {
  margin-bottom: 0;
  color: var(--muted);
}

.settings-actions {
  align-items: center;
  flex-wrap: wrap;
}

.settings-status {
  color: var(--muted);
  font-weight: 800;
}


@media (max-width: 720px) {
  .app-header,
  .section-heading,
  .trend-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header {
    position: relative;
    gap: 14px;
    padding: 16px 12px;
  }

  #settingsButton {
    position: static;
  }

  h1 {
    max-width: none;
  }

  .header-actions,
  .recipient-row,
  .status-line,
  .status-line.single {
    grid-template-columns: 1fr;
    width: 100%;
  }

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

  .header-actions button {
    width: 100%;
    min-width: 0;
    padding-inline: 8px;
  }

  .icon-button {
    width: auto;
  }

  main {
    padding: 12px 8px 24px;
  }

  .panel {
    padding: 12px 10px;
  }

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

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

  .chart-wrap {
    margin-inline: -4px;
  }
}

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

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

  h1 {
    font-size: 22px;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions button {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-header,
  .entry-panel,
  #settingsDialog,
  .secondary-button,
  .login-screen {
    display: none !important;
  }

  main {
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 0;
    break-inside: avoid;
  }

  .table-wrap,
  .chart-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 10px;
  }

  th,
  td {
    padding: 4px;
  }
}
