:root {
  --navy: #1e3a5f;
  --navy-dark: #16304f;
  --accent: #2c5aa0;
  --bg: #f4f6f9;
  --border: #e1e5eb;
  --text: #2a2f36;
  --muted: #6b7583;
  --green: #1e7e42;
  --green-bg: #e6f4ea;
  --red: #b3261e;
  --red-bg: #fbe9e7;
  --amber-bg: #fff6da;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

header.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
}

header.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
}

header.topbar .brand .logo {
  width: 28px; height: 28px;
  background: #c0392b;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

header.topbar .status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.pill {
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 12px;
}
.pill.green { background: var(--green); }

nav.tabs {
  background: #e9edf2;
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  overflow-x: auto;
}

nav.tabs button {
  border: none;
  background: transparent;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

nav.tabs button.active {
  color: var(--navy);
  background: #fff;
  border-bottom: 3px solid var(--accent);
}

main {
  padding: 20px;
  max-width: 1890px;
  margin: 0 auto;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.card h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--navy);
  margin: 0 0 14px 0;
  font-weight: 700;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  margin-top: 10px;
}
label:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #c9d0da;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}
textarea { resize: vertical; min-height: 50px; }

.row { display: flex; gap: 8px; align-items: flex-end; }
.row > * { flex: 1; }

button.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
button.btn.secondary { background: #eef1f5; color: var(--text); border: 1px solid #c9d0da; }
button.btn.danger { background: var(--red-bg); color: var(--red); border: 1px solid #f0c4c0; }
button.btn.small { padding: 4px 10px; font-size: 12px; }
button.btn:hover { filter: brightness(0.95); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  background: #f4f6f9;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 7px 10px; border-bottom: 1px solid #f0f2f5; white-space: nowrap; }
tr:hover td { background: #fafbfc; }
tr.total-row td { font-weight: 700; border-top: 2px solid var(--border); background: #f4f6f9; }
tr.total-row:hover td { background: #f4f6f9; }

.status-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.status-Paid { background: var(--green-bg); color: var(--green); }
.status-Open { background: var(--amber-bg); color: #8a6d00; }
.status-Voided { background: #eee; color: #888; text-decoration: line-through; }

.kpi-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card {
  background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 14px;
}
.kpi-card .label { font-size: 11px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.kpi-card .value { font-size: 22px; font-weight: 700; color: var(--navy); }

.filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; }
.filter-bar .spacer { flex: 1; }

.muted { color: var(--muted); font-size: 12px; }
.subtabs { display: flex; gap: 8px; margin-bottom: 14px; }
.subtabs button {
  border: 1px solid var(--border); background: #fff; padding: 7px 14px; border-radius: 16px;
  font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.subtabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.bl-preview {
  border: 1px dashed #c9d0da; border-radius: 6px; min-height: 300px;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
  padding: 20px;
}
.bl-doc { text-align: left; width: 100%; font-size: 13px; }
.bl-doc h3 { margin: 0 0 4px 0; color: var(--navy); }
.bl-doc table { margin-top: 10px; }
.bl-doc .total-line { font-weight: 700; font-size: 15px; margin-top: 10px; text-align: right; }

.right { text-align: right; }
.mt { margin-top: 10px; }
.hidden { display: none !important; }

tr.payment-row td { background: var(--green-bg); font-weight: 600; }
tr.payment-row:hover td { background: var(--green-bg); }

.notes-cell {
  width: 1.4cm;
  max-width: 1.4cm;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.notes-cell:hover {
  background: var(--amber-bg);
  text-decoration: underline;
}

.ticketno-cell {
  width: 1.12cm;
  max-width: 1.12cm;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  color: var(--accent);
  text-decoration: underline;
}
.ticketno-cell:hover {
  background: var(--amber-bg);
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff; border-radius: 8px; padding: 20px;
  max-width: 420px; width: 90%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.modal-box h3 {
  margin: 0 0 10px 0; color: var(--navy);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.modal-box p {
  white-space: pre-wrap; word-break: break-word;
  font-size: 14px; margin: 0 0 16px 0;
}

@media print {
  header.topbar, nav.tabs, .no-print { display: none !important; }
  main { padding: 0; }
  .card { border: none; box-shadow: none; }
}
