/* ===== Opo-Med Item Allocation demo ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --orange: #f5a623;
  --orange-soft: #fdf3e2;
  --green: #7a9e63;
  --green-soft: #eef3e8;
  --green-border: #a9c294;
  --blue: #4a90d9;
  --text: #3c3c3c;
  --text-soft: #8a8a8a;
  --line: #e6e6e6;
  --bg: #f2f2f2;
  --card: #fafafa;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  height: 100vh;
}

/* ===== Top bar ===== */
.topbar {
  height: 48px; background: #e9e9e9; border-bottom: 1px solid #ddd;
  display: flex; align-items: center; justify-content: space-between; padding: 0 14px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #3aa6b9, #2d7fa8);
  display: flex; align-items: center; justify-content: center;
}
.logo-text { font-weight: 700; font-size: 15px; }
.user-chip { display: flex; flex-direction: column; margin-left: 18px; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 9px; letter-spacing: .5px; color: var(--text-soft); }
.topbar-right { display: flex; gap: 6px; }
.icon-btn { background: none; border: none; cursor: pointer; padding: 6px; border-radius: 6px; }
.icon-btn:hover { background: #ddd; }

/* ===== Layout ===== */
.layout { display: flex; height: calc(100vh - 48px); }
.sidebar {
  width: 150px; background: #ececec; padding: 14px 0;
  display: flex; flex-direction: column; justify-content: space-between;
  border-right: 1px solid #e0e0e0;
}
.sidebar ul { list-style: none; }
.sidebar li {
  padding: 10px 18px; cursor: pointer; color: #555;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.sidebar li:hover { background: #e2e2e2; }
.sidebar li.active { color: var(--orange); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; font-size: 13px; opacity: .75; }
.need-help { padding: 12px 18px; color: #666; font-size: 12px; }

.content { flex: 1; overflow: auto; padding: 14px 18px; }

/* ===== Toolbar ===== */
.page-toolbar { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
.chip {
  background: #e7e7e7; border: none; border-radius: 10px; padding: 9px 14px;
  font-size: 13px; font-weight: 600; color: #444; cursor: pointer;
}
.chip.square { padding: 9px 11px; }
.chip.select { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.sel-chev { color: #999; font-size: 10px; }

/* ===== Page grid ===== */
.page-grid { display: grid; grid-template-columns: 230px 1fr 260px; gap: 14px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.card-head { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-ico { opacity: .7; }

.booking-card {
  background: var(--green-soft); border: 1px solid var(--green-border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 12px; color: #4c5b40;
}
.bd-line1 { font-weight: 700; font-size: 14px; }
.bd-line2 { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.ampm { font-weight: 400; font-size: 11px; float: right; }
.bd-doctor { font-weight: 700; margin-top: 6px; }
.bd-sub { font-size: 11.5px; color: #6a755f; }
.loan-pill {
  display: inline-block; margin-top: 8px; padding: 3px 14px; border: 1px solid var(--green);
  border-radius: 6px; color: var(--green); font-size: 12px;
}
.surgery-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 12px; color: #5b5b3a; }
.sc-row { display: flex; gap: 8px; margin-bottom: 10px; line-height: 1.35; }

.col-mid .ship-days { margin-left: auto; text-align: right; font-size: 11px; color: var(--orange); font-weight: 400; }
.ship-date { color: var(--blue); }
.donut-wrap { display: flex; align-items: center; justify-content: center; padding: 8px 0 4px; gap: 30px; }
.donut {
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--card) 62%, transparent 62.5% 100%), #efefef;
}
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: #888; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; border: 1px solid #ccc; }
.lg-assigned { background: #f8e2c0; }
.lg-shipped { background: #dfe9d5; }

.ship-info-row { display: flex; justify-content: space-between; background: #f1f1f1; border-radius: 8px; padding: 10px 12px; font-size: 12px; }
.link { color: var(--blue); cursor: pointer; }

/* ===== Tables ===== */
.table-card { margin-bottom: 14px; padding-bottom: 4px; }
.table-actions { margin-left: auto; display: flex; gap: 6px; }
.mini-btn { background: #ececec; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; cursor: pointer; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 10px; color: #9a9a9a; font-weight: 600; letter-spacing: .4px; padding: 8px 8px; }
td { padding: 10px 8px; font-size: 12px; border-top: 1px solid #efefef; color: #555; }
.cb { width: 26px; }
.kebab { background: none; border: none; font-size: 15px; color: #777; cursor: pointer; }

/* ===== Modal ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(70, 70, 70, .55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  width: 400px; max-width: calc(100vw - 40px); background: #fff; border-radius: 14px;
  padding: 18px 22px 22px; box-shadow: 0 18px 60px rgba(0,0,0,.28);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; color: #999; cursor: pointer; line-height: 1; }

.product-line { display: flex; align-items: baseline; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.product-ico { opacity: .6; }
.product-name { font-weight: 700; font-size: 13px; }
.product-code { color: #8a8a8a; font-size: 12.5px; }

.consumables-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.consumables-label { font-size: 12.5px; color: #666; }
.scan-btn {
  background: #fff; border: 1px solid #ddd; border-radius: 9px; padding: 7px 9px;
  cursor: pointer; color: #555; display: flex; align-items: center;
}
.scan-btn.armed { border-color: var(--green); color: var(--green); box-shadow: 0 0 0 3px rgba(122,158,99,.15); }

/* Scan status banner */
.scan-status {
  border-radius: 9px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 10px;
  display: flex; align-items: flex-start; gap: 8px; line-height: 1.4;
}
.scan-status.ok { background: #eef6e9; color: #3f6b2e; border: 1px solid #c4dcb4; }
.scan-status.error { background: #fdecec; color: #a13030; border: 1px solid #f0c4c4; }
.scan-status.warn { background: #fdf3e2; color: #8a6410; border: 1px solid #ecd9ab; }

/* Inputs */
.inputs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.input-row { position: relative; }
.lot-input {
  width: 100%; border: 1px solid #e2e2e2; border-radius: 10px; padding: 13px 72px 13px 14px;
  font-size: 13px; color: var(--text); outline: none; background: #fff;
  transition: border-color .15s, box-shadow .15s, background .3s;
}
.lot-input::placeholder { color: #b5b5b5; }
.lot-input:focus { border-color: #bbb; }
.lot-input.flash-ok { background: #eaf5e2; border-color: var(--green); }
.lot-input.flash-bad { background: #fdecec; border-color: #cc4b4b; }
.lot-input.filled-by-scan { border-color: #cfe0c2; }
/* Expired stock: the whole line stays red */
.lot-input.line-critical, .lot-input.line-critical:focus {
  background: #fbdede; border-color: #c43a3a; color: #7c1f1f; font-weight: 600;
}

/* Per-row validation icons — two columns: date (left), GTIN (right) */
.row-icon {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.icon-gtin { right: 12px; }
.icon-date { right: 40px; }
.row-icon.ok { background: #e6f2dc; color: #4c7a35; }
.row-icon.bad { background: #fbe3e3; color: #b53a3a; }
.row-icon.warn { background: #fdf0d4; color: #a97a12; }
.row-icon.none { background: #efefef; color: #a5a5a5; }

/* Wrong-product warning popup */
.warn-overlay {
  position: fixed; inset: 0; z-index: 120; background: rgba(40, 40, 40, .45);
  display: flex; align-items: center; justify-content: center;
}
.warn-overlay[hidden] { display: none; }
.warn-box {
  width: 360px; max-width: calc(100vw - 48px); background: #fff; border-radius: 14px;
  padding: 22px 24px; text-align: center; box-shadow: 0 18px 60px rgba(0,0,0,.3);
}
.warn-icon {
  width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 50%;
  background: #fbe3e3; color: #b53a3a; display: flex; align-items: center; justify-content: center;
}
.warn-box h3 { font-size: 14.5px; margin-bottom: 8px; color: #8f2f2f; }
.warn-box p { font-size: 12.5px; color: #555; line-height: 1.5; margin-bottom: 16px; }
.warn-btn { width: 100%; }

/* Critical (expired stock) variant of the popup */
.warn-box.critical { border: 2px solid #c43a3a; box-shadow: 0 18px 60px rgba(160,20,20,.35); }
.warn-box.critical .warn-icon { background: #c43a3a; color: #fff; }
.warn-box.critical h3 { color: #b02525; text-transform: uppercase; letter-spacing: .3px; }
.warn-box.critical .warn-btn { background: #c43a3a; border-color: #c43a3a; }

.modal-foot { display: flex; justify-content: space-between; gap: 12px; }
.btn { flex: 1; padding: 12px 0; border-radius: 10px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.btn-outline { background: #fff; border: 1px solid #cfd8ea; color: var(--blue); }
.btn-primary { background: var(--blue); border: 1px solid var(--blue); color: #fff; }
.btn-primary:disabled { background: #e2e2e2; border-color: #e2e2e2; color: #9a9a9a; cursor: default; }

/* ===== Dev bar ===== */
.dev-toggle {
  position: fixed; bottom: 14px; right: 14px; z-index: 90;
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid #ccc;
  background: #fff; cursor: pointer; font-size: 16px; box-shadow: 0 3px 10px rgba(0,0,0,.15);
}
.dev-bar {
  position: fixed; bottom: 62px; right: 14px; z-index: 90;
  background: #2f2f2f; color: #eee; border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.dev-bar[hidden] { display: none; }
.dev-title { font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: #aaa; }
.dev-bar button {
  background: #444; color: #eee; border: 1px solid #555; border-radius: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 12px; text-align: left;
}
.dev-bar button:hover { background: #555; }
.dev-raw {
  max-width: 260px; font-family: ui-monospace, Menlo, monospace; font-size: 10.5px;
  color: #9fd49f; border-top: 1px solid #4a4a4a; padding-top: 8px; word-break: break-all;
}

/* ===== Access gate ===== */
.gate {
  position: fixed; inset: 0; z-index: 200; background: #eef1f4;
  display: flex; align-items: center; justify-content: center;
}
.gate[hidden] { display: none; }
.gate-box {
  background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.12);
  padding: 30px 34px; width: 320px; text-align: center;
}
.gate-logo { font-weight: 700; font-size: 18px; margin-bottom: 10px; }
.gate-box p { font-size: 12.5px; color: #777; margin-bottom: 16px; line-height: 1.5; }
.gate-box input {
  width: 100%; border: 1px solid #ddd; border-radius: 9px; padding: 11px 12px;
  font-size: 13px; margin-bottom: 10px; outline: none;
}
.gate-box input:focus { border-color: var(--blue); }
.gate-box button {
  width: 100%; background: var(--blue); color: #fff; border: none; border-radius: 9px;
  padding: 11px 0; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.gate-error { color: #a13030; font-size: 12px; margin-top: 8px; }
