/* Precise Fencing Portal — matches marketing brand */
:root {
  --primary: #1b3726;
  --primary-dark: #132219;
  --accent-green: #4a8965;
  --accent-tan: #ba895c;
  --cream: #f3f0eb;
  --cream-dark: #bdc2ba;
  --sage: #516557;
  --button: #446352;
  --button-hover: #38674c;
  --white: #ffffff;
  --danger: #a33a2f;
  --warning: #b8860b;
  --success: #2d6a4f;
  --shadow: 0 2px 12px rgba(27, 55, 38, 0.08);
  --radius: 12px;
  --radius-lg: 16px;
  --font: "Oswald", system-ui, sans-serif;
  --sidebar-w: 260px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --text: #1b3726;
  --muted: #516557;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  /* Keep vertical scroll locked; no side-to-side drift on mobile */
  overflow-x: hidden;
  overscroll-behavior-x: none;
  width: 100%;
  max-width: 100%;
}

body {
  font-family: var(--font);
  font-weight: 500;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  font-size: 1.05rem;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  width: 100%;
  max-width: 100%;
  position: relative;
}

/* Soft page motion — keep subtle so UI doesn’t feel busy */
@keyframes portal-fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes portal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Detail drawer (card click → smooth sheet / modal, not a dumped block) */
.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 34, 25, 0.5);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.32s var(--ease-out), visibility 0.32s;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.detail-backdrop.show {
  opacity: 1;
  visibility: visible;
}
.detail-drawer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(110%);
  width: min(640px, 100%);
  max-height: min(90vh, 760px);
  background: var(--white);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 48px rgba(19, 34, 25, 0.22);
  z-index: 310;
  display: flex;
  flex-direction: column;
  transition: transform 0.38s var(--ease-out);
  overflow: hidden;
  will-change: transform;
}
.detail-drawer.open {
  transform: translateX(-50%) translateY(0);
}
.detail-drawer.detail-drawer-lg {
  width: min(720px, 100%);
  max-height: min(92vh, 860px);
}
.detail-drawer-handle {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: rgba(27, 55, 38, 0.18);
  margin: 0.65rem auto 0.25rem;
  flex-shrink: 0;
}
.detail-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.4rem 0.95rem;
  padding-left: max(1.4rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.4rem, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid rgba(27, 55, 38, 0.08);
  flex-shrink: 0;
}
.detail-drawer-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-drawer-body {
  /* Keep content inset from the drawer edges (not flush) */
  padding: 1.35rem 1.5rem 2rem;
  padding-left: max(1.5rem, env(safe-area-inset-left, 0px) + 1rem);
  padding-right: max(1.5rem, env(safe-area-inset-right, 0px) + 1rem);
  padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px) + 1.25rem);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  animation: portal-fade-up 0.35s var(--ease-out) both;
}
.detail-header-row {
  margin-bottom: 0.85rem;
}
.detail-section-title {
  margin: 1.25rem 0 0.55rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
@media (min-width: 720px) {
  .detail-drawer {
    bottom: auto;
    top: 50%;
    border-radius: 16px;
    max-height: min(82vh, 680px);
    transform: translate(-50%, -46%) scale(0.97);
    opacity: 0;
    visibility: hidden;
    transition:
      transform 0.36s var(--ease-out),
      opacity 0.3s var(--ease-out),
      visibility 0.3s;
    will-change: transform, opacity;
  }
  .detail-drawer.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
  }
  .detail-drawer.detail-drawer-lg {
    width: min(760px, 94vw);
    max-height: min(88vh, 820px);
  }
  .detail-drawer-handle { display: none; }
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

/* Layout — fixed green rail so it always fills the left edge while scrolling */
.portal-shell {
  display: block;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--cream);
}

.portal-sidebar {
  background:
    linear-gradient(180deg, rgba(27, 55, 38, 0.35) 0%, transparent 28%),
    var(--primary-dark);
  color: var(--cream);
  padding: 1.35rem 0.9rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid rgba(243, 240, 235, 0.06);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem 1rem;
  margin: 0 0.15rem;
  border-bottom: 1px solid rgba(243, 240, 235, 0.1);
}

.portal-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  padding: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.portal-brand span {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.25;
}

.portal-brand small {
  display: block;
  font-weight: 500;
  font-size: 0.72rem;
  color: rgba(243, 240, 235, 0.78);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.2rem;
}

.portal-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  padding: 0.25rem 0.15rem;
}

.portal-nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 3rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  color: rgba(243, 240, 235, 0.94);
  font-size: 1.02rem;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.35;
  font-weight: 600;
  transition:
    background 0.2s var(--ease-out),
    color 0.2s var(--ease-out),
    box-shadow 0.2s var(--ease-out);
}

.portal-nav a:hover {
  background: rgba(243, 240, 235, 0.12);
  color: #fff;
}

.portal-nav a.active {
  background: rgba(186, 137, 92, 0.24);
  color: #f5e0c8;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent-tan);
}

/* Website link always visible and distinct at bottom of nav */
.portal-nav a[href="/"] {
  margin-top: 0.85rem;
  border: 1px solid rgba(243, 240, 235, 0.2);
  color: #fff;
  background: rgba(243, 240, 235, 0.06);
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.portal-nav a[href="/"]:hover {
  background: rgba(243, 240, 235, 0.14);
  border-color: rgba(243, 240, 235, 0.32);
}

.portal-sidebar .btn-logout {
  width: auto;
  margin: 0.5rem 0.15rem 0;
  align-self: stretch;
  min-height: 3rem;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  border-color: rgba(243, 240, 235, 0.32);
  color: var(--cream);
  background: transparent;
  transition: transform 0.2s var(--ease-out), background 0.2s, border-color 0.2s;
}

.portal-sidebar .btn-logout:hover {
  transform: translateY(-1px);
  background: rgba(243, 240, 235, 0.1);
  border-color: rgba(243, 240, 235, 0.45);
  color: #fff;
}

.portal-main {
  padding: 1.65rem 1.85rem 3.25rem;
  margin-left: var(--sidebar-w);
  min-width: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--cream);
  animation: portal-fade-in 0.28s var(--ease-out) both;
}

.portal-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  animation: portal-fade-up 0.35s var(--ease-out) both;
}

.portal-topbar h1 {
  font-weight: 700;
  font-size: clamp(1.65rem, 3.2vw, 2.05rem);
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--primary);
}

.portal-topbar p {
  color: var(--muted);
  font-weight: 500;
  margin-top: 0.45rem;
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 38rem;
}

.menu-fab {
  display: none;
  background: var(--primary);
  color: var(--cream);
  border: none;
  border-radius: 10px;
  min-height: 2.85rem;
  padding: 0.7rem 1.15rem;
  cursor: pointer;
  letter-spacing: 0.02em;
  text-transform: none;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.65rem;
  box-shadow: 0 2px 10px rgba(27, 55, 38, 0.16);
}

/* Cards / tables */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  min-width: 0;
  max-width: 100%;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(27, 55, 38, 0.06);
  padding: 1.2rem 1.3rem;
  animation: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.card-grid .stat-card:nth-child(1) { animation-delay: 0.04s; }
.card-grid .stat-card:nth-child(2) { animation-delay: 0.08s; }
.card-grid .stat-card:nth-child(3) { animation-delay: 0.12s; }
.card-grid .stat-card:nth-child(4) { animation-delay: 0.16s; }
.card-grid .stat-card:nth-child(5) { animation-delay: 0.2s; }
.card-grid .stat-card:nth-child(6) { animation-delay: 0.24s; }

button.stat-card-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 2px solid transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition:
    border-color 0.28s var(--ease-out),
    box-shadow 0.28s var(--ease-out),
    transform 0.28s var(--ease-out),
    background 0.28s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
button.stat-card-btn:hover {
  border-color: rgba(74, 137, 101, 0.5);
  box-shadow: 0 4px 16px rgba(27, 55, 38, 0.1);
}
button.stat-card-btn:active {
  transform: scale(0.99);
  transition-duration: 0.12s;
}
button.stat-card-btn.active {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(74, 137, 101, 0.22), 0 8px 24px rgba(27, 55, 38, 0.1);
  background: #f7fbf8;
}
.stat-hint {
  margin-top: 0.55rem;
  font-size: 0.9rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--sage);
  font-weight: 500;
}

.stat-card .label {
  font-size: 0.95rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 0.45rem;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.15;
}

.stat-card .value.danger { color: var(--danger); }
.stat-card .value.warning { color: var(--warning); }
.stat-card .value.success { color: var(--success); }

.panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgba(27, 55, 38, 0.07);
  padding: 1.45rem 1.55rem;
  margin-bottom: 1.25rem;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto; /* wide tables scroll inside the panel, not the whole page */
  overflow-wrap: break-word;
  animation: none;
}

.panel:hover {
  box-shadow: var(--shadow);
}

.panel h2 {
  font-size: 1.28rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.panel > .form-hint:first-of-type,
.panel-header + .form-hint {
  margin-bottom: 1rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

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

/* Collapsible create forms — keep lists visible first */
.panel-collapsible {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}
.panel-collapsible.is-open {
  padding-top: 1.45rem;
  padding-bottom: 1.45rem;
}
.panel-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: none;
  border: 0;
  padding: 0.35rem 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.panel-toggle:hover .panel-toggle-title {
  color: var(--accent-green);
}
.panel-toggle-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}
.panel-toggle-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}
.panel-toggle-hint {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--sage);
  letter-spacing: 0.02em;
}
.panel-toggle-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: rgba(27, 55, 38, 0.06);
  color: var(--primary);
  font-size: 0.85rem;
  transition: transform 0.28s var(--ease-out), background 0.2s;
}
.panel-collapsible.is-open .panel-toggle-chevron {
  transform: rotate(180deg);
  background: rgba(74, 137, 101, 0.15);
}
.panel-collapse-body {
  display: none;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(27, 55, 38, 0.08);
}
.panel-collapsible.is-open .panel-collapse-body {
  display: block;
  animation: portal-fade-up 0.32s var(--ease-out) both;
}
@media (max-width: 600px) {
  .panel-toggle-hint { display: none; }
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid rgba(27, 55, 38, 0.08);
  vertical-align: middle;
  max-width: 20rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

table.data th {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sage);
  font-weight: 500;
}

table.data tr:hover td {
  background: rgba(243, 240, 235, 0.45);
}

/* Whole row is the link (customers list, etc.) */
table.data tr.click-row {
  cursor: pointer;
}
table.data tr.click-row:hover td {
  background: rgba(74, 137, 101, 0.12);
}
table.data tr.click-row:focus {
  outline: none;
}
table.data tr.click-row:focus td {
  background: rgba(74, 137, 101, 0.16);
}
table.data tr.click-row:active td {
  background: rgba(74, 137, 101, 0.2);
}

.empty {
  text-align: center;
  color: var(--sage);
  padding: 2rem 1rem;
  font-weight: 500;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 600;
  background: var(--cream);
  color: var(--sage);
  line-height: 1.25;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.badge-sent { background: #e3eef0; color: #1a5c66; }
.badge-awaiting_payment { background: #e8f0ea; color: #2d5a40; }
.badge-paid, .badge-completed, .badge-signed { background: #d8f0e3; color: var(--success); }
.badge-past_due, .badge-failed, .badge-void { background: #f5d6d2; color: var(--danger); }
.badge-awaiting_check, .badge-pending, .badge-draft { background: #f5edd4; color: #7a5b00; }

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--cream);
  border: 2px solid rgba(27, 55, 38, 0.12);
}
.avatar-lg { width: 112px; height: 112px; }
.avatar-sm { width: 36px; height: 36px; }
.profile-head {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  min-width: 0;
  max-width: 100%;
}
.profile-head .meta {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 100%;
}
.profile-head .meta h2 {
  margin-bottom: 0.25rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.profile-head .meta p {
  color: var(--sage);
  font-weight: 500;
  margin: 0.15rem 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
a.row-link {
  color: var(--primary);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
a.row-link:hover { color: var(--accent-green); }
.actions-stack {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
  max-width: 100%;
  align-items: flex-start;
}
.actions-stack .btn {
  width: auto;
  max-width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}
.actions-stack-row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  max-width: 100%;
}
.actions-stack-row .btn {
  width: auto;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

/* Customer list — dense, readable rows (desktop spreads across the row) */
.customer-cards {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
a.customer-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(27, 55, 38, 0.1);
  border-radius: 10px;
  background: var(--white);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  cursor: pointer;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
a.customer-card:hover {
  border-color: var(--accent-green);
  box-shadow: 0 2px 10px rgba(27, 55, 38, 0.07);
  background: #f7faf8;
}
a.customer-card:active {
  transform: scale(0.997);
}
.customer-card .avatar,
.customer-card .avatar-sm {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}
.customer-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.customer-card-name {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
}
.customer-card-line {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.customer-card-addr {
  color: var(--sage);
  font-weight: 400;
  font-size: 0.88rem;
}
.customer-card-meta {
  margin-top: 0.1rem;
  font-size: 0.78rem;
  color: var(--sage);
  font-weight: 500;
  white-space: nowrap;
}

/* Desktop: spread name / email / phone / address / date across the row */
@media (min-width: 901px) {
  .customer-cards {
    gap: 0.4rem;
  }

  a.customer-card {
    padding: 0.65rem 1rem;
    gap: 0.95rem;
  }

  .customer-card-body {
    display: grid;
    /* minmax(0, …) so columns can shrink — avoids text blowing out of the row */
    grid-template-columns:
      minmax(0, 1.15fr)
      minmax(0, 1.45fr)
      minmax(0, 0.9fr)
      minmax(0, 1.25fr)
      minmax(4.5rem, auto);
    column-gap: 1.15rem;
    row-gap: 0;
    align-items: center;
  }

  .customer-card-name {
    font-size: 1rem;
    margin: 0;
  }

  .customer-card-line {
    font-size: 0.9rem;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
  }

  .customer-card-addr {
    font-size: 0.88rem;
  }

  .customer-card-meta {
    margin: 0;
    text-align: right;
    font-size: 0.8rem;
    justify-self: end;
  }
}

/* Invoice / list cards — clean hierarchy, not cramped stacks of text */
.invoice-cards {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
  max-width: 100%;
}
.invoice-card {
  border: 1px solid rgba(27, 55, 38, 0.1);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.15rem;
  background: var(--white);
  animation: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden; /* keep long titles/badges inside the card */
}

a.invoice-card-link,
.invoice-card.click-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  cursor: pointer;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
a.invoice-card-link:hover,
.invoice-card.click-card:hover {
  border-color: var(--accent-green);
  box-shadow: 0 3px 12px rgba(27, 55, 38, 0.08);
  background: #f7faf8;
}
.invoice-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0;
  min-width: 0;
  max-width: 100%;
}
/* Title block must shrink so badge can stay on the right without overflowing */
.invoice-card-top > :first-child {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.invoice-card-top .badge {
  flex: 0 0 auto;
  max-width: min(42%, 9.5rem);
}
.invoice-card-num,
.invoice-card-top strong {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: block;
  line-height: 1.25;
  color: var(--primary);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.invoice-card-sub {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  margin-top: 0.2rem;
  line-height: 1.35;
  /* One calm secondary line — don’t stack multiple dense lines */
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.invoice-card-sub + .invoice-card-sub {
  display: none; /* hide extra sub-lines; keep card scannable */
}
.invoice-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.85rem;
  margin: 0;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(27, 55, 38, 0.08);
  font-size: 0.98rem;
  color: var(--muted);
  font-weight: 500;
  min-width: 0;
  max-width: 100%;
}
.invoice-card-meta > span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.invoice-card-meta > span:not(.invoice-card-amount) {
  font-weight: 500;
}
/* Only show amount + due on the meta row; extra spans hide for calm layout */
.invoice-card-meta > span:nth-child(n+3) {
  display: none;
}
.invoice-card-amount {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}
.invoice-card .actions-stack,
.invoice-card .actions-stack-row,
.invoice-card .btn-row,
.invoice-card > .btn {
  margin-top: 0.15rem;
}
.detail-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
  min-width: 0;
  max-width: 100%;
}
.detail-fact {
  background: var(--cream);
  border-radius: 10px;
  padding: 0.95rem 1.1rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}
.detail-fact-label {
  display: block;
  font-size: 0.88rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--sage);
  margin-bottom: 0.35rem;
  font-weight: 600;
}
.detail-fact-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  padding: 0;
}
.detail-fact-value.danger { color: var(--danger); }
.detail-desc {
  margin-bottom: 1rem;
  color: var(--sage);
  font-weight: 500;
  line-height: 1.5;
  font-size: 1rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  padding: 0 0.1rem;
}

/* Buttons — roomy touch targets, clear labels */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.85rem;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  border: 1.5px solid transparent;
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
  max-width: 100%;
  cursor: pointer;
  transition: background 0.2s var(--ease-out), transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), border-color 0.2s;
  background: var(--button);
  color: var(--cream);
  line-height: 1.25;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: var(--button-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(27, 55, 38, 0.16);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-accent {
  background: var(--accent-tan);
  color: #fff;
  border-color: var(--accent-tan);
}
.btn-accent:hover { background: #c99a6b; border-color: #c99a6b; }

.btn-secondary {
  background: var(--white);
  color: var(--primary);
  border-color: rgba(27, 55, 38, 0.28);
  box-shadow: 0 1px 2px rgba(27, 55, 38, 0.04);
}
.btn-secondary:hover {
  background: var(--primary);
  color: var(--cream);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  min-height: 2.45rem;
  padding: 0.55rem 0.95rem;
  font-size: 0.9rem;
  border-radius: 9px;
  font-weight: 600;
}

/* Full-width only where intentional (login, mobile cards) */
.btn-block {
  width: 100%;
  min-height: 3.1rem;
  font-size: 1.02rem;
}

/* Card actions: fit content on desktop, full width on small screens */
.invoice-card > .btn,
.invoice-card .btn-block {
  width: auto;
  min-width: 8.5rem;
  margin-top: 0.35rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.1rem;
  align-items: center;
}

.btn-row .btn {
  flex: 0 1 auto;
}

/* Action groups still readable — not tiny chips */
.btn-row.btn-row-compact {
  margin: 0;
  gap: 0.55rem;
}
.btn-row.btn-row-compact .btn {
  min-height: 2.45rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
}

/* Table cells with buttons shouldn't stretch rows awkwardly */
table.data td .btn-row {
  justify-content: flex-end;
}
table.data td .actions-stack {
  max-width: 16rem;
}

/* Email preview / reminder draft */
.email-draft {
  background: var(--cream);
  border: 1px solid rgba(27, 55, 38, 0.12);
  border-radius: 12px;
  padding: 1.15rem 1.25rem;
  margin-top: 0.75rem;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}
.email-draft-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sage);
  font-weight: 500;
  margin-bottom: 0.4rem;
}
.email-draft-subject {
  font-weight: 700;
  font-size: 1.02rem;
  margin-bottom: 0.85rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 0 0.05rem;
}
.email-draft-body {
  white-space: pre-wrap;
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--primary);
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding: 0.15rem 0.1rem 0.25rem;
  font-family: inherit;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  box-sizing: border-box;
}

/* Forms */
.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid.two {
  grid-template-columns: 1fr 1fr;
}

.preview-box {
  background: var(--cream);
  border: 1px solid rgba(27, 55, 38, 0.12);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.92rem;
  line-height: 1.45;
  min-height: 3.5rem;
}

.pdf-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.pdf-frame-wrap {
  border: 1px solid rgba(27, 55, 38, 0.15);
  border-radius: 8px;
  overflow: hidden;
  background: #525659;
  min-height: 480px;
}

.pdf-frame {
  width: 100%;
  height: min(70vh, 720px);
  border: 0;
  display: block;
  background: #525659;
}

.form-group label {
  display: block;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--primary);
  margin-bottom: 0.45rem;
  font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  min-height: 3rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid rgba(27, 55, 38, 0.18);
  border-radius: 10px;
  background: var(--white);
  color: var(--primary);
  font-size: 1.02rem;
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: 2px solid var(--accent-green);
  outline-offset: 1px;
}

.form-hint {
  font-size: 0.95rem;
  color: var(--sage);
  font-weight: 500;
  margin-top: 0.4rem;
  line-height: 1.5;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.alert-error { background: #f5d6d2; color: var(--danger); }
.alert-success { background: #d8f0e3; color: var(--success); }
.alert-info { background: #e3eef0; color: #1a5c66; }

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(160deg, rgba(27, 55, 38, 0.92), rgba(19, 34, 25, 0.96)),
    var(--primary);
}

.login-card {
  width: min(420px, 100%);
  background: var(--cream);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg, var(--shadow));
  padding: 2rem 1.75rem;
  animation: portal-fade-up 0.5s var(--ease-out) both;
}

.login-card .logo-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.login-card .logo-row img { width: 48px; height: 48px; }

.login-card h1 {
  font-size: 1.35rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-card .sub {
  color: var(--sage);
  font-weight: 500;
  margin-bottom: 1.25rem;
  line-height: 1.55;
}

/* Contract / sign */
.contract-body {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  max-height: 420px;
  overflow: auto;
  margin-bottom: 1.25rem;
  line-height: 1.65;
  color: var(--text);
  font-weight: 500;
}

.contract-body h1, .contract-body h2, .contract-body h3 {
  color: var(--primary);
  margin: 0.75rem 0 0.4rem;
}

.sign-pad-wrap {
  border: 2px dashed rgba(27, 55, 38, 0.25);
  border-radius: var(--radius);
  background: #fff;
  touch-action: none;
  margin: 0.75rem 0;
}

.sign-pad-wrap canvas {
  display: block;
  width: 100%;
  height: 180px;
  cursor: crosshair;
  border-radius: inherit;
}

.consent {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin: 1rem 0;
  font-size: 1rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.5;
}

.consent input { margin-top: 0.3rem; }

/* Chat */
.chat-box {
  display: flex;
  flex-direction: column;
  height: min(70vh, 560px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg {
  max-width: min(85%, 480px);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.msg-me {
  align-self: flex-end;
  background: var(--primary);
  color: var(--cream);
  border-bottom-right-radius: 4px;
}

.msg-them {
  align-self: flex-start;
  background: var(--cream);
  color: var(--primary);
  border-bottom-left-radius: 4px;
}

.msg time {
  display: block;
  font-size: 0.78rem;
  opacity: 0.85;
  margin-top: 0.35rem;
  font-weight: 500;
}

.chat-compose {
  display: flex;
  gap: 0.65rem;
  border-top: 1px solid rgba(27, 55, 38, 0.1);
  padding-top: 0.85rem;
}

.chat-compose input {
  flex: 1;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(27, 55, 38, 0.18);
  background: var(--cream);
}

/* Pay options (payment structure, customer pay method, etc.) — compact tiles, not huge bars */
.pay-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
  max-width: 36rem;
}

.pay-option {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.55rem 0.7rem;
  border: 1.5px solid rgba(27, 55, 38, 0.16);
  border-radius: 9px;
  cursor: pointer;
  background: var(--white);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  margin: 0;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.pay-option input[type="radio"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
  width: 0.95rem;
  height: 0.95rem;
  accent-color: var(--accent-green);
}
.pay-option > div,
.pay-option > span:not(:first-child) {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pay-option:has(input:checked),
.pay-option.selected {
  border-color: var(--accent-green);
  background: #f3f8f5;
  box-shadow: inset 0 0 0 1px rgba(74, 137, 101, 0.25);
}

.pay-option strong {
  display: block;
  margin-bottom: 0.1rem;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.25;
  color: var(--primary);
}

.pay-option span {
  font-size: 0.78rem;
  color: var(--sage);
  font-weight: 500;
  line-height: 1.3;
  display: block;
}

/* Mobile */
@media (max-width: 900px) {
  .portal-shell {
    display: block;
  }

  .portal-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 88vw);
    height: 100vh;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-105%);
    transition: transform 0.36s var(--ease-out);
    box-shadow: 8px 0 32px rgba(19, 34, 25, 0.2);
    will-change: transform;
  }

  .portal-sidebar.open {
    transform: translateX(0);
  }

  .portal-main {
    margin-left: 0;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(19, 34, 25, 0.48);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.32s var(--ease-out), visibility 0.32s;
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
  }

  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  .menu-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.4rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.9rem;
  }

  .portal-nav a {
    min-height: 2.75rem;
    font-size: 1rem;
    padding: 0.7rem 1rem;
  }

  .btn {
    min-height: 2.25rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
  }

  .btn-sm {
    min-height: 2rem;
    padding: 0.32rem 0.65rem;
    font-size: 0.78rem;
  }

  /* Login / chat: full-width but still modest height */
  .login-page .btn-block,
  .login-card .btn-block,
  .chat-compose .btn {
    width: 100%;
    min-height: 2.45rem;
    aspect-ratio: auto;
    white-space: nowrap;
    font-size: 0.9rem;
  }

  /*
   * Action buttons: compact chips that wrap (not huge stretched tiles)
   */
  .actions-stack,
  .actions-stack-row,
  .invoice-card .btn-row,
  .detail-drawer-body .btn-row,
  .panel .btn-row:not(.btn-row-keep-inline) {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
    align-items: center;
  }

  .actions-stack .btn,
  .actions-stack-row .btn,
  .invoice-card .btn-row .btn,
  .invoice-card .btn-row a.btn,
  .detail-drawer-body .btn-row .btn,
  .detail-drawer-body .btn-row a.btn,
  .panel .btn-row:not(.btn-row-keep-inline) .btn,
  .panel .btn-row:not(.btn-row-keep-inline) a.btn {
    width: auto !important;
    min-width: 0 !important;
    max-width: 100%;
    flex: 0 1 auto;
    min-height: 2.2rem;
    height: auto;
    aspect-ratio: auto;
    max-height: none;
    padding: 0.35rem 0.7rem;
    white-space: normal; /* long labels wrap instead of escaping the card */
    text-align: center;
    line-height: 1.2;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
  }

  /* Single primary CTA on a card — compact pill, not a giant bar */
  .invoice-card > .btn,
  .invoice-card > a.btn {
    display: inline-flex;
    width: auto;
    min-width: 0;
    max-width: 100%;
    min-height: 2.25rem;
    height: auto;
    aspect-ratio: auto;
    max-height: none;
    margin-top: 0.1rem;
    padding: 0.4rem 0.9rem;
    white-space: nowrap;
    text-align: center;
    line-height: 1.2;
    font-size: 0.85rem;
    border-radius: 8px;
  }

  .btn-row.btn-row-compact {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .btn-row.btn-row-compact .btn,
  .btn-row.btn-row-compact a.btn {
    width: auto !important;
    flex: 0 1 auto;
    aspect-ratio: auto;
    min-height: 2rem;
    max-height: none;
    padding: 0.3rem 0.6rem;
    white-space: nowrap;
    font-size: 0.76rem;
    border-radius: 8px;
  }

  .portal-nav a {
    font-size: 1.05rem;
    padding: 0.95rem 1.05rem;
  }

  .form-grid.two { grid-template-columns: 1fr; }

  .portal-main {
    padding: 1rem 0.75rem 5rem;
    overflow-x: hidden;
  }

  .portal-topbar h1 {
    font-size: 1.45rem;
    line-height: 1.25;
  }

  .portal-topbar p {
    font-size: 0.95rem;
    line-height: 1.45;
  }

  .panel {
    padding: 1.1rem 0.85rem;
    overflow-x: auto; /* keep content inside panel edges */
  }

  .panel h2 {
    font-size: 1.2rem;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Top dashboard tiles — leave as 2-up (not full-width stacks) */
  .card-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    min-width: 0;
  }

  .stat-card {
    padding: 0.9rem 0.85rem;
  }

  .stat-card .label {
    font-size: 0.68rem;
    line-height: 1.3;
  }

  .stat-card .value {
    font-size: 1.55rem;
  }

  /* Invoice / outstanding / past-due list cards */
  .invoice-cards {
    gap: 0.65rem;
    margin-inline: 0;
  }

  .invoice-card {
    padding: 1rem 0.95rem;
  }

  .invoice-card-num {
    font-size: 1.15rem;
  }

  .invoice-card-amount {
    font-size: 1.5rem;
  }

  .invoice-card-meta {
    font-size: 1.02rem;
    gap: 0.5rem 1rem;
  }

  .badge {
    font-size: 0.7rem;
    padding: 0.3rem 0.65rem;
    white-space: nowrap;
  }

  .detail-drawer-header {
    padding: 0.9rem 1.25rem 1rem;
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px) + 0.75rem);
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px) + 0.75rem);
  }

  .detail-drawer-body {
    padding: 1.25rem 1.25rem 2.25rem;
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px) + 0.85rem);
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px) + 0.85rem);
    padding-bottom: max(2.25rem, env(safe-area-inset-bottom, 0px) + 1.5rem);
  }

  .detail-facts {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .detail-fact {
    padding: 1rem 1.15rem;
  }

  .detail-fact-value {
    font-size: 1.2rem;
  }

  .email-draft {
    padding: 1.1rem 1.15rem;
  }

  .pay-options {
    grid-template-columns: 1fr;
    max-width: none;
    gap: 0.4rem;
  }

  .pay-option {
    padding: 0.5rem 0.65rem;
  }

  .pay-option strong {
    font-size: 0.88rem;
  }

  .pay-option span {
    font-size: 0.76rem;
    line-height: 1.3;
  }

  .login-page .btn-block,
  .login-card .btn-block {
    min-height: 2.45rem;
    font-size: 0.9rem;
    width: 100%;
    aspect-ratio: auto;
  }

  .invoice-card {
    padding: 0.95rem 0.9rem 1rem;
    gap: 0.5rem;
  }

  .invoice-card-num {
    font-size: 1.12rem;
  }

  .invoice-card-sub {
    font-size: 0.9rem;
  }

  .invoice-card-amount {
    font-size: 1.25rem;
  }

  table.data {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    font-size: 0.92rem;
  }

  table.data th,
  table.data td {
    padding: 0.85rem 0.65rem;
  }

  /* Mobile customers: stacked lines, still full usable width */
  .customer-cards {
    gap: 0.5rem;
  }

  .customer-card {
    align-items: flex-start;
    padding: 0.8rem 0.75rem;
  }

  .customer-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
  }

  .customer-card-line {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
  }
}

@media (max-width: 400px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* Install schedule calendar */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.35rem;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sage);
  font-weight: 500;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
}
.cal-cell {
  min-height: 4.5rem;
  border: 1px solid rgba(27, 55, 38, 0.1);
  border-radius: 10px;
  background: var(--cream);
  padding: 0.4rem 0.35rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: border-color 0.15s, background 0.15s;
}
.cal-cell:hover { border-color: var(--accent-green); }
.cal-cell.cal-empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
  min-height: 0;
}
.cal-cell.is-today { outline: 2px solid var(--accent-tan); }
.cal-cell.is-selected {
  border-color: var(--primary);
  background: #e8f0ea;
}
.cal-cell.has-jobs { background: #f3f8f5; }
.cal-daynum {
  font-weight: 700;
  font-size: 0.9rem;
}
.cal-count {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-green);
  font-weight: 500;
}
.cal-chip {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--sage);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 700px) {
  .cal-chip { display: none; }
  .cal-cell { min-height: 3.2rem; padding: 0.3rem; }
}

.hidden { display: none !important; }

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--sage);
  font-weight: 500;
}

/* Table body text clearer */
table.data {
  font-weight: 500;
}
table.data th {
  font-weight: 600;
  color: var(--sage);
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.9rem;
}
