:root {
  color-scheme: light;
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --navy: #102a43;
  --navy-deep: #071d30;
  --blue: #1677ff;
  --blue-dark: #095fd1;
  --cyan: #24b6c9;
  --green: #159a76;
  --text: #243b53;
  --muted: #6b7c93;
  --border: #d9e2ec;
  --surface: #ffffff;
  --background: #f2f6fa;
  --danger: #c53b3b;
  --success-bg: #e7f7f1;
  --shadow: 0 24px 70px rgba(16, 42, 67, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 8%, rgba(36, 182, 201, 0.12), transparent 24rem),
    var(--background);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 72%) minmax(0, 28%);
  min-height: 100vh;
  background: #fff;
}

.brand-panel {
  position: relative;
  order: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 24px;
  overflow: hidden;
  padding: clamp(34px, 3vw, 52px);
  color: #fff;
  background:
    repeating-linear-gradient(135deg, transparent 0 20px, rgba(255,255,255,.1) 21px 23px, transparent 24px 42px),
    linear-gradient(155deg, #0fcbd2 0%, #0b9bea 38%, #3154ef 70%, #2424d9 100%);
}

.brand-panel::before,
.brand-panel::after {
  position: absolute;
  content: "";
  border: 0;
  filter: saturate(115%);
}
.brand-panel::before {
  width: 135%;
  height: 48%;
  right: -28%;
  top: 11%;
  border-radius: 46% 0 0 52% / 62% 0 0 44%;
  background: linear-gradient(135deg, #08edca 0%, #14d6d0 42%, #4f43ff 43%, #3f45f4 100%);
  box-shadow: 0 90px 0 -20px rgba(36, 26, 235, .88);
  transform: rotate(7deg);
}
.brand-panel::after {
  width: 110%;
  height: 58%;
  right: -23%;
  bottom: -24%;
  border-radius: 52% 48% 0 0 / 65% 64% 0 0;
  background: linear-gradient(135deg, #0b84e8, #185fcf 42%, #7265ff 43%, #4c4ef3 75%);
  transform: rotate(-8deg);
}

.brand-mark {
  position: relative;
  z-index: 2;
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 22px;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 1px rgba(255,255,255,.15);
}
.brand-mark svg { width: 50px; fill: var(--cyan); }
.brand-mark .brand-mark-detail { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.brand-panel h1 { margin: 0; font-size: clamp(2.3rem, 5vw, 4.7rem); line-height: 1; letter-spacing: -.04em; }
.brand-panel > div:not(.brand-mark), .benefits { position: relative; z-index: 2; }
.brand-panel h1 { max-width: 520px; font-size: clamp(2.3rem, 4vw, 4rem); text-shadow: 0 3px 22px rgba(14, 40, 98, .2); }
.brand-description { max-width: 480px; margin: 18px 0 0; color: rgba(255,255,255,.88); font-size: 1.05rem; line-height: 1.65; }

.benefits { display: none; gap: 15px; margin: 0; padding: 0; list-style: none; color: #dce8f2; }
.benefits li { display: flex; align-items: center; gap: 12px; }
.benefits span { display: inline-grid; width: 25px; height: 25px; place-items: center; color: #fff; border-radius: 50%; background: rgba(36,182,201,.25); }

.content-panel {
  order: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 42px clamp(48px, 8vw, 150px);
  background: #fff;
}
.auth-card { width: min(100%, 670px); padding: 0; border: 0; border-radius: 0; background: #fff; box-shadow: none; }
.mobile-brand { display: flex; align-items: center; margin-bottom: 32px; color: var(--navy); }
.company-logo { display: block; width: 100%; height: auto; }
.login-logo { width: min(100%, 455px); filter: saturate(1.18) contrast(1.05); }

.tabs { display: flex; gap: 24px; margin-bottom: 42px; padding: 0; border-bottom: 1px solid #e6edf3; background: transparent; }
.tab { position: relative; padding: 11px 0 14px; color: var(--muted); border: 0; border-radius: 0; background: transparent; font-weight: 700; }
.tab.active { color: #078fd4; background: transparent; box-shadow: none; }
.tab.active::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 3px; content: ""; border-radius: 3px 3px 0 0; background: #0aa9df; }

.form-header { margin-bottom: 28px; }
.form-header h2, dialog h2, .dashboard-card h2 { margin: 0 0 9px; color: var(--navy); font-size: clamp(1.65rem, 4vw, 2.1rem); letter-spacing: -.025em; }
.form-header > p:last-child, dialog > form > p { margin: 0; color: var(--muted); line-height: 1.55; }

form { display: grid; gap: 18px; }
.field-grid { display: grid; grid-template-columns: 1.3fr .9fr; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--text); font-size: .9rem; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 56px;
  padding: 0 17px;
  color: var(--text);
  border: 1px solid #c9d7df;
  border-radius: 8px;
  outline: none;
  background: #f4f7f8;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field textarea { min-height: 90px; padding-top: 14px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px rgba(22,119,255,.11); }
.field select { appearance: none; padding-right: 42px; background-image: linear-gradient(45deg, transparent 50%, #60798b 50%), linear-gradient(135deg, #60798b 50%, transparent 50%); background-position: calc(100% - 20px) 24px, calc(100% - 14px) 24px; background-size: 6px 6px; background-repeat: no-repeat; }
.field input[readonly] { color: #536779; background: #eaf0f4; }
.field input[type="file"] { min-height: auto; padding: 10px; background: #fff; }
.field input[type="file"]::file-selector-button { margin-right: 12px; padding: 9px 13px; color: var(--blue-dark); border: 1px solid #bfd2e0; border-radius: 8px; background: #edf6ff; font-weight: 700; cursor: pointer; }
.field small { color: var(--muted); line-height: 1.4; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-label-row .text-button { font-size: .78rem; }
.catalog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.danger-text { color: var(--danger); }
.text-button:disabled { cursor: not-allowed; opacity: .45; }
.password-field { position: relative; }
.password-field input { padding-right: 78px; }
.toggle-password { position: absolute; top: 50%; right: 11px; padding: 5px; color: var(--blue-dark); border: 0; background: transparent; font-size: .8rem; font-weight: 700; transform: translateY(-50%); }

.form-options { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: .88rem; }
.checkbox-label { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.checkbox-label input { width: 17px; height: 17px; accent-color: var(--blue); }
.text-button, .back-button { padding: 0; color: var(--blue-dark); border: 0; background: transparent; font-weight: 700; }
.back-button { margin-bottom: 28px; }

.primary-button, .secondary-button {
  width: 100%;
  min-height: 50px;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 800;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.primary-button { color: #fff; border: 0; background: linear-gradient(135deg, #0db6d1, #087dde); box-shadow: 0 9px 20px rgba(8,125,222,.2); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(22,119,255,.27); }
.primary-button:disabled { cursor: wait; opacity: .7; transform: none; }
.secondary-button { margin-top: 24px; color: var(--navy); border: 1px solid var(--border); background: #fff; }

.message { display: none; padding: 11px 13px; border-radius: 9px; font-size: .88rem; line-height: 1.45; }
.message.visible { display: block; }
.message.error { color: #9f2727; border: 1px solid #f2caca; background: #fff1f1; }
.message.success { color: #08745a; border: 1px solid #bde8da; background: var(--success-bg); }
.message.info { color: #275f98; border: 1px solid #c8dff5; background: #edf6ff; }

.dashboard-card { text-align: center; }
.success-icon { display: grid; width: 72px; height: 72px; margin: 0 auto 25px; place-items: center; color: #fff; border-radius: 50%; background: var(--green); font-size: 2rem; box-shadow: 0 10px 25px rgba(21,154,118,.25); }
.session-badge { display: inline-flex; align-items: center; gap: 8px; margin-top: 15px; padding: 8px 12px; color: #08745a; border-radius: 999px; background: var(--success-bg); font-size: .85rem; font-weight: 700; }
.role-badge { padding: 8px 12px; color: #165c96; border-radius: 999px; background: #e8f3ff; font-size: .82rem; font-weight: 800; }
.session-badge span { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(21,154,118,.12); }

.system-card { width: min(100%, 980px); }
.system-header, .system-user, .section-heading, .receipt-actions { display: flex; align-items: center; }
.system-header { justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.system-heading { display: flex; align-items: flex-start; flex-direction: column; gap: 14px; min-width: 0; }
.delivery-logo { flex: 0 0 auto; width: 370px; max-width: 100%; filter: saturate(1.2) contrast(1.06); }
.system-heading > div { padding-left: 6px; }
.system-header h2 { margin: 0 0 5px; color: var(--navy); font-size: 1.8rem; }
.system-header p:last-child { margin: 0; color: var(--muted); }
.system-header .login-identity { color: var(--navy); font-weight: 700; }
.system-user { gap: 16px; }
.system-user .session-badge { margin: 0; white-space: nowrap; }
.module-tabs { display: flex; gap: 26px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.module-tab { padding: 12px 2px; color: var(--muted); border: 0; border-bottom: 3px solid transparent; background: transparent; font-weight: 800; }
.module-tab.active { color: var(--blue-dark); border-bottom-color: var(--cyan); }
.receipt-form { padding: 24px; border: 1px solid #e0e8ef; border-radius: 16px; background: #fbfdff; }
.document-identification { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 16px; color: var(--navy); border-bottom: 1px solid #e0e8ef; font-size: .85rem; }
.document-identification span { color: var(--muted); font-weight: 800; text-transform: uppercase; }
.form-section-title { margin: 8px 0 -4px; color: var(--navy); font-size: 1rem; }
.three-columns { grid-template-columns: minmax(360px, 1fr) 145px 100px; align-items: end; }
.receipt-actions { gap: 12px; }
.receipt-actions .primary-button { width: auto; min-width: 210px; }
.receipt-actions .secondary-button { width: auto; min-width: 110px; margin: 0; }
.recent-receipts { margin-top: 30px; }
.return-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.return-header h3 { margin: 0 0 6px; color: var(--navy); font-size: 1.35rem; }
.return-header p:last-child { margin: 0; color: var(--muted); }
.return-search { max-width: 560px; margin-bottom: 18px; }
.status-pending { color: #9b6b00; font-weight: 800; }
.status-returned { color: #08745a; font-weight: 800; }
.status-active { display: inline-flex; padding: 5px 9px; color: #08745a; border-radius: 999px; background: #e2f6ef; font-size: .78rem; font-weight: 800; }
.status-inactive { display: inline-flex; padding: 5px 9px; color: #9f2727; border-radius: 999px; background: #fff0f0; font-size: .78rem; font-weight: 800; }
.user-form { display: grid; gap: 14px; }
.user-form .field-grid { align-items: start; }
.user-form .field { align-content: start; }
.user-form .user-submit { width: auto; min-width: 220px; justify-self: start; }
.users-list { margin-top: 24px; }
.section-heading { justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.section-heading h3 { margin: 0; color: var(--navy); font-size: 1.15rem; }
.table-wrapper { overflow-x: auto; border: 1px solid #e0e8ef; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .88rem; }
th, td { padding: 13px 14px; border-bottom: 1px solid #edf1f5; white-space: nowrap; }
th { color: #536779; background: #f4f7fa; font-size: .76rem; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.empty-row { color: var(--muted); text-align: center; }
.table-action { padding: 5px 9px; color: var(--blue-dark); border: 1px solid #c7dbea; border-radius: 7px; background: #f3f9ff; font-size: .78rem; font-weight: 700; }
.ca-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.ca-search-row .secondary-button { width: auto; min-width: 160px; margin: 0; border-radius: 8px; }
.ca-exempt-label { margin-top: 5px; color: var(--navy); font-weight: 700; }
.ca-result { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 15px; border: 1px solid #c9dfeb; border-radius: 10px; background: #f3faff; }
.ca-result div { display: grid; gap: 3px; }
.ca-result span { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.ca-result strong { color: var(--navy); font-size: .88rem; }
.ca-result small { grid-column: 1 / -1; color: var(--muted); }
.ca-alerts { margin-bottom: 18px; padding: 14px 16px; color: #775500; border: 1px solid #efd178; border-radius: 10px; background: #fff8dc; font-size: .88rem; line-height: 1.5; }
.ca-alerts.danger { color: #942d2d; border-color: #edbcbc; background: #fff0f0; }
.add-item-button { width: auto; margin: 0; border-radius: 9px; }
.pending-items { display: grid; gap: 10px; padding: 15px; border: 1px solid #dce6ed; border-radius: 12px; background: #fff; }
.pending-items-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--navy); font-size: .86rem; }
.pending-items-heading span { color: var(--muted); font-size: .78rem; }
.validity-ok { color: #08745a; font-weight: 700; }
.validity-warning { color: #9b6b00; font-weight: 800; }
.validity-expired { color: #b52f2f; font-weight: 800; }
.remove-item { color: #a32f2f; border-color: #edc5c5; background: #fff4f4; }
.commitment-term { max-height: 330px; overflow-y: auto; padding: 20px; color: #40566a; border: 1px solid #d6e2ea; border-radius: 12px; background: #fff; font-size: .86rem; line-height: 1.55; }
.commitment-term h3 { margin: 0 0 12px; color: var(--navy); text-align: center; text-transform: uppercase; }
.commitment-term p { margin: 0 0 12px; }
.commitment-term ul { display: grid; gap: 9px; margin: 0; padding-left: 20px; }
.commitment-term .term-note { margin: 16px 0 0; color: var(--navy); }
.term-acceptance { display: flex; align-items: flex-start; gap: 11px; padding: 14px; color: var(--navy); border-radius: 10px; background: #edf7fa; font-size: .9rem; font-weight: 700; line-height: 1.45; }
.term-acceptance input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; accent-color: var(--blue); }
.signature-grid { display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 14px; }
.signature-grid > .field:last-child { width: min(100%, 260px); }
.signature-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.signature-heading label { color: var(--text); font-size: .9rem; font-weight: 700; }
#signatureCanvas { display: block; width: 100%; height: 250px; border: 1px solid #b9cbd6; border-radius: 10px; background: #fff; box-shadow: inset 0 1px 3px rgba(16,42,67,.06); cursor: crosshair; touch-action: none; }

footer { width: min(100%, 670px); color: #8795a8; font-size: .78rem; }
.hidden { display: none !important; }

dialog { width: min(calc(100% - 30px), 470px); padding: 0; border: 0; border-radius: 20px; color: var(--text); box-shadow: 0 25px 90px rgba(5,24,40,.3); }
dialog::backdrop { background: rgba(7,29,48,.66); backdrop-filter: blur(3px); }
dialog form { position: relative; padding: 38px; }
.dialog-close { position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; color: var(--muted); border: 0; border-radius: 50%; background: #edf2f7; font-size: 1.3rem; line-height: 1; }

@media (max-width: 900px) {
  .page-shell { grid-template-columns: 1fr; }
  .brand-panel { display: none; }
  .content-panel { min-height: 100vh; }
  .three-columns { grid-template-columns: minmax(0, 1fr) 130px 90px; }
  .delivery-logo { width: 330px; }
}

@media (max-width: 560px) {
  .content-panel { justify-content: flex-start; padding: 18px 12px; }
  .auth-card { padding: 25px 20px; border-radius: 18px; }
  .field-grid { grid-template-columns: 1fr; }
  .three-columns { grid-template-columns: 1fr; }
  .signature-grid { grid-template-columns: 1fr; }
  #signatureCanvas { height: 220px; }
  .ca-search-row { grid-template-columns: 1fr; }
  .ca-search-row .secondary-button { width: 100%; }
  .system-header, .system-user, .receipt-actions { align-items: stretch; flex-direction: column; }
  .return-header { align-items: flex-start; flex-direction: column; }
  .system-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .delivery-logo { width: min(100%, 280px); }
  .system-user { gap: 10px; }
  .receipt-actions .primary-button, .receipt-actions .secondary-button { width: 100%; }
  .form-options { align-items: flex-start; flex-direction: column; }
  dialog form { padding: 32px 22px 24px; }
}
