:root {
  --navy: #0b3352;
  --orange: #f39200;
  --ink: #1b2430;
  --muted: #5f6b76;
  --line: #d6dde4;
  --bg: #f4f7fa;
  --card: #fff;
  --danger: #b42318;
  --ok: #146c43;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
a {
  color: var(--navy);
}
h1 {
  font-size: 1.6rem;
  margin: 0;
  color: var(--navy);
}
h2 {
  font-size: 1.05rem;
  margin: 0 0 12px;
  color: var(--navy);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875rem;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 3px solid var(--navy);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  color: var(--navy);
}
.brand small {
  color: var(--orange);
  font-weight: 700;
  margin-left: 4px;
}
.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}
.head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 4px;
}
input,
select,
textarea {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
textarea {
  min-height: 90px;
  resize: vertical;
}
input[aria-invalid='true'],
textarea[aria-invalid='true'] {
  border-color: var(--danger);
}
input:disabled,
select:disabled,
textarea:disabled {
  background: #f1f3f5;
  color: var(--ink);
}
.err {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 4px 0 0;
}
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn.primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn.accent {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.btn.link {
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--danger);
  font-weight: 600;
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: #e8edf2;
  color: var(--muted);
}
.pill.final {
  background: #fff1dc;
  color: #9a5b00;
}
.pill.sent {
  background: #e3f4ea;
  color: var(--ok);
}

/* the list */
.search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
table.list {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.list th,
.list td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.list th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.list td.num {
  text-align: right;
  white-space: nowrap;
}
.list tr:last-child td {
  border-bottom: 0;
}

/* lines */
.line {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.kind {
  font-weight: 800;
  color: var(--navy);
}
.line-main {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 90px 130px 120px;
  align-items: end;
}
.amount {
  font-weight: 700;
  text-align: right;
  padding-bottom: 9px;
}
.details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* totals */
.totals {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 20px;
  max-width: 380px;
  margin-left: auto;
}
.totals dt {
  text-align: right;
}
.totals dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.totals .big {
  font-weight: 800;
  color: var(--navy);
  font-size: 1.1rem;
}
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 600;
}
.check input {
  width: auto;
  margin-top: 4px;
}
.notice {
  background: #fff8ec;
  border: 1px solid #f6d7a7;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.actions {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

@media (max-width: 640px) {
  .line-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .line-main > :first-child {
    grid-column: 1 / -1;
  }
  .line-main .amount {
    grid-column: 1 / -1;
    padding-bottom: 0;
  }
  .list thead {
    display: none;
  }
  .list tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    border-bottom: 1px solid var(--line);
  }
  .list td {
    border: 0;
    padding: 4px 12px;
  }
  .list td.hide-sm {
    display: none;
  }
  .brand span small {
    display: block;
    margin: 0;
  }
}

fieldset.plain {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.h2-label {
  font-size: inherit;
  margin: 0;
}
.totals-note {
  text-align: right;
  margin: 6px 0 0;
}
.btn.link.back {
  color: var(--muted);
}

/* phase 2: sign-in, void, the danger-side buttons */
.signin {
  max-width: 440px;
  margin: 40px auto;
}
.signin h1 {
  margin-bottom: 10px;
}
.signin form .btn {
  margin-top: 14px;
  width: 100%;
}
.pill.void {
  background: #fde8e8;
  color: var(--danger);
}
.notice.sent {
  background: #eef8f2;
  border-color: #b9e0c8;
}
.notice.void {
  background: #fdf0f0;
  border-color: #f2c4c4;
}
.list tr.is-void td {
  color: var(--muted);
}
.list tr.is-void td.num {
  text-decoration: line-through;
}
.actions .push {
  margin-left: auto;
}

/* A locked invoice shows only what was entered (no grey examples in empty fields). */
fieldset:disabled ::placeholder {
  color: transparent;
}

/* Send to sales: light blue, so it is not mistaken for sending to the customer. */
.btn.sales {
  background: #d9eefc;
  border-color: #a8d4f3;
  color: var(--navy);
}
.btn.sales:hover {
  background: #c6e4fa;
}
