:root {
  --navy: #07233d;
  --header: #eaf4f8;
  --blue: #1677b8;
  --green: #21a67a;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ec;
  --paper: #ffffff;
  --wash: #f4f8fb;
  --danger: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--wash);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  background: var(--header);
  color: var(--navy);
  border-bottom: 4px solid var(--blue);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 172px;
  height: 52px;
  object-fit: contain;
  object-position: left center;
}

nav { display: flex; gap: 14px; }
a { color: var(--blue); font-weight: 700; text-decoration: none; }
nav a { color: var(--navy); }

.logout-form { margin: 0; }

.logout-form button {
  min-height: 0;
  padding: 0;
  color: var(--navy);
  background: transparent;
}

.logout-form button:hover {
  color: var(--blue);
  background: transparent;
}

main {
  width: min(1480px, calc(100vw - 32px));
  margin: 22px auto 48px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary div, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary div {
  padding: 16px;
  border-top: 3px solid var(--blue);
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.summary strong {
  display: block;
  margin-top: 4px;
  color: var(--navy);
  font-size: 24px;
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

h1, h2 {
  margin: 0 0 14px;
  color: var(--navy);
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }

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

.panel-title h2 { margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.badge.ok {
  color: #075e45;
  background: #d8f7ea;
  border: 1px solid #91dfbd;
}

.badge.error {
  color: #981b1b;
  background: #fee2e2;
  border: 1px solid #fca5a5;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input, textarea, select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
  border: 1px solid #bcc9d6;
  border-radius: 6px;
  font: inherit;
}

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

button {
  min-height: 36px;
  padding: 8px 12px;
  color: white;
  background: var(--blue);
  border: 0;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}

button:hover { background: #185abc; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--header);
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
  margin: 0;
}

.login-panel {
  padding: 28px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(7, 35, 61, 0.12);
}

.login-logo {
  display: block;
  width: 220px;
  height: 74px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 18px;
}

.login-error {
  margin: -4px 0 12px;
  color: var(--danger);
  font-weight: 800;
}

.actions, .row {
  display: flex;
  gap: 10px;
  align-items: end;
}

.actions form { display: inline; }

.row > label { flex: 1; }

.items { overflow-x: auto; margin-bottom: 12px; }
.item-head, .item-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) 80px 90px 110px 90px minmax(220px, 1.3fr);
  gap: 8px;
  min-width: 880px;
}
.item-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}
.item-row { margin-bottom: 8px; }

.table { display: grid; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tr {
  display: grid;
  grid-template-columns: 1fr 1.4fr .9fr .9fr .8fr 2fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.compact .tr { grid-template-columns: 1.3fr .8fr .8fr; }
.tr:last-child { border-bottom: 0; }
.tr.head {
  color: white;
  background: var(--navy);
  font-weight: 800;
}

mark.status {
  display: inline-block;
  min-width: 96px;
  padding: 4px 8px;
  color: var(--navy);
  background: #e8f1ff;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}
.status.paid { background: #dcfce7; color: #166534; }
.status.partially_paid { background: #fef3c7; color: #92400e; }
.status.cancelled { background: #fee2e2; color: var(--danger); }

.inline-pay {
  display: grid;
  grid-template-columns: 140px 90px 78px;
  gap: 6px;
}
.inline-pay input { min-height: 32px; padding: 5px 7px; }

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

@media (max-width: 900px) {
  .topbar, .actions, .row { align-items: stretch; flex-direction: column; }
  .brand-lockup { align-items: flex-start; flex-direction: column; gap: 8px; }
  .summary, .two { grid-template-columns: 1fr; }
  .tr { grid-template-columns: 1fr; }
  .tr.head { display: none; }
}
