:root {
  font-family: "Segoe UI", Arial, sans-serif;
  color: #18242d;
  background: #edf1f4;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.topbar {
  min-height: 74px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #fff;
  background: #15324a;
  border-bottom: 4px solid #d6a11d;
}

.topbar h1,
.topbar p,
h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 23px;
}

.topbar p {
  margin-top: 3px;
  color: #cbd8e2;
  font-size: 13px;
}

.top-actions,
.toolbar,
.toolbar-group,
.save-actions,
.dialog-actions,
.expense-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.access-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.access-field span {
  font-size: 12px;
  font-weight: 700;
}

.access-field input {
  width: 130px;
  color: #18242d;
}

main {
  width: 100%;
  padding-bottom: 28px;
}

.metadata-band,
.toolbar,
.machine-section,
.reconcile-band,
.save-band {
  padding-left: 18px;
  padding-right: 18px;
}

.metadata-band {
  display: grid;
  grid-template-columns: minmax(190px, 1.3fr) minmax(150px, 0.8fr) minmax(220px, 1.4fr) minmax(150px, 0.7fr);
  gap: 12px;
  padding-top: 16px;
  padding-bottom: 16px;
  background: #fff;
  border-bottom: 1px solid #cfd8df;
}

label span,
.metric span {
  display: block;
  margin-bottom: 5px;
  color: #44545f;
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 36px;
  padding: 6px 9px;
  color: #14232d;
  background: #fff;
  border: 1px solid #aebbc5;
  border-radius: 4px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(36, 115, 166, 0.28);
  outline-offset: 1px;
  border-color: #2473a6;
}

.stepper {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
}

.stepper input {
  min-width: 62px;
  text-align: center;
  border-radius: 0;
}

.stepper button {
  border: 1px solid #aebbc5;
  background: #e8edf1;
  font-size: 20px;
  font-weight: 700;
}

.stepper button:first-child {
  border-radius: 4px 0 0 4px;
}

.stepper button:last-child {
  border-radius: 0 4px 4px 0;
}

.toolbar {
  justify-content: space-between;
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #cfd8df;
}

.button {
  min-height: 36px;
  padding: 7px 12px;
  color: #173349;
  background: #dbe6ed;
  border: 1px solid #9fb2bf;
  border-radius: 4px;
  font-weight: 700;
}

.button:hover {
  background: #cbdbe5;
}

.button.primary {
  color: #fff;
  background: #176a45;
  border-color: #125538;
}

.button.primary:hover {
  background: #125a3a;
}

.button.secondary {
  color: #fff;
  background: #286788;
  border-color: #20546f;
}

.button.secondary:hover {
  background: #205876;
}

.button.danger-subtle {
  color: #842f2f;
  background: #f4e2e2;
  border-color: #d5abab;
}

.machine-section {
  padding-top: 14px;
  padding-bottom: 8px;
}

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

.section-heading h2,
.reconcile-band h2 {
  font-size: 17px;
}

.section-heading p {
  margin: 3px 0 0;
  color: #687781;
  font-size: 12px;
}

.validation-summary {
  min-height: 20px;
  color: #a03131;
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid #bdc9d1;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 6px;
  border-right: 1px solid #d6dee4;
  border-bottom: 1px solid #d6dee4;
  text-align: center;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #fff;
  background: #31546a;
  font-size: 12px;
}

tbody tr:nth-child(even) {
  background: #f5f7f9;
}

td input,
td select {
  min-width: 90px;
  min-height: 32px;
  padding: 4px 6px;
  text-align: right;
}

td .machine-name,
td .note-input {
  min-width: 145px;
  text-align: left;
}

.calculated {
  min-width: 92px;
  font-weight: 700;
}

.money {
  color: #0f5132;
  font-weight: 800;
}

.status-cell {
  min-width: 150px;
  max-width: 190px;
  white-space: normal;
  color: #a03131;
  font-size: 12px;
  font-weight: 700;
}

.status-cell.ok {
  color: #176a45;
}

.inline-financial {
  display: grid;
  grid-template-columns: minmax(95px, 1fr) 32px;
  gap: 4px;
  min-width: 132px;
}

.mini-button,
.hp-button,
.close-button {
  border: 1px solid #9fb2bf;
  background: #e3ebf0;
  border-radius: 4px;
  font-weight: 800;
}

.hp-button {
  min-width: 54px;
  min-height: 32px;
  color: #6b4a00;
  background: #f4e4ad;
  border-color: #d0b766;
}

.hp-button.active {
  color: #fff;
  background: #976a00;
}

.reconcile-band {
  margin-top: 10px;
  padding-top: 14px;
  padding-bottom: 15px;
  background: #fff;
  border-top: 3px solid #31546a;
  border-bottom: 1px solid #c3ced6;
}

.totals-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.digital-totals {
  grid-template-columns: repeat(4, minmax(155px, 1fr));
}

.physical-totals {
  grid-template-columns: repeat(6, minmax(140px, 1fr));
}

.metric {
  min-height: 72px;
  padding: 9px 10px;
  background: #edf2f5;
  border: 1px solid #c4d0d8;
  border-radius: 4px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 23px;
  letter-spacing: 0;
}

.metric.emphasized {
  background: #e4eef4;
  border-color: #7fa4ba;
}

.metric.emphasized strong,
.input-metric input {
  font-size: 27px;
  font-weight: 800;
}

.input-metric input {
  height: 44px;
  text-align: right;
}

.metric.balance.ok {
  color: #0f613d;
  background: #e0f1e8;
  border-color: #74aa8d;
}

.metric.balance.alert {
  color: #932e2e;
  background: #f5e1e1;
  border-color: #cc8d8d;
}

.save-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
}

.save-band span {
  display: block;
  margin-top: 3px;
  color: #64737d;
  font-size: 12px;
}

dialog {
  width: min(440px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid #8295a2;
  border-radius: 6px;
  box-shadow: 0 18px 60px rgba(16, 32, 42, 0.3);
}

dialog::backdrop {
  background: rgba(15, 27, 36, 0.52);
}

.wide-dialog {
  width: min(920px, calc(100vw - 28px));
}

.dialog-form {
  padding: 16px;
}

.dialog-form > label {
  display: block;
  margin-top: 10px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #d1dbe1;
}

.dialog-heading h2 {
  font-size: 18px;
}

.close-button {
  width: 34px;
  height: 34px;
  font-size: 22px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.dialog-error {
  min-height: 18px;
  margin-top: 8px;
  color: #9d2e2e;
  font-weight: 700;
}

.expense-toolbar {
  justify-content: space-between;
  margin: 12px 0;
}

.expense-table input {
  min-width: 150px;
}

.history-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px;
  border-bottom: 1px solid #d5dde3;
}

.reports-message {
  min-height: 22px;
  margin: 10px 0;
  color: #596973;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  padding: 11px 14px;
  color: #fff;
  background: #263d4c;
  border-radius: 4px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #922f2f;
}

@media (max-width: 900px) {
  .topbar,
  .save-band,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .top-actions,
  .save-actions {
    justify-content: space-between;
  }
}

@media (max-width: 540px) {
  .metadata-band,
  .digital-totals,
  .physical-totals {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .top-actions,
  .save-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .access-field {
    justify-content: space-between;
  }

  .access-field input {
    flex: 1;
  }
}
