:root {
  --brand-navy: #102850;
  --brand-teal: #c2410c;
  --brand-teal-dark: #9a3412;
  --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 {
  background: #fff;
  border-radius: 0.5rem;
  display: block;
  margin-bottom: 1.5rem;
  padding: 0.75rem;
}

.portal-brand img {
  display: block;
  height: auto;
  width: 100%;
}

.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-nav-group {
  display: grid;
  gap: 0.35rem;
}

.portal-nav-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0.5rem;
  color: #e8f5f6;
  cursor: pointer;
  display: flex;
  font: inherit;
  justify-content: space-between;
  min-height: 2.6rem;
  padding: 0.65rem 0.75rem;
  text-align: left;
  width: 100%;
}

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

.portal-nav-chevron {
  font-style: normal;
  transition: transform 0.15s ease;
}

.portal-nav-toggle[aria-expanded="true"] .portal-nav-chevron {
  transform: rotate(180deg);
}

.portal-submenu {
  display: grid;
  gap: 0.25rem;
  padding-left: 0.75rem;
}

.portal-submenu a {
  align-items: center;
  border-radius: 0.5rem;
  color: #cfe6e8;
  display: flex;
  font-size: 0.9rem;
  min-height: 2.2rem;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
}

.portal-submenu a:hover,
.portal-submenu 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,
.badge.late {
  background: rgba(232, 160, 24, 0.18);
  color: #7c4d00;
}

.badge.absent {
  background: rgba(192, 57, 43, 0.14);
  color: #c0392b;
}

.badge.off {
  background: rgba(99, 116, 129, 0.14);
  color: var(--muted-fg);
}

.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;
  }
}

.plans-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.plan-card {
  --plan-color: var(--brand-teal);
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 0.6rem;
  box-shadow: 0 0.125rem 0.5rem rgba(16, 40, 80, 0.06);
  flex: 0 1 14rem;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.plan-card:hover {
  box-shadow: 0 0.75rem 1.5rem rgba(16, 40, 80, 0.12);
  transform: translateY(-2px);
}

.plan-card-current {
  border: 2px solid var(--plan-color);
  box-shadow: 0 0.5rem 1.5rem rgba(16, 40, 80, 0.16);
}

.plan-card-banner {
  align-items: center;
  background: var(--plan-color);
  color: #fff;
  display: flex;
  font-size: 0.82rem;
  font-weight: 800;
  gap: 0.5rem;
  justify-content: center;
  letter-spacing: 0.04em;
  padding: 0.7rem 0.75rem;
  text-align: center;
  text-transform: uppercase;
}

.plan-card-banner-tag {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  font-size: 0.66rem;
  padding: 0.1rem 0.5rem;
}

.plan-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.5rem 1.25rem 1.25rem;
  text-align: center;
}

.plan-price {
  color: var(--plan-color);
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.1rem;
}

.plan-interval {
  color: var(--muted-fg);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.plan-description {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.plan-best-for {
  background: color-mix(in srgb, var(--plan-color) 14%, white);
  border-radius: 0.4rem;
  color: var(--body-fg);
  font-size: 0.78rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.65rem;
}

.plan-features-label {
  color: var(--muted-fg);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
  text-align: left;
  text-transform: uppercase;
}

.plan-features {
  display: grid;
  gap: 0.55rem;
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  text-align: left;
}

.plan-features li {
  color: var(--body-fg);
  font-size: 0.86rem;
  padding-left: 1.6rem;
  position: relative;
}

.plan-features li::before {
  align-items: center;
  background: var(--plan-color);
  border-radius: 999px;
  color: #fff;
  content: "✓";
  display: inline-flex;
  font-size: 0.65rem;
  font-weight: 800;
  height: 1.1rem;
  justify-content: center;
  left: 0;
  position: absolute;
  top: 0.05rem;
  width: 1.1rem;
}

.plan-cta {
  justify-content: center;
  margin: 0 auto;
  min-height: 2.1rem;
  padding: 0.45rem 1.5rem;
  width: auto;
}

.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;
}

.form-grid--full {
  max-width: none;
}

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;
}

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

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

.form-row-2 {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.avatar-field {
  align-items: center;
  display: flex;
  gap: 1rem;
}

.avatar-preview {
  background: var(--body-bg);
  border: 1px solid var(--card-border);
  border-radius: 50%;
  height: 84px;
  object-fit: cover;
  width: 84px;
}

.avatar-crop-panel {
  margin-top: 0.75rem;
}

.avatar-crop-viewport {
  background: var(--body-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  cursor: grab;
  display: inline-block;
  overflow: hidden;
  touch-action: none;
}

.avatar-crop-viewport canvas {
  display: block;
}

.avatar-crop-viewport:active {
  cursor: grabbing;
}

.avatar-crop-zoom {
  display: block;
  margin: 0.75rem 0;
  width: 260px;
}

.avatar-crop-actions {
  display: flex;
  gap: 0.5rem;
}

.field-label {
  color: var(--brand-navy);
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.field-readonly {
  background: var(--body-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.375rem;
  color: var(--muted-fg);
  min-height: 2.45rem;
  padding: 0.5rem 0.65rem;
}

.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, #fdf5ee 0%, #fbe7d8 100%);
  border-bottom: 1px solid rgba(194, 65, 12, 0.14);
  display: flex;
  justify-content: center;
  padding: 1.25rem 1rem 1rem;
}

.auth-logo {
  display: block;
  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, #fdf5ee 0%, #fbe7d8 100%);
  box-shadow: inset 0 -1px 0 rgba(194, 65, 12, 0.14);
  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;
  width: min(100%, 11.5rem);
}

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

.portal-login .login-brand-copy p {
  color: var(--muted-fg);
  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;
  }
}

/* Content loader: overlays just the content area (sidebar/topbar on the
   dashboard, the card chrome on auth pages stay usable right away) while
   assets are still loading, so visitors never see unstyled/half-rendered
   content. Removed by the inline script in base.html/auth_base.html on
   window "load" (with a timeout fallback in case a slow third-party
   resource never fires it). */
.portal-content,
.auth-card {
  position: relative;
}

.page-loader {
  position: absolute;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--body-bg) 85%, transparent);
  opacity: 1;
  transition: opacity 0.25s ease;
}

.page-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.page-loader__spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid var(--card-border);
  border-top-color: var(--brand-teal);
  animation: page-loader-spin 0.8s linear infinite;
}

@keyframes page-loader-spin {
  to {
    transform: rotate(360deg);
  }
}

.mini-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--card-border);
  border-top-color: var(--brand-teal);
  animation: page-loader-spin 0.8s linear infinite;
}

.dialog-busy-overlay {
  align-items: center;
  background: #fff;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  justify-content: center;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 5;
}

#wmComposeDialog {
  position: relative;
}

/* Webmail - modeled on AdminLTE 4's mailbox demo (inbox/read/compose),
   rebuilt as scoped `.wm-*` classes instead of loading Bootstrap 5 itself -
   Bootstrap's global reset/utility classes would otherwise cascade onto the
   whole portal shell (sidebar, topbar, every other page), not just this
   section, since nothing here is scoped to a body class the way AdminLTE
   itself is. Bootstrap Icons is just an icon font/class set with no reset,
   so that alone is loaded directly (see inbox.html/compose.html). */
.wm-layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.wm-compose-btn {
  align-items: center;
  background: var(--brand-teal);
  border: 1px solid var(--brand-teal);
  border-radius: 0.375rem;
  color: #fff;
  display: flex;
  font-weight: 700;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.65rem 1rem;
  text-decoration: none;
  width: 100%;
}

.wm-compose-btn:hover {
  background: var(--brand-teal-dark);
  border-color: var(--brand-teal-dark);
}

.wm-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.wm-card + .wm-card {
  margin-top: 1rem;
}

.wm-card-header {
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.75rem 1rem;
}

.wm-card-title {
  color: var(--brand-navy);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}

.wm-card-body {
  padding: 1rem;
}

.wm-card-body.p-0 {
  padding: 0;
}

.wm-card-footer {
  border-top: 1px solid var(--card-border);
  display: flex;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
}

.wm-folders {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

.wm-folder-link {
  align-items: center;
  color: var(--body-fg);
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  text-decoration: none;
}

.wm-folder-link:hover {
  background: var(--body-bg);
}

.wm-folder-link.active {
  background: var(--brand-teal);
  color: #fff;
}

.wm-folder-badge {
  background: var(--card-border);
  border-radius: 999px;
  color: var(--body-fg);
  flex: 0 0 auto;
  font-size: 0.72rem;
  padding: 0.05rem 0.5rem;
}

.wm-folder-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wm-folder-link.active .wm-folder-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.wm-toolbar {
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
}

.wm-toolbar .wm-btn-group {
  display: flex;
  gap: 0.35rem;
}

.wm-icon-btn {
  align-items: center;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 0.375rem;
  color: var(--body-fg);
  cursor: pointer;
  display: inline-flex;
  height: 2rem;
  justify-content: center;
  width: 2rem;
}

.wm-icon-btn:hover {
  background: var(--body-bg);
}

.wm-toolbar-count {
  color: var(--muted-fg);
  font-size: 0.82rem;
  margin-left: auto;
}

.wm-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wm-list-item {
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  cursor: pointer;
  display: flex;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
}

.wm-list-item:last-child {
  border-bottom: 0;
}

.wm-list-item:hover {
  background: var(--body-bg);
}

.wm-list-item.selected {
  background: rgba(194, 65, 12, 0.08);
}

.wm-list-item.unread {
  background: var(--body-bg);
}

.wm-list-item.unread .wm-list-peer,
.wm-list-item.unread .wm-list-subject {
  font-weight: 700;
}

.wm-star-btn {
  background: none;
  border: 0;
  color: var(--card-border);
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.wm-star-btn.starred {
  color: #f0ad4e;
}

.wm-list-link {
  align-items: center;
  color: inherit;
  display: flex;
  flex: 1 1 auto;
  gap: 0.75rem;
  min-width: 0;
  text-decoration: none;
}

.wm-list-peer {
  color: var(--brand-navy);
  flex: 0 0 9rem;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wm-list-subject {
  color: var(--body-fg);
  flex: 1 1 auto;
  font-size: 0.85rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wm-list-subject .muted {
  font-weight: 400;
}

.wm-list-date {
  color: var(--muted-fg);
  flex: 0 0 auto;
  font-size: 0.75rem;
}

.wm-empty {
  color: var(--muted-fg);
  padding: 2rem 1rem;
  text-align: center;
}

/* Reading pane (matches read.html's card) */
.wm-sender {
  align-items: flex-start;
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.wm-avatar {
  align-items: center;
  background: var(--brand-teal);
  border-radius: 50%;
  color: #fff;
  display: flex;
  flex: 0 0 auto;
  font-size: 0.85rem;
  font-weight: 700;
  height: 2.75rem;
  justify-content: center;
  width: 2.75rem;
}

.wm-sender-meta {
  display: flex;
  flex: 1 1 auto;
  justify-content: space-between;
  gap: 0.75rem;
}

.wm-body {
  margin-bottom: 1.25rem;
  min-height: 4rem;
}

.wm-reading-frame {
  border: 0;
  display: block;
  height: 20rem;
  width: 100%;
}

.wm-attachments-title {
  color: var(--body-fg);
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.wm-attachments {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.wm-attachment {
  align-items: center;
  border: 1px solid var(--card-border);
  border-radius: 0.375rem;
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
}

.wm-attachment i {
  font-size: 1.4rem;
}

.wm-attachment-name {
  flex: 1 1 auto;
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.d-none {
  display: none !important;
}

.me-2 {
  margin-right: .5rem;
}

.wm-card-header-wrap {
  flex-wrap: wrap;
  row-gap: 0.6rem;
}

.drive-breadcrumb {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  font-size: 1rem;
  margin: 0;
}

.drive-breadcrumb span {
  color: var(--body-fg);
}

.drive-breadcrumb span a {
  color: var(--muted-fg);
  text-decoration: none;
}

.drive-breadcrumb span a:hover {
  color: var(--brand-teal);
  text-decoration: underline;
}

.drive-breadcrumb span:not(:last-child)::after {
  content: '\203A';
  margin: 0 .5rem;
  color: var(--muted-fg);
}

.drive-toolbar {
  align-items: center;
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-bottom: 1.25rem;
}

.drive-search {
  align-items: center;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  display: flex;
  gap: .5rem;
  padding: .45rem .9rem;
}

.drive-search input {
  background: transparent;
  border: none;
  min-height: auto;
  outline: none;
  width: 200px;
}

.drive-view-toggle {
  display: flex;
  gap: .15rem;
}

.btn-icon {
  align-items: center;
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  color: var(--body-fg);
  display: inline-flex;
  height: 2.35rem;
  justify-content: center;
  width: 2.35rem;
}

.btn-icon:hover {
  background: var(--body-bg);
}

.btn-icon.active {
  background: rgba(194, 65, 12, .12);
  border-color: transparent;
  color: var(--brand-teal);
}

.drive-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.drive-card,
.drive-folder-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: .5rem;
  display: flex;
  flex-direction: column;
  /* align-items:center (the flex default for "match the reference's
     centered text") sizes each child to its own content width instead of
     the card's full width - that let a long filename's text-overflow:
     ellipsis rule never actually trigger, since the name div just grew
     wider than the card instead of clipping, spilling the text into the
     next card. stretch + min-width:0 (below, plus width:100% on the name
     itself) keeps the visual centering via text-align while actually
     constraining the box overflow:hidden needs to work against. */
  align-items: stretch;
  min-width: 0;
  min-height: 11.5rem;
  padding: 1rem .85rem;
  text-align: center;
}

.drive-folder-card {
  color: inherit;
  text-decoration: none;
}

.drive-folder-card:hover {
  border-color: var(--brand-teal);
}

.drive-card .drive-file-icon,
.drive-folder-card .drive-file-icon {
  color: var(--brand-teal);
  font-size: 2.5rem;
}

.drive-folder-icon {
  color: #f0ad4e !important;
}

/* Bootstrap Icons' file-type glyphs (bi-file-earmark-pdf-fill etc.) are
   colored per format via these Bootstrap-style utility classes, matching
   the same semantic colors Office/Adobe use, instead of every file icon
   sharing one flat brand-teal color - !important since a plain single-class
   selector would otherwise lose to .drive-file-icon's color rule above on
   source order alone. */
.text-danger { color: #dc3545 !important; }
.text-success { color: #198754 !important; }
.text-info { color: #0dcaf0 !important; }
.text-primary { color: #0d6efd !important; }
.text-warning { color: #f0ad4e !important; }
.text-secondary { color: #6c757d !important; }

.drive-folder-row td a {
  align-items: center;
  color: inherit;
  display: inline-flex;
  text-decoration: none;
}

.drive-folder-row td a:hover {
  color: var(--brand-teal);
}

.drive-card .drive-file-name,
.drive-folder-card .drive-file-name {
  font-size: .85rem;
  font-weight: 700;
  margin-top: .5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-card .drive-file-meta,
.drive-folder-card .drive-file-meta {
  color: var(--muted-fg);
  font-size: .72rem;
  margin: .15rem 0 .75rem;
}

.drive-card-download {
  display: inline-flex;
  font-size: .78rem;
  margin-top: auto;
  min-height: auto;
  padding: .35rem .9rem;
}

.drive-list-table {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: .5rem;
  border-collapse: collapse;
  width: 100%;
}

.drive-list-table th {
  color: var(--muted-fg);
  font-size: .78rem;
  font-weight: 700;
  padding: .6rem .9rem;
  text-align: left;
  text-transform: uppercase;
}

.drive-list-table td {
  border-top: 1px solid var(--card-border);
  padding: .6rem .9rem;
  vertical-align: middle;
}

.drive-list-table .drive-file-icon {
  color: var(--brand-teal);
  font-size: 1.2rem;
}

.drive-list-name {
  display: inline-block;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.drive-empty {
  padding: 2rem 0;
  text-align: center;
}

.drive-card {
  cursor: pointer;
}

.drive-list-table tbody tr {
  cursor: pointer;
}

/* jquery-ui's own base theme (jquery-ui.min.css) leaves this as an
   unstyled sprite-icon button with no visible background - every portal
   page that opens a jquery-ui .dialog() (documents.html, clients.html)
   gets a proper red square close button instead (same shape as the
   .btn-danger row-delete buttons), matching the same look already used
   on the admin's modal_datatable.css dialogs. */
.ui-dialog .ui-dialog-titlebar-close {
  align-items: center; background: #dc3545; border: none; border-radius: .175rem;
  box-shadow: none; color: #fff; cursor: pointer; display: flex;
  justify-content: center; opacity: 1; padding: 0; margin-right: 10px;
}
.ui-dialog .ui-dialog-titlebar-close:hover { background: #b42318; }
.ui-dialog .ui-dialog-titlebar-close .ui-icon { display: none; }
.ui-dialog .ui-dialog-titlebar-close::before { content: "\00d7"; color: #fff; display: block; font-size: 1rem; line-height: 1; }

.doc-preview-body {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 200px;
}

.doc-preview-image {
  max-height: 70vh;
  max-width: 100%;
}

.doc-preview-frame {
  border: 0;
  height: 70vh;
  width: 100%;
}

.doc-preview-unsupported {
  color: var(--muted-fg);
  padding: 2.5rem 1rem;
  text-align: center;
}

.doc-preview-unsupported i {
  color: var(--brand-teal);
  font-size: 3rem;
}

/* Gallery's "Manage categories" dialog only (see asset_category_manage.html)
   - two equal columns (the category list + the add-category form) side by
   side, matching Bootstrap's col-6/col-6, instead of the template
   category dialog's narrower single-column stack. */
.mr-category-manage--grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 640px) {
  .mr-category-manage--grid {
    grid-template-columns: 1fr;
  }
}
