:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #60707c;
  --line: #d8e0e5;
  --paper: #ffffff;
  --surface: #f4f7f8;
  --surface-strong: #e8eef1;
  --accent: #174a7c;
  --accent-dark: #071c34;
  --gold: #c99b2e;
  --danger: #a33b33;
  --shadow: 0 18px 50px rgba(23, 32, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  cursor: pointer;
}

.global-appbar {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: #071c34;
  color: #fff;
  border-bottom: 4px solid var(--gold);
}

.global-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.global-brand img {
  width: 132px;
  height: 42px;
  object-fit: contain;
  object-position: left center;
  padding: 4px 8px;
  border-radius: 6px;
  background: #fff;
}

.global-brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.global-brand span {
  display: block;
  margin-top: 3px;
  color: #c8d6e5;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.global-nav {
  display: flex;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.global-nav a {
  min-width: 104px;
  padding: 9px 12px;
  border-radius: 6px;
  color: #dbe7f3;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

.global-nav a.active {
  color: #071c34;
  background: #fff;
}

.diary-subnav {
  height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 6px 20px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.diary-subnav-label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.diary-subnav-label strong,
.diary-subnav-label span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.diary-subnav-label span {
  color: #43535d;
  font-weight: 700;
  text-transform: none;
}

.diary-subnav-links {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.access-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 28, 52, 0.52);
  backdrop-filter: blur(4px);
}

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

.access-card {
  width: min(100%, 380px);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.access-brand {
  color: var(--ink);
}

.access-brand .brand-mark {
  border-color: var(--line);
  background: #f4f7f8;
}

.access-error {
  margin: -6px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.app-notice {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid #bfd0df;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 28px rgba(8, 31, 55, 0.16);
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}

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

.app-shell {
  display: block;
  min-height: calc(100vh - 116px);
}

.app-shell.is-locked {
  display: none;
}

.sidebar {
  background: #071c34;
  color: #f7fafb;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.sidebar-panel small,
.panel-label {
  color: #b9c6ce;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  min-width: 110px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7fafc;
  color: #071c34;
  text-align: center;
  font-weight: 800;
}

.access-level-button {
  min-width: 126px;
  padding: 9px 12px;
  border: 1px solid #c9d6e2;
  border-radius: 7px;
  background: #eef3f8;
  color: #071c34;
  text-align: center;
  font-weight: 800;
}

.access-level-button:hover {
  border-color: #174a7c;
  background: #dfeaf4;
}

.access-level-button[hidden],
.operator-only[hidden] {
  display: none;
}

.nav-button:hover,
.nav-button.active {
  border-color: #174a7c;
  background: #174a7c;
  color: #ffffff;
}

.sidebar-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 16px;
  border-radius: 8px;
}

.sidebar-panel strong,
.sidebar-panel span,
.sidebar-panel small {
  display: block;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

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

h1 {
  margin-bottom: 6px;
  font-size: 24px;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #43535d;
}

.topbar p {
  color: var(--muted);
  margin-bottom: 0;
}

.topbar-actions,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary-button,
.ghost-button,
.small-button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: var(--paper);
  color: var(--ink);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

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

.small-button {
  min-height: 32px;
  padding: 0 10px;
}

.day-nav-button[hidden] {
  display: none;
}

.day-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.print-bundle {
  display: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.form-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 1px 0 rgba(23, 32, 38, 0.04);
  display: grid;
  gap: 10px;
}

.form-section.wide,
.form-actions {
  grid-column: 1 / -1;
}

.compact-diary {
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(190px, 260px) minmax(0, 1fr);
  align-items: end;
}

.compact-diary .section-header {
  align-self: center;
}

.workforce-section {
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.workforce-section .section-header {
  grid-column: 1 / -1;
}

.execution-section {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
}

.execution-section .section-header {
  grid-column: 1 / -1;
}

.field-activities textarea,
.field-occurrences textarea {
  min-height: 132px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
}

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

label {
  display: grid;
  gap: 5px;
  color: #34444e;
  font-weight: 700;
  font-size: 13px;
}

.field-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px 10px;
  min-height: 36px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  outline: 3px solid rgba(15, 118, 110, 0.16);
  border-color: var(--accent);
}

.weather-picker {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0;
}

.weather-picker legend {
  color: #34444e;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
}

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

.weather-picker legend {
  grid-column: 1 / -1;
}

.weather-picker label {
  display: grid;
  grid-template-rows: 34px;
  gap: 0;
  cursor: pointer;
}

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

.weather-picker span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  text-align: center;
}

.weather-picker span {
  background: #f8fafb;
  color: #34444e;
  font-size: 12px;
  font-weight: 800;
}

.weather-picker b {
  display: none;
}

.weather-picker input:checked ~ span {
  border-color: var(--accent);
  background: #e6f3f1;
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.18);
}

.quantity-section {
  display: grid;
  gap: 8px;
}

.quantity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quantity-header div {
  display: grid;
  gap: 2px;
}

.quantity-header strong {
  color: #34444e;
}

.quantity-header span {
  color: var(--muted);
  font-size: 12px;
}

.small-action {
  width: auto;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #34444e;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.small-action:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #f2faf8;
}

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

.quantity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  padding: 5px 6px 5px 9px;
}

.quantity-row span {
  font-size: 12px;
  font-weight: 700;
  color: #34444e;
}

.quantity-row input {
  min-height: 28px;
  padding: 4px 6px;
  text-align: center;
}

.file-drop {
  border: 1px dashed #9cadb7;
  border-radius: 8px;
  background: #f8fafb;
  min-height: 54px;
  place-items: center;
  text-align: center;
}

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

.photo-grid,
.report-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.photo-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.photo-card img,
.report-photos img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.photo-card button {
  width: 100%;
  border: 0;
  background: #f6e9e7;
  color: var(--danger);
  min-height: 34px;
}

.form-actions {
  justify-content: flex-end;
  padding: 4px 0 0;
}

.filters {
  display: grid;
  grid-template-columns: 220px minmax(240px, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.period-export-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 150px 150px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.period-export-panel strong,
.period-export-panel span {
  display: block;
}

.period-export-panel span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.records-list {
  display: grid;
  gap: 10px;
}

.record-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.record-row strong,
.record-row span {
  display: block;
}

.record-row span {
  color: var(--muted);
  margin-top: 4px;
}

.record-actions {
  display: flex;
  gap: 8px;
}

.danger-button {
  border: 1px solid #e2b5ae;
  background: #fff8f7;
  color: var(--danger);
  border-radius: 6px;
  min-height: 38px;
  padding: 0 10px;
}

.danger-button.confirming {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.empty-state {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
}

.report-page {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 980px;
  margin: 0 auto;
  padding: 34px;
}

.excel-header {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 132px;
  align-items: stretch;
  border: 1px solid var(--ink);
  border-bottom: 0;
  background: #ffffff;
}

.header-logo {
  display: grid;
  place-items: center;
  min-height: 86px;
  padding: 8px;
  border-right: 1px solid var(--ink);
  overflow: hidden;
}

.header-logo img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 68px;
  object-fit: contain;
  object-position: center;
}

.left-logo img {
  max-width: 150px;
  max-height: 58px;
}

.right-logo img {
  max-width: 108px;
  max-height: 70px;
}

.right-logo {
  border-right: 0;
  border-left: 1px solid var(--ink);
}

.header-title {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 10px 14px;
  text-align: center;
}

.header-title h2 {
  margin: 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.header-title strong {
  font-family: "Times New Roman", Times, serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.excel-info-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
  margin-bottom: 18px;
  background: #ffffff;
}

.excel-info-grid .cell {
  min-height: 48px;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 7px 9px;
  display: grid;
  align-content: center;
  gap: 4px;
  line-height: 1.2;
  min-width: 0;
}

.excel-info-grid span {
  color: #273740;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.excel-info-grid strong {
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.span-1 {
  grid-column: span 1;
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.metric-cell strong {
  font-size: 14px;
}

.weather-cell {
  min-height: 60px;
}

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

.weather-option {
  display: grid;
  grid-template-rows: auto 30px;
}

.weather-option b {
  display: grid;
  place-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #f8fafb;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.weather-option strong {
  display: grid;
  place-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  font-size: 20px;
  line-height: 1;
}

.report-grid,
.report-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.report-grid section,
.report-split .report-block,
.report-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 16px;
}

.report-split .report-block {
  min-height: 150px;
}

dl {
  margin: 0;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 12px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

.report-block p {
  white-space: pre-wrap;
  margin-bottom: 0;
  line-height: 1.5;
}

.report-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin: 0;
}

.report-list div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #edf1f3;
  min-height: 28px;
  padding: 3px 0;
}

.report-list dt,
.report-list dd {
  font-size: 13px;
}

.report-list dt {
  min-width: 0;
  color: #34444e;
  overflow-wrap: break-word;
}

.report-list dd {
  display: grid;
  place-items: center;
  min-height: 24px;
  border: 1px solid #dce4e8;
  border-radius: 4px;
  background: #f8fafb;
  color: #000000;
  font-weight: 800;
}

.report-note {
  margin-top: 10px;
  color: #34444e;
}

.signature-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin-top: 48px;
}

.signature-row span {
  border-top: 1px solid var(--ink);
  text-align: center;
  padding-top: 8px;
  color: #34444e;
}

@media screen and (max-width: 920px) {
  .global-appbar {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .global-brand img {
    width: 112px;
    height: 36px;
  }

  .global-brand strong {
    font-size: 15px;
  }

  .global-brand span {
    font-size: 10px;
  }

  .global-nav {
    width: 100%;
    min-width: 0;
    overflow-x: visible;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .global-nav a {
    flex: 1 1 70px;
    min-width: 0;
    padding: 8px 10px;
    font-size: 13px;
  }

  .diary-subnav {
    height: auto;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
  }

  .diary-subnav-label {
    gap: 8px;
    flex-wrap: wrap;
    white-space: normal;
  }

  .diary-subnav-links {
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: stretch;
    overflow-x: visible;
  }

  .nav-button {
    flex: 1 1 96px;
    min-width: 0;
  }

  .access-level-button {
    flex: 1 1 128px;
    min-width: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: calc(100vh - 168px);
  }

  .sidebar {
    position: static;
    padding: 16px;
    gap: 16px;
  }

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

  .sidebar-panel {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .excel-header {
    display: grid;
    min-width: 0;
    max-width: 100%;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .topbar-actions button {
    width: 100%;
    min-width: 0;
  }

  .form-grid,
  .filters,
  .period-export-panel,
  .report-grid,
  .report-split,
  .record-row {
    grid-template-columns: 1fr;
  }

  .compact-diary,
  .workforce-section,
  .execution-section {
    grid-template-columns: 1fr;
  }

  .compact-diary .section-header,
  .workforce-section .section-header,
  .execution-section .section-header {
    grid-column: 1;
  }

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

  .excel-header,
  .excel-info-grid {
    grid-template-columns: 1fr;
  }

  .excel-info-grid .span-1,
  .excel-info-grid .span-2,
  .excel-info-grid .span-3,
  .excel-info-grid .span-4,
  .excel-info-grid .span-5,
  .excel-info-grid .span-6,
  .excel-info-grid .span-7 {
    grid-column: 1 / -1;
  }

  .quantity-header,
  .quantity-row {
    grid-template-columns: 1fr;
  }

  .quantity-row input {
    text-align: left;
  }

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

  .record-actions button {
    flex: 1;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  body {
    background: #ffffff;
  }

  .sidebar,
  .global-appbar,
  .diary-subnav,
  .topbar,
  .day-nav-button,
  #formView,
  #recordsView {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .view,
  #reportView {
    display: block !important;
    min-height: 0;
    padding: 0;
  }

  body.print-bundle-active .app-shell {
    display: none !important;
  }

  body.print-bundle-active .print-bundle {
    display: block !important;
  }

  body.print-bundle-active .print-bundle .report-page {
    break-after: page;
    page-break-after: always;
  }

  body.print-bundle-active .print-bundle .report-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .report-page {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    max-width: none;
    width: 190mm;
    margin: 0 auto;
    padding: 0;
  }

  .excel-header,
  .excel-info-grid,
  .report-block,
  .report-split,
  .signature-row {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-photos {
    grid-template-columns: repeat(2, 1fr);
  }

  .report-photos img {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
