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

:root {
  font-family: 'Montserrat', Arial, sans-serif;
  color: #3f424c;
  background: #f4f7fa;
  font-synthesis: none;
  --brand: #0aa8cc;
  --brand-deep: #0795b5;
  --brand-soft: #eaf7fb;
  --ink: #42444e;
  --navy: #17253e;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f7fa; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.app-header {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  background: #fff;
  border-bottom: 1px solid #e4e9ee;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup img { width: 34px; height: 42px; object-fit: contain; }
.brand-lockup strong { display: block; font-size: 16px; color: var(--ink); }
.brand-lockup span { display: block; font-size: 11px; color: #89919d; margin-top: 3px; }
.app-header nav { display: flex; gap: 8px; }
.app-header nav button {
  border: 0;
  background: transparent;
  color: #5a606b;
  padding: 10px 13px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
}
.app-header nav button:hover { background: #eef7fa; color: var(--brand-deep); }

.page-shell {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  align-items: start;
}
.control-panel, .preview-panel, .verify-card-panel, .records-panel {
  background: white;
  border: 1px solid #e4e9ee;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(23, 37, 62, .06);
}
.control-panel { padding: 24px; }
.preview-panel { padding: 18px; overflow: hidden; }
.section-heading, .preview-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}
.eyebrow { display: block; font-size: 10px; letter-spacing: .18em; color: var(--brand-deep); font-weight: 800; }
h1, h2, h3 { margin: 0; color: var(--ink); }
h1 { font-size: 24px; margin-top: 5px; }
h2 { font-size: 16px; margin-top: 4px; }
.preview-heading > span { font-size: 10px; color: #8e96a2; text-align: right; max-width: 260px; line-height: 1.5; }

.card-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 700; color: #5a606b; }
.card-form input, .card-form textarea, .verify-input-row input {
  width: 100%;
  border: 1px solid #dbe1e7;
  border-radius: 10px;
  padding: 11px 12px;
  color: #343842;
  background: #fff;
  outline: none;
  transition: .2s ease;
}
.card-form input:focus, .card-form textarea:focus, .verify-input-row input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 168, 204, .1);
}
.card-form textarea { resize: vertical; min-height: 95px; line-height: 1.45; }
.full-row { grid-column: 1 / -1; }
.upload-field small { font-size: 10px; line-height: 1.5; color: #969da8; font-weight: 500; }
.form-subsection {
  grid-column: 1 / -1;
  margin-top: 2px;
  padding-top: 4px;
}
.form-subsection strong {
  display: block;
  font-size: 12px;
  color: #3f4751;
  margin-bottom: 2px;
}
.form-subsection span {
  display: block;
  font-size: 10px;
  color: #97a0ab;
  line-height: 1.5;
}
.form-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 4px; }
.primary, .secondary, .ghost, .table-action {
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 700;
  font-size: 12px;
}
.primary { background: linear-gradient(135deg, #09b5d7, #0699bd); color: white; }
.secondary { background: #17253e; color: white; }
.ghost { background: #eef3f6; color: #4d5662; }
.form-message {
  padding: 10px 12px;
  background: #f3f8fa;
  border: 1px solid #dcecf1;
  color: #53606a;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.5;
}

.card-scroll { overflow: auto; padding-bottom: 6px; }
#print-card { width: 856px; height: 540px; }
.id-card {
  width: 856px;
  height: 540px;
  position: relative;
  overflow: hidden;
  background: #fff;
  color: #444750;
  font-family: 'Montserrat', Arial, sans-serif;
  box-shadow: 0 3px 15px rgba(25, 55, 80, .12);
}
.card-top-banner {
  position: absolute;
  left: -2px;
  top: -2px;
  width: 574px;
  height: 126px;
  color: white;
  overflow: hidden;
}
.card-top-banner-art {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;

  left: -30px;
  top: 0;
}
.medical-title { position: absolute; left: 18px; top: 16px; font-size: 39px; line-height: 1; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.identification-title { position: absolute; left: 18px; top: 58px; font-size: 28px; line-height: 1; font-weight: 500; letter-spacing: -.02em; white-space: nowrap; }
.tagline { position: absolute; left: 19px; top: 92px; font-size: 11px; font-weight: 500; letter-spacing: .26em; white-space: nowrap; }
.skymed-logo { position: absolute; right: 36px; top: 16px; width: 258px; height: 106px; object-fit: contain; object-position: center; }
.patient-photo-frame {
  position: absolute;
  left: 27px;
  top: 151px;
  width: 220px;
  height: 288px;
  border: 4px solid #d8edf7;
  border-radius: 14px;
  overflow: hidden;
  background: #58a9d3;
}
.patient-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.patient-photo-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: rgba(255,255,255,.75); font-size: 20px; font-weight: 700; letter-spacing: .18em; }
.watermark-mark { position: absolute; right: 20px; top: 154px; width: 225px; height: 325px; object-fit: contain; opacity: .055; filter: saturate(.7); }
.card-fields { position: absolute; left: 282px; top: 177px; width: 388px; z-index: 2; }
.field-label { font-size: 13px; line-height: 1.2; font-weight: 700; color: #4a4d56; }
.name-label { margin-bottom: 5px; }
.patient-name { width: 430px; max-width: 430px; font-size: 41px; line-height: 1.02; font-weight: 800; color: #41434c; letter-spacing: -.035em; white-space: nowrap; overflow: visible; text-overflow: clip; }
.dob-line { display: flex; gap: 22px; align-items: baseline; margin-top: 11px; }
.dob-value { font-size: 13px; font-weight: 600; color: #464952; }
.blue-rule { height: 1.5px; background: #3aa8dc; margin-top: 7px; width: 340px; }
.condition-label { margin-top: 20px; }
.condition-name { margin-top: 8px; font-size: 39px; line-height: 1.02; font-weight: 800; color: #41434c; letter-spacing: -.035em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.warning-text { margin-top: 12px; width: 400px; font-size: 12.3px; line-height: 1.38; font-weight: 600; color: #464953; }
.device-note {
  position: absolute;
  left: 28px;
  bottom: 16px;
  width: 452px;
  height: 52px;
  border-radius: 15px;
  background: #dff0f9;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 13px;
}
.device-note img { width: 26px; height: 37px; object-fit: contain; }
.device-divider { width: 1.5px; height: 34px; background: #41a4d1; }
.device-title { color: #17253e; font-size: 13.4px; font-weight: 800; letter-spacing: .12em; }
.device-subtitle { margin-top: 2px; color: #17253e; font-size: 7.7px; font-weight: 500; letter-spacing: .04em; }
.barcode-area {
  position: absolute;
  right: 30px;
  bottom: 13px;
  width: 308px;
  height: 58px;
  border: 0;
  background: transparent;
  padding: 0;
  display: grid;
  grid-template-rows: 38px 18px;
  align-items: start;
  z-index: 5;
}
.barcode-svg { width: 100%; height: 38px; display: block; }
.barcode-serial { font-family: 'Montserrat', Arial, sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .25em; color: #17253e; text-align: center; line-height: 18px; }
.barcode-clickable:hover { filter: brightness(.92); }

.status-chip, .count-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  white-space: nowrap;
}
.status-chip.printed { background: #dff7e9; color: #187a45; }
.status-chip.not-printed { background: #fff1dc; color: #9b5d00; }
.status-chip.small { padding: 5px 8px; font-size: 9px; }
.count-chip { background: #edf5f8; color: #60717b; }

.single-page { padding: 28px; }
.verify-card-panel, .records-panel { max-width: 1050px; margin: 0 auto; padding: 28px; }
.verify-card-panel { max-width: 720px; }
.muted { color: #838b96; font-size: 13px; line-height: 1.6; }
.verify-input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 20px; }
.verify-input-row input { font-size: 18px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.verify-result { margin-top: 22px; padding: 22px; border-radius: 16px; display: flex; gap: 18px; align-items: flex-start; border: 1px solid; }
.verify-result.is-printed { background: #f0fbf5; border-color: #c7eed9; }
.verify-result.is-not-printed { background: #fff9ee; border-color: #f6ddb1; }
.verify-status-icon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; color: white; font-size: 30px; font-weight: 800; flex: 0 0 auto; }
.is-printed .verify-status-icon { background: #22a65e; }
.is-not-printed .verify-status-icon { background: #e99a20; }
.verify-status-title { font-size: 21px; font-weight: 800; color: #343944; }
.verify-serial { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 4px; color: #4a5662; font-weight: 700; }
.verify-name { margin-top: 9px; font-size: 16px; font-weight: 700; color: #454a53; }
.verify-meta { margin-top: 10px; font-size: 11px; color: #7e8792; line-height: 1.7; }
.verify-error { margin-top: 18px; background: #fff0f0; color: #a34444; border: 1px solid #f0caca; padding: 12px 14px; border-radius: 10px; font-size: 12px; }

.records-page { overflow-x: auto; }
.records-table-wrap { overflow: auto; border: 1px solid #e7ebef; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { padding: 12px 13px; text-align: left; border-bottom: 1px solid #edf0f3; font-size: 11px; }
th { background: #f7fafb; color: #7d858f; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
td { color: #4a5059; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: #233043; }
.table-action { padding: 7px 10px; background: #eef7fa; color: #1685a3; }
.empty-state { padding: 34px; text-align: center; color: #9299a3; font-size: 12px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(23, 37, 62, .42); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal-card { width: min(440px, 100%); background: white; border-radius: 18px; padding: 24px; box-shadow: 0 20px 60px rgba(13, 31, 52, .25); }
.modal-card h3 { font-size: 20px; }
.modal-card p { color: #737b86; font-size: 12px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

@media (max-width: 1080px) {
  .page-shell { grid-template-columns: 1fr; }
  .control-panel { max-width: 856px; }
}
@media (max-width: 720px) {
  .app-header { padding: 0 14px; height: auto; min-height: 72px; gap: 10px; flex-wrap: wrap; }
  .app-header nav { width: 100%; padding-bottom: 8px; overflow-x: auto; }
  .page-shell, .single-page { padding: 14px; }
  .control-panel, .preview-panel, .verify-card-panel, .records-panel { border-radius: 14px; padding: 16px; }
  .card-form { grid-template-columns: 1fr; }
  .full-row { grid-column: auto; }
  .verify-input-row { grid-template-columns: 1fr; }
}

@media print {
  @page { size: 85.6mm 53.98mm; margin: 0; }
  html, body { width: 85.6mm; height: 53.98mm; margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body { overflow: hidden; }
  body * { visibility: hidden !important; }
  #print-card, #print-card * { visibility: visible !important; }
  #print-card {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 85.6mm !important;
    height: 53.98mm !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  #print-card .id-card {
    width: 856px !important;
    height: 540px !important;
    transform: scale(.378);
    transform-origin: 0 0;
    box-shadow: none !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* Multi-company system UI. The printable card CSS above remains unchanged. */
.system-lockup { min-width: 220px; }
.system-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #08b4d7, #088caf);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  box-shadow: 0 8px 18px rgba(10, 168, 204, .18);
}
.header-user {
  min-width: 220px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.header-user span {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #7b8490;
  font-size: 10px;
  font-weight: 600;
}
.header-user button {
  border: 1px solid #e2e8ed;
  background: #fff;
  color: #4d5662;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 700;
}
.header-user button:hover { background: #f3f7f9; }

.company-picker {
  border: 1px solid #e2e8ed;
  border-radius: 14px;
  padding: 14px;
  background: #fbfdfe;
}
.company-picker-heading { margin-bottom: 11px; }
.company-picker-heading strong {
  display: block;
  color: #424953;
  font-size: 12px;
}
.company-picker-heading span {
  display: block;
  margin-top: 3px;
  color: #929ba6;
  font-size: 10px;
  line-height: 1.45;
}
.company-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.company-option {
  position: relative;
  min-height: 92px;
  border: 1px solid #dfe6eb;
  border-radius: 12px;
  background: #fff;
  padding: 10px 11px 9px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 7px;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.company-option:hover {
  border-color: #9bd7e7;
  transform: translateY(-1px);
}
.company-option.selected {
  border-color: #0aa8cc;
  box-shadow: 0 0 0 3px rgba(10, 168, 204, .09);
}
.company-logo-box {
  width: 100%;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}
.company-logo-box img {
  max-width: 100%;
  max-height: 44px;
  object-fit: contain;
  object-position: left center;
}
.company-option-name {
  color: #46505a;
  font-size: 10px;
  font-weight: 800;
}
.company-check {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #0aa8cc;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  opacity: 0;
  transform: scale(.8);
  transition: .18s ease;
}
.company-option.selected .company-check { opacity: 1; transform: scale(1); }
.verify-company {
  display: inline-flex;
  margin-top: 8px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(10, 168, 204, .1);
  color: #087f9c;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.login-page {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 10% 10%, rgba(41, 183, 216, .14), transparent 34%),
    radial-gradient(circle at 88% 88%, rgba(31, 76, 112, .10), transparent 33%),
    linear-gradient(145deg, #f7fbfd 0%, #eef5f8 55%, #f8fafb 100%);
}
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}
.login-orb-one {
  width: 330px;
  height: 330px;
  left: -130px;
  top: -130px;
  background: linear-gradient(145deg, rgba(0, 181, 227, .20), rgba(0, 143, 190, .03));
}
.login-orb-two {
  width: 420px;
  height: 420px;
  right: -190px;
  bottom: -210px;
  background: linear-gradient(145deg, rgba(65, 69, 80, .10), rgba(0, 181, 227, .05));
}
.login-card {
  position: relative;
  z-index: 2;
  width: min(470px, 100%);
  background: rgba(255, 255, 255, .95);
  border: 1px solid rgba(218, 228, 234, .92);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 26px 70px rgba(28, 55, 76, .13);
  backdrop-filter: blur(16px);
}
.login-brand-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 15px;
  border-radius: 16px;
  background: #f8fbfc;
  border: 1px solid #e7eef2;
}
.login-brand-tile {
  height: 60px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.login-brand-tile img {
  max-width: 100%;
  max-height: 54px;
  object-fit: contain;
}
.login-brand-divider { width: 1px; height: 34px; background: #dfe8ed; }
.login-copy { margin-top: 25px; }
.login-copy h1 { margin-top: 6px; font-size: 29px; letter-spacing: -.025em; }
.login-copy p {
  margin: 8px 0 0;
  color: #7e8792;
  font-size: 12px;
  line-height: 1.6;
}
.login-form { display: grid; gap: 15px; margin-top: 24px; }
.login-form label {
  display: grid;
  gap: 7px;
  color: #4d5560;
  font-size: 11px;
  font-weight: 800;
}
.login-form input {
  width: 100%;
  height: 48px;
  border: 1px solid #dbe4e9;
  border-radius: 12px;
  padding: 0 13px;
  background: #fff;
  color: #343a43;
  outline: none;
  font-size: 12px;
  transition: .18s ease;
}
.login-form input:focus {
  border-color: #0aa8cc;
  box-shadow: 0 0 0 4px rgba(10, 168, 204, .10);
}
.password-field { position: relative; }
.password-field input { padding-right: 64px; }
.password-field button {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: #eef6f8;
  color: #26829a;
  padding: 7px 9px;
  font-size: 9px;
  font-weight: 800;
}
.login-submit {
  height: 49px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #07b4d7, #078ead);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(8, 158, 192, .22);
}
.login-submit:hover { filter: brightness(.98); }
.login-error, .auth-global-error {
  border: 1px solid #f2cccc;
  border-radius: 10px;
  background: #fff4f4;
  color: #a34545;
  padding: 10px 12px;
  font-size: 10px;
  line-height: 1.5;
}
.login-footnote {
  margin-top: 19px;
  padding-top: 16px;
  border-top: 1px solid #edf1f3;
  color: #a0a8b1;
  text-align: center;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
}
.auth-global-error {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
}
.auth-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: #f5f9fb;
  color: #6f7984;
  font-size: 11px;
  font-weight: 700;
}
.auth-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #dceaf0;
  border-top-color: #0aa8cc;
  animation: auth-spin .8s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .app-header { height: auto; min-height: 78px; flex-wrap: wrap; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .system-lockup, .header-user { min-width: 0; }
  .header-user { margin-left: auto; }
  .app-header nav { order: 3; width: 100%; justify-content: center; }
}

@media (max-width: 720px) {
  .company-options { grid-template-columns: 1fr; }
  .login-page { padding: 16px; }
  .login-card { padding: 20px; border-radius: 20px; }
  .login-brand-row { gap: 8px; padding: 10px; }
  .login-brand-tile { height: 48px; }
  .login-copy h1 { font-size: 24px; }
  .header-user span { display: none; }
}
