@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap");

:root {
  --blue: #18488a;
  --blue-dark: #123563;
  --navy: #052346;
  --bg: #f5f9ff;
  --card-bg: #ffffff;
  --border: #dfebff;
  --text: #323232;
  --muted: #5b6172;
  --danger: #a80000;
  --radius: 4px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Montserrat", "Segoe UI", "Open Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

/* ---------- Header / nav ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}

.brand-logo { display: block; height: 22px; width: auto; color: var(--navy); }

.brand .brand-name {
  font-size: 15px;
  line-height: 1.15;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.mainnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.mainnav a {
  text-decoration: none;
  color: var(--navy);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
}

.mainnav a:hover { background: #eef1fa; }
.mainnav a.active { background: var(--blue); color: #fff; }

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
}

.account button {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--navy);
}

.account button:hover { background: #eef1fa; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.demo-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  background: #fff4e0;
  border-bottom: 1px solid #f0d9a8;
  color: #7a5200;
  font-size: 12.5px;
  padding: 8px 20px;
  text-align: center;
}

.demo-banner button {
  background: #fff;
  border: 1px solid #e0c07a;
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 12px;
  color: #7a5200;
  cursor: pointer;
  white-space: nowrap;
}

.demo-banner button:hover { background: #fdf0d5; }

/* ---------- Generic building blocks ---------- */

h1 {
  font-size: 22px;
  color: var(--navy);
  margin: 0 0 20px;
}

h2 {
  font-size: 15px;
  color: var(--navy);
  margin: 0 0 10px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.grid {
  display: grid;
  gap: 20px;
}

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

@media (max-width: 900px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

label {
  display: block;
  font-size: 12.5px;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 4px;
}

.field { margin-bottom: 16px; }
.required::after { content: " *"; color: var(--danger); }

input[type="text"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(56, 96, 178, 0.15);
}

input[readonly] { background: #eef1f7; color: var(--muted); }

.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.error-text { font-size: 11.5px; color: var(--danger); margin-top: 4px; min-height: 14px; }

button.btn {
  background: var(--blue);
  color: #fff;
  border: 1px solid var(--blue-dark);
  border-radius: var(--radius);
  min-height: 48px;
  padding: 13px 26px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

button.btn:hover { background: var(--blue-dark); }
button.btn:disabled { opacity: 0.55; cursor: default; }

button.btn.secondary {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--border);
}
button.btn.secondary:hover { background: #eef1fa; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 18px;
  max-width: 640px;
  margin: 40px auto 0;
}

.home-btn {
  display: block;
  text-decoration: none;
  background: var(--blue);
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--blue-dark);
}

.home-btn:hover { background: var(--blue-dark); }

.home-hero {
  text-align: center;
  color: var(--navy);
  margin-top: 30px;
}

.home-hero p { color: var(--muted); font-size: 13.5px; }

/* ---------- Search / select lists ---------- */

.search-box { position: relative; margin-bottom: 10px; }
.search-box input { padding-right: 32px; }
.search-box .icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--blue);
  pointer-events: none;
}

.pick-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
}

.pick-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid #eef1f7;
  cursor: pointer;
  font-size: 14.5px;
}

.pick-item:last-child { border-bottom: none; }
.pick-item:hover { background: #f3f6fc; }
.pick-item.selected { background: #dbe6fb; border-left: 3px solid var(--navy); }
.pick-item .title { font-weight: 600; color: var(--text); }
.pick-item .subtitle { color: var(--muted); }
.pick-empty { padding: 14px; font-size: 12.5px; color: var(--muted); text-align: center; }

.selected-chip {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--navy);
  background: #eef1fa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.selected-chip strong { color: var(--navy); }

/* ---------- Notices ---------- */

.notice {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 18px;
  display: none;
}
.notice.show { display: block; }
.notice.success { background: #e6f4ea; color: #1e6b34; border: 1px solid #b6dfc2; }
.notice.error { background: #fbe9e9; color: #9c2020; border: 1px solid #f0c2c2; }
.notice.info { background: #eaf1fb; color: var(--navy); border: 1px solid var(--border); }

/* ---------- Auth gate ---------- */

#authGate {
  max-width: 420px;
  margin: 80px auto;
  text-align: center;
}
#authGate .card { padding: 34px 28px; }
#authGate p { color: var(--muted); font-size: 13.5px; }

[data-requires-auth] { display: none; }

/* ---------- Printable weighing ticket ---------- */

#ticketOverlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 40, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
#ticketOverlay.show { display: flex; }

.ticket-modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 0;
}

.ticket-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}

#ticket {
  padding: 26px 30px;
}

.ticket-header {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.ticket-header img.ticket-logo { height: 30px; width: auto; color: var(--navy); }
.ticket-header .ticket-title { margin-left: auto; text-align: right; }
.ticket-header .ticket-title .uid { font-size: 18px; font-weight: 700; color: var(--navy); }
.ticket-header .ticket-title .dt { font-size: 12px; color: var(--muted); }

.ticket-section { margin-bottom: 16px; }
.ticket-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--blue);
  margin: 0 0 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.ticket-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; }
.ticket-row .k { color: var(--muted); }
.ticket-row .v { font-weight: 600; }

.ticket-weights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.ticket-weight-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
}
.ticket-weight-box .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.ticket-weight-box .val { font-size: 18px; font-weight: 700; color: var(--navy); }

.ticket-sign { margin-top: 26px; display: flex; justify-content: space-between; gap: 30px; }
.ticket-sign-line { flex: 1; text-align: center; font-size: 11.5px; color: var(--muted); }
.ticket-sign-line .line { border-top: 1px solid var(--text); margin-bottom: 6px; height: 34px; }

@media print {
  body * { visibility: hidden; }
  #ticket, #ticket * { visibility: visible; }
  #ticket {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 0;
  }
  .ticket-modal-actions, .topbar, .demo-banner, #authGate { display: none !important; }
}
