/* dia_app: one stylesheet. Palette and spacing first; everything else uses them. */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --text: #1c1c1c;
  --muted: #6e6e6e;
  --line: #e0e0e0;
  --line-strong: #b8b8b8;
  --bg: #ffffff;
  --bg-subtle: #f3f3f3;
  --bg-hover: #f8f8f8;
  --accent: #2c5a85;
  --accent-hover: #21476b;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 40px;

  --content-width: 1200px;
  --field-width: 22rem;
  --radius: 2px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

h2 {
  margin: var(--space-5) 0 var(--space-4);
  font-size: 1.4rem;
  font-weight: 600;
}

h3 {
  margin: var(--space-6) 0 var(--space-3);
  font-size: 1.07rem;
  font-weight: 600;
}

p {
  margin: var(--space-3) 0;
}

/* Top bar: title, sections, logout. */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: 0 max(var(--space-5), calc((100% - var(--content-width)) / 2 + var(--space-5)));
  border-bottom: 1px solid var(--line-strong);
}

.topbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
}

.topbar nav a {
  padding: var(--space-3) var(--space-3) calc(var(--space-3) - 2px);
  border-bottom: 2px solid transparent;
  color: var(--text);
  text-decoration: none;
}

.topbar nav a:hover {
  background: var(--bg-hover);
}

.topbar nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.topbar .logout {
  margin: 0 0 0 auto;
}

main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-2) var(--space-5) var(--space-6);
}

/* Tables. */

table {
  width: 100%;
  margin: var(--space-4) 0;
  border-collapse: collapse;
}

th,
td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: baseline;
}

thead th {
  background: var(--bg-subtle);
  border-bottom-color: var(--line-strong);
  font-weight: 600;
}

tbody th {
  font-weight: 500;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tfoot th,
tfoot td {
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
  font-weight: 600;
}

.num,
.total {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.num,
td.total {
  white-space: nowrap;
}

/* Numeric columns whose cells carry no class. */
.stock th:nth-child(4),
.stock th:nth-child(5),
.parcels td:nth-child(4),
.history th:nth-child(6) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr.reversed td {
  color: var(--muted);
  text-decoration: line-through;
}

/* Detail lists on lot and parcel cards. */

dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-5);
  margin: var(--space-4) 0;
}

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

dd {
  margin: 0;
}

/* Forms: label above its field. */

form {
  margin: var(--space-4) 0;
}

label {
  display: block;
  margin-bottom: var(--space-3);
  font-size: 0.93rem;
}

input,
select,
button {
  font: inherit;
  color: var(--text);
}

input,
select {
  padding: 6px var(--space-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
}

label > input,
label > select {
  display: block;
  width: var(--field-width);
  max-width: 100%;
  margin-top: var(--space-1);
}

label > input[type="checkbox"],
label > input[type="radio"] {
  display: inline-block;
  width: auto;
  margin: 0 var(--space-2) 0 0;
  vertical-align: middle;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

form p {
  max-width: 40rem;
  color: var(--muted);
  font-size: 0.93rem;
}

fieldset {
  max-width: var(--field-width);
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-1);
  border: 1px solid var(--line);
}

legend {
  padding: 0 var(--space-1);
  font-weight: 600;
}

button {
  padding: 6px var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

button:hover {
  background: var(--bg-subtle);
}

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

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

button + button {
  margin-left: var(--space-2);
}

/* Small forms inside table rows. */

td form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

td label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

td label > input {
  width: 6rem;
  margin: 0;
}

/* Error and notice messages. */

.message {
  max-width: 40rem;
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--text);
}

.message p {
  margin: 0;
}

/* Login and error pages: a small centred card. */

main.login {
  max-width: 24rem;
  margin: 12vh auto var(--space-6);
  padding: var(--space-5);
  border: 1px solid var(--line-strong);
}

main.login h1 {
  margin: 0 0 var(--space-4);
  font-size: 1.25rem;
  font-weight: 600;
}

main.login label > input {
  width: 100%;
}

main.login button.primary {
  width: 100%;
  margin-top: var(--space-2);
}
