/* Colours (light and dark), fonts and the top bar come from the farm UI: ./farm/common.css, so both pages look the
   same and switching between them does not move anything. The names this form uses map onto those colours. */
:root {
  --panel: var(--surface);
  --text: var(--fg);
  --focus: var(--accent);
  --focus-dark: var(--accent-strong);
  --danger: var(--crit);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

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

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.page-head {
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

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

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

label,
.wide-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span,
.wide-field span {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--field);
  color: var(--text);
  min-height: 42px;
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 78px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.computed-row div {
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 10px;
  background: var(--field);
}

.computed-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.computed-row strong {
  font-size: 18px;
  font-weight: 700;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  cursor: pointer;
  min-height: 42px;
  padding: 9px 14px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.primary-button {
  background: var(--focus);
  color: var(--on-accent);
  font-weight: 600;
}

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

.secondary-button,
.icon-button {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.secondary-button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.status-text {
  margin: 0;
  min-height: 20px;
  color: var(--muted);
}

.status-text.good {
  color: var(--focus-dark);
}

.status-text.bad {
  color: var(--danger);
}

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

.section-heading h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.section-heading select {
  width: auto;
  min-width: 160px;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  font-size: 13px;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.warn {
  color: var(--warn);
  font-weight: 700;
}

.status-text.warn {
  color: var(--warn);
}

[hidden] {
  display: none !important;
}

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

.login-shell {
  padding: 0 16px;
}

.login-view {
  max-width: 460px;
  margin: 6vh auto 0;
}

.login-panel {
  text-align: center;
}

.lang-picker {
  margin-bottom: 16px;
}

.lang-picker-title {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 10px;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease;
}

.lang-option:hover {
  border-color: var(--line-strong);
}

.lang-option.is-active {
  border-color: var(--focus);
  background: var(--accent-soft);
  font-weight: 700;
}

.flag {
  stroke: none;
  width: 30px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--line);
}

.lang-menu {
  position: relative;
}

.lang-button .flag {
  width: 20px;
  height: 14px;
  border-radius: 2px;
}

.lang-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10;
  display: grid;
  gap: 4px;
  min-width: 190px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

.lang-dropdown .lang-option {
  min-height: 38px;
  border-width: 0;
  font-size: 14px;
}

.lang-dropdown .lang-option .flag {
  width: 20px;
  height: 14px;
  border-radius: 2px;
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.login-form input {
  text-align: center;
  font-size: 24px;
  letter-spacing: 0.3em;
}

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

.gf-topbar .icon-button {
  width: 34px;
  min-height: 34px;
  height: 34px;
  border-radius: 999px;
  background: none;
  color: var(--muted);
}

.gf-topbar .icon-button:hover {
  color: var(--text);
  border-color: var(--muted);
  background: none;
}

.gf-topbar .icon-button svg {
  width: 16px;
  height: 16px;
}

.user-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--focus-dark);
  font-size: 14px;
  white-space: nowrap;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.today-room h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.today-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.today-chip {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--text);
  cursor: pointer;
}

.today-chip.is-done {
  background: var(--ok-soft);
  border-color: var(--ok);
  color: var(--ok);
}

.today-chip.is-warn {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
  font-weight: 700;
}

.today-chip.is-missing {
  border-style: dashed;
  color: var(--muted);
}

.cycles-list {
  display: grid;
  gap: 14px;
}

.cycle-room {
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.cycle-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cycle-head h3 {
  margin: 0;
  font-size: 16px;
}

.cycle-badge {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}

.cycle-badge.is-active {
  border-style: solid;
  background: var(--ok-soft);
  border-color: var(--ok);
  color: var(--ok);
  font-weight: 700;
}

.cycle-tables {
  display: grid;
  gap: 8px;
}

.cycle-line {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.cycle-line-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cycle-line-actions .secondary-button {
  min-height: 34px;
  padding: 5px 10px;
}

.cycle-form-slot {
  grid-column: 1 / -1;
}

.cycle-form {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-small);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.cycle-table-rows {
  display: grid;
  gap: 8px;
}

.cycle-table-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 2fr 1fr;
  align-items: end;
  gap: 10px;
}

.cycle-include {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.cycle-include input {
  width: auto;
  min-height: 0;
}

.cycle-include span {
  color: var(--text);
  font-size: 14px;
}

.cycle-report {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cycle-report .secondary-button {
  min-height: 34px;
  padding: 5px 10px;
  text-decoration: none;
  font-size: 14px;
}

.cycle-history summary {
  cursor: pointer;
  color: var(--muted);
}

.cycle-history-item {
  display: grid;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.cycle-history-table {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input.input-warn {
  border-color: var(--warn);
  background: var(--warn-soft);
}

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

@media (max-width: 620px) {
  .page-head h1 {
    font-size: 20px;
  }

  .lang-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    padding: 14px;
  }

  .field-grid,
  .computed-row,
  .cycle-line,
  .cycle-table-row {
    grid-template-columns: 1fr;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .section-heading select {
    width: 100%;
  }
}
.login-logo { display: flex; justify-content: center; margin-bottom: 8px; }

/* inside the farm UI (#/form): its bar and side menu are around the frame */
.embedded .gf-topbar { display: none; }
