/* App styles. Mobile-first: designed for a 360 px wide phone. */

:root {
  --blue: #0b4f9c;
  --blue-dark: #083a74;
  --blue-light: #e8f0fa;
  --text: #111827;
  --muted: #4b5563;
  --border: #9ca3af;
  --error: #b00020;
  --warning: #8a4b00;
  --success: #0b6b2f;
  --white: #ffffff;
  --tap-size: 2.75rem; /* 44 px at the default font size, grows with large fonts */
  --nav-height: 3.5rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--white);
  color: var(--text);
  font: 1rem/1.5 system-ui, "Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif;
}

[hidden] {
  display: none !important;
}

/* Header, notice and navigation */

.app-header {
  background: var(--blue);
  color: var(--white);
  padding: 0.75rem 1rem;
}

.app-header__title {
  margin: 0;
  font-size: 1.25rem;
}

.notice {
  margin: 0;
  padding: 0.75rem 1rem;
  background: #fff4d6;
  border-bottom: 1px solid #e0b64a;
  color: #4a3200;
}

.app-main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--nav-height) + 2rem);
}

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  min-height: var(--nav-height);
  background: var(--white);
  border-top: 1px solid var(--border);
}

.bottom-nav__link {
  flex: 1 1 0;
  min-width: 0; /* with large text, the buttons share the width and wrap instead of overflowing */
  text-align: center;
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-size);
  padding: 0.5rem;
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
}

.bottom-nav__link[aria-current="page"] {
  background: var(--blue-light);
  box-shadow: inset 0 3px 0 var(--blue);
}

/* Screens and forms */

.screen h2 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

.form__section {
  min-width: 0; /* a fieldset would otherwise refuse to shrink below its widest content */
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.form__section legend {
  padding: 0 0.5rem;
  font-weight: 700;
  color: var(--blue-dark);
}

.field {
  margin-bottom: 1rem;
}

.field__label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.field__required {
  color: var(--error);
}

.field__hint {
  margin: 0 0 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.field input:not([type="file"]),
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap-size);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--white);
  color: var(--text);
  font: inherit; /* 16 px or more, so phones do not zoom in on focus */
}

.field input[type="file"] {
  width: 100%;
  min-height: var(--tap-size);
  font: inherit;
}

.field--invalid input,
.field--invalid select,
.field--invalid textarea {
  border-color: var(--error);
  border-width: 2px;
}

.field__error,
.field__warning {
  margin: 0.25rem 0 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.field__error {
  color: var(--error);
}

.field__warning {
  color: var(--warning);
}

.field__error:empty,
.field__warning:empty {
  display: none;
}

:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

.logo-preview {
  display: block;
  max-width: 100%;
  max-height: 8rem;
  margin: 0.5rem 0;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  object-fit: contain;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-size);
  padding: 0.5rem 1.25rem;
  border: 2px solid var(--blue);
  border-radius: 0.5rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button--primary {
  width: 100%;
  background: var(--blue);
  color: var(--white);
}

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

.button--secondary {
  background: var(--white);
  color: var(--blue);
}

/* Status line under the form */

.status {
  margin: 0 0 0.75rem;
  font-weight: 700;
}

.status:empty {
  display: none;
}

.status--error {
  color: var(--error);
}

.status--success {
  color: var(--success);
}

/* New Invoice form */

.invoice-number {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
}

.invoice-number strong {
  color: #c00018; /* red, like the paper invoice book */
}

.choice-group {
  min-width: 0;
  padding: 0;
  border: 0;
}

.choice-group legend {
  padding: 0;
}

.choice-group__options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.choice {
  flex: 1 1 8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap-size);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
}

.choice:has(input:checked) {
  border: 2px solid var(--blue);
  background: var(--blue-light);
  font-weight: 600;
}

.choice input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--blue);
}

.line {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #f8fafc;
}

.line__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.line__title {
  margin: 0;
  font-size: 1rem;
  color: var(--blue-dark);
}

.line__numbers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.line__amount {
  margin: 0;
  font-weight: 600;
}

.line__amount:empty {
  display: none;
}

.button--icon {
  min-width: var(--tap-size);
  padding: 0;
  border-color: var(--border);
  background: var(--white);
  color: var(--error);
  font-size: 1.5rem;
  line-height: 1;
}

.button--full {
  width: 100%;
  margin-top: 0.75rem;
}

.form__section > .button {
  margin-bottom: 0.75rem;
}

.totals {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--blue);
  border-radius: 0.5rem;
  background: var(--blue-light);
}

.totals__row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
}

.totals dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.totals__row--grand {
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--blue);
  font-size: 1.25rem;
  font-weight: 700;
}

.tip {
  margin: 1rem 0 0;
  font-size: 0.9375rem;
  color: var(--muted);
}


/* Invoices list, backup reminder and Backup / Restore */

.notice--inline {
  margin: 0 0 1rem;
  border: 1px solid #e0b64a;
  border-radius: 0.5rem;
}

.notice--inline p {
  margin: 0 0 0.75rem;
}

.invoice-list__summary {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.invoice-list {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.invoice-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "number customer total"
    "number meta total";
  column-gap: 0.75rem;
  align-items: center;
  min-height: 3.5rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  text-decoration: none;
}

.invoice-row:hover {
  background: var(--blue-light);
}

.invoice-row__number {
  grid-area: number;
  color: #c00018; /* red, like the paper invoice book */
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.invoice-row__customer {
  grid-area: customer;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.invoice-row__meta {
  grid-area: meta;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.875rem;
}

.invoice-row__total {
  grid-area: total;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

.backup__title {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  color: var(--blue-dark);
}

.backup__restore {
  margin-top: 1rem;
}

.backup {
  margin-top: 1.75rem;
}
