:root {
  --brand-navy: #102850;
  --brand-teal: #0898a0;
  --brand-teal-dark: #067b82;
  --brand-amber: #e8a018;
  --body-bg: #f3f8f9;
  --body-fg: #111827;
  --muted-fg: #637481;
  --card-border: #d8e5e8;
}

* {
  box-sizing: border-box;
}

body.portal {
  background: var(--body-bg);
  color: var(--body-fg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

.portal-shell {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  min-height: 100vh;
}

.portal-sidebar {
  background: var(--brand-navy);
  color: #eef6f7;
  padding: 1rem;
}

.portal-brand {
  align-items: center;
  color: #fff;
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  text-decoration: none;
}

.portal-brand img {
  background: #fff;
  border-radius: 0.5rem;
  height: 2.75rem;
  object-fit: contain;
  padding: 0.25rem;
  width: 2.75rem;
}

.portal-brand strong,
.portal-brand span {
  display: block;
}

.portal-brand strong {
  font-size: 1.05rem;
  line-height: 1.1;
}

.portal-brand span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.portal-nav {
  display: grid;
  gap: 0.35rem;
}

.portal-nav a,
.portal-logout button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0.5rem;
  color: #e8f5f6;
  display: flex;
  font: inherit;
  gap: 0.65rem;
  min-height: 2.6rem;
  padding: 0.65rem 0.75rem;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.portal-nav a:hover,
.portal-logout button:hover,
.portal-nav a.active {
  background: var(--brand-teal);
  color: #fff;
}

.portal-logout {
  margin: 1.5rem 0 0;
}

.portal-main {
  min-width: 0;
}

.portal-topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  min-height: 4rem;
  padding: 0.8rem 1.5rem;
}

.portal-user {
  color: var(--muted-fg);
  font-size: 0.9rem;
}

.portal-operator-stop {
  display: inline-flex;
  margin: 0;
}

.portal-operator-stop button {
  background: transparent;
  border: 0;
  color: var(--brand-teal);
  font: inherit;
  font-weight: 700;
  padding: 0;
}

.portal-operator-stop button:hover {
  color: var(--brand-teal-dark);
}

.portal-content {
  padding: 1.5rem;
}

.portal-title {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.portal-title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  color: var(--brand-navy);
  font-size: 1.65rem;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

h2 {
  color: var(--brand-navy);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.muted {
  color: var(--muted-fg);
}

.grid {
  display: grid;
  gap: 1rem;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-col {
  grid-template-columns: minmax(0, 1.4fr) minmax(18rem, 0.8fr);
}

.card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  box-shadow: 0 0.125rem 0.5rem rgba(16, 40, 80, 0.06);
  padding: 1rem;
}

.stat-card {
  min-height: 7rem;
}

.stat-label {
  color: var(--muted-fg);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.stat-value {
  color: var(--brand-navy);
  font-size: 1.35rem;
  font-weight: 700;
}

.positive {
  color: var(--brand-teal-dark);
  font-weight: 700;
}

.negative {
  color: #c0392b;
  font-weight: 700;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
}

.badge.active,
.badge.verified {
  background: rgba(8, 152, 160, 0.14);
  color: var(--brand-teal-dark);
}

.badge.expired,
.badge.cancelled,
.badge.unverified {
  background: rgba(232, 160, 24, 0.18);
  color: #7c4d00;
}

.button {
  align-items: center;
  background: var(--brand-teal);
  border: 1px solid var(--brand-teal);
  border-radius: 0.375rem;
  color: #fff;
  display: inline-flex;
  font-weight: 700;
  min-height: 2.4rem;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}

.button:hover {
  background: var(--brand-teal-dark);
  border-color: var(--brand-teal-dark);
  color: #fff;
}

.button.secondary {
  background: #fff;
  color: var(--brand-navy);
}

.button.danger {
  background: #fff;
  border-color: #dc3545;
  color: #b42318;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--card-border);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--brand-navy);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.customers-toolbar {
  margin-bottom: 1rem;
}

.customers-search {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.customers-search input {
  flex: 1 1 18rem;
  min-width: 0;
}

.customers-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.6fr) minmax(20rem, 0.9fr);
}

.customers-list-card,
.customers-form-card {
  display: grid;
  gap: 1rem;
}

.customers-card-header {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.customers-card-header h2 {
  margin-bottom: 0.25rem;
}

.customers-table {
  min-width: 100%;
}

.customers-table td {
  vertical-align: top;
}

.customers-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.customer-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.customer-actions form {
  margin: 0;
}

.customer-form {
  display: grid;
  gap: 0.85rem;
}

.customer-form label {
  gap: 0.3rem;
}

.customer-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.customers-popup-shell {
  align-items: center;
  display: none;
  inset: 0;
  justify-content: center;
  padding: 1.25rem;
  position: fixed;
  z-index: 50;
}

.customers-popup-shell.open {
  display: flex;
}

.customers-popup-backdrop {
  background: rgba(16, 24, 40, 0.62);
  inset: 0;
  position: absolute;
}

.customers-popup-card {
  max-height: calc(100vh - 2.5rem);
  max-width: 42rem;
  overflow: auto;
  position: relative;
  width: min(42rem, 100%);
  z-index: 1;
}

.customers-popup-header {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.customers-popup-meta {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

.customers-popup-title {
  color: var(--brand-navy);
  font-size: 1.2rem;
  line-height: 1.2;
}

.customers-popup-lede {
  color: var(--muted-fg);
  font-size: 0.92rem;
}

.customers-popup-chip {
  align-items: center;
  background: rgba(8, 152, 160, 0.12);
  border-radius: 999px;
  color: var(--brand-teal-dark);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  min-height: 1.8rem;
  padding: 0.2rem 0.65rem;
}

.customers-popup-body {
  display: grid;
  gap: 0.85rem;
}

.customers-popup-footer {
  display: flex;
  gap: 0.65rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.customers-popup-close {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted-fg);
  cursor: pointer;
  display: inline-flex;
  font-size: 2rem;
  line-height: 1;
  padding: 0;
}

.customers-popup-close:hover {
  color: var(--brand-navy);
}

@media (max-width: 560px) {
  .customers-popup-header {
    display: block;
  }

  .customers-popup-footer,
  .portal-title-actions,
  .customer-actions {
    justify-content: stretch;
  }

  .customers-popup-footer .button,
  .portal-title-actions .button,
  .customer-actions .button {
    width: 100%;
    justify-content: center;
  }
}

.details {
  display: grid;
  gap: 0.65rem;
}

.detail-row {
  display: grid;
  gap: 0.25rem;
}

.detail-row span {
  color: var(--muted-fg);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.code {
  background: #f3f8f9;
  border: 1px solid var(--card-border);
  border-radius: 0.375rem;
  color: var(--brand-navy);
  display: block;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-x: auto;
  padding: 0.75rem;
  white-space: pre-wrap;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
  max-width: 34rem;
}

label {
  color: var(--brand-navy);
  display: grid;
  font-weight: 700;
  gap: 0.35rem;
}

input {
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  color: var(--body-fg);
  font: inherit;
  min-height: 2.45rem;
  padding: 0.5rem 0.65rem;
}

input:focus {
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 0.22rem rgba(8, 152, 160, 0.18);
  outline: 0;
}

.messages {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.message {
  background: rgba(8, 152, 160, 0.12);
  border: 1px solid rgba(8, 152, 160, 0.24);
  border-radius: 0.5rem;
  color: var(--brand-navy);
  padding: 0.75rem 1rem;
}

.auth-page {
  align-items: center;
  background: var(--body-bg);
  display: grid;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  margin: 0 auto;
  max-width: 28rem;
  overflow: hidden;
  width: 100%;
}

.auth-brand-bar {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(169, 173, 183, 0.88) 0%, rgba(93, 103, 122, 0.88) 52%, rgba(31, 49, 85, 0.94) 100%);
  display: flex;
  justify-content: center;
  padding: 1.25rem 1rem 1rem;
}

.auth-logo {
  display: block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.16));
  margin: 0 auto;
  max-width: 16rem;
  width: 80%;
}

.auth-card > :not(.auth-brand-bar) {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.auth-card > :not(.auth-brand-bar):last-child {
  padding-bottom: 1.5rem;
}

.auth-card .messages {
  margin-top: 1rem;
}

.portal-login .auth-page {
  align-items: center;
  background: linear-gradient(180deg, #f6fbfc 0%, #edf4f5 100%);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 1.75rem 1.25rem;
}

.portal-login .login-shell {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(16, 40, 80, 0.08);
  border-radius: 1.2rem;
  box-shadow: 0 1.75rem 4rem rgba(16, 40, 80, 0.14);
  overflow: hidden;
  width: min(100%, 28rem);
}

.portal-login .login-brand-bar {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(169, 173, 183, 0.92) 0%, rgba(93, 103, 122, 0.92) 52%, rgba(31, 49, 85, 0.96) 100%);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 14rem;
  padding: 1.4rem 1.35rem 1.2rem;
  text-align: center;
}

.portal-login .login-brand {
  flex: 0 0 auto;
}

.portal-login .login-brand img {
  display: block;
  height: auto;
  max-width: 11.5rem;
  margin: 0 auto;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
  width: min(100%, 11.5rem);
}

.portal-login .login-brand-copy h1 {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.2rem;
}

.portal-login .login-brand-copy p {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.88rem;
  line-height: 1.4;
  margin: 0;
  max-width: 22rem;
}

.portal-login .login-card-body {
  background: #fff;
  padding: 1.45rem 1.5rem 1.55rem;
}

.portal-login .login-box-msg {
  color: var(--brand-navy);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.95rem;
  text-align: left;
}

.portal-login .alert {
  border-radius: 0.5rem;
  margin-bottom: 0.9rem;
  padding: 0.7rem 0.95rem;
}

.portal-login .alert-danger {
  background: rgba(180, 35, 24, 0.08);
  border: 1px solid rgba(180, 35, 24, 0.2);
  color: #b42318;
}

.portal-login .alert-warning {
  background: rgba(232, 160, 24, 0.14);
  border: 1px solid rgba(232, 160, 24, 0.28);
  color: #7c4d00;
}

.portal-login .login-field {
  position: relative;
}

.portal-login .login-field input {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  color: var(--body-fg);
  min-height: 3rem;
  padding: 0.68rem 0.9rem 0.68rem 2.7rem;
  width: 100%;
}

.portal-login .login-field input:focus {
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 0.22rem rgba(8, 152, 160, 0.14);
  outline: 0;
}

.portal-login .login-field-icon {
  align-items: center;
  color: var(--brand-teal);
  display: flex;
  height: 100%;
  left: 0.85rem;
  pointer-events: none;
  position: absolute;
  top: 0;
}

.portal-login .login-actions {
  align-items: center;
  display: flex;
  justify-content: flex-end;
  margin-top: 0.2rem;
}

.portal-login .login-actions .btn {
  align-items: center;
  background: var(--brand-teal);
  border: 1px solid var(--brand-teal);
  border-radius: 0.375rem;
  color: #fff;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 2.75rem;
  min-width: 8rem;
  padding: 0.52rem 0.8rem;
  text-decoration: none;
}

.portal-login .login-actions .btn:hover {
  background: var(--brand-teal-dark);
  border-color: var(--brand-teal-dark);
  color: #fff;
}

.portal-login .login-actions .btn.btn-primary {
  box-shadow: none;
}

.portal-login .login-card-body .errorlist {
  color: #dc3545;
  font-size: 0.875rem;
  list-style: none;
  margin: -0.45rem 0 0.65rem;
  padding-left: 0;
}

.form-errors {
  color: #b42318;
  font-size: 0.9rem;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-label {
  align-items: center;
  display: flex;
  gap: 0.65rem;
}

.workspace-modal {
  align-items: center;
  display: none;
  inset: 0;
  justify-content: center;
  padding: 1.25rem;
  position: fixed;
  z-index: 50;
}

.workspace-modal-toggle:checked ~ .workspace-modal {
  display: flex;
}

.workspace-modal:target {
  display: flex;
}

.workspace-modal-backdrop {
  background: rgba(16, 24, 40, 0.62);
  inset: 0;
  position: absolute;
  z-index: 0;
}

.workspace-modal-card {
  max-height: calc(100vh - 2.5rem);
  max-width: 42rem;
  overflow: auto;
  position: relative;
  z-index: 1;
  width: min(42rem, 100%);
}

.workspace-modal-header {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.workspace-modal-close {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted-fg);
  cursor: pointer;
  display: inline-flex;
  font-size: 2rem;
  line-height: 1;
  padding: 0;
}

.workspace-modal-close:hover {
  color: var(--brand-navy);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

.pos-workspace {
  display: grid;
  gap: 1rem;
}

.workspace-hero {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(8, 152, 160, 0.12), rgba(16, 40, 80, 0.06)),
    #fff;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.workspace-kicker {
  color: var(--brand-teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.workspace-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.workspace-actions .button {
  cursor: pointer;
}

.workspace-metrics {
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.workspace-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 0.9fr);
}

.workspace-main,
.workspace-side {
  display: grid;
  gap: 1rem;
}

.workspace-panel {
  display: grid;
  gap: 0.9rem;
}

.panel-header {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.panel-header h2 {
  margin-bottom: 0;
}

.workspace-table {
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
}

.doc-chip,
.stock-badge {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  min-height: 1.7rem;
  padding: 0.2rem 0.6rem;
}

.doc-chip.transaction {
  background: rgba(8, 152, 160, 0.14);
  color: var(--brand-teal-dark);
}

.doc-chip.stock {
  background: rgba(16, 40, 80, 0.1);
  color: var(--brand-navy);
}

.workspace-subtitle {
  color: var(--brand-navy);
  font-weight: 700;
}

.workspace-note {
  color: var(--muted-fg);
  font-size: 0.82rem;
  margin-top: 0.12rem;
}

.workspace-value {
  color: var(--brand-navy);
  font-weight: 700;
}

.stock-badge {
  background: rgba(8, 152, 160, 0.12);
  color: var(--brand-teal-dark);
}

.stock-badge.low {
  background: rgba(232, 160, 24, 0.18);
  color: #7c4d00;
}

.stack-list {
  display: grid;
  gap: 0.65rem;
}

.stack-row {
  align-items: center;
  background: #f9fbfc;
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0.85rem;
}

@media (max-width: 980px) {
  .portal-shell {
    grid-template-columns: 1fr;
  }

  .portal-sidebar {
    position: static;
  }

  .portal-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-logout {
    margin-top: 0.5rem;
  }

  .stats,
  .two-col,
  .customers-layout,
  .workspace-metrics,
  .workspace-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .portal-content,
  .portal-topbar {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .portal-nav {
    grid-template-columns: 1fr;
  }

  .portal-title {
    display: block;
  }
}
