:root {
  --ink: #202f2a;
  --muted: #7a857f;
  --green: #25664b;
  --line: #e5e9e5;
  --bg: #f6f8f5;
  --surface: #fff;
  --soft: #edf4eb;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
aside {
  width: 240px;
  position: fixed;
  inset: 0 auto 0 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 35px 22px;
  display: flex;
  flex-direction: column;
}
.brand {
  text-decoration: none;
  color: var(--green);
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 34px;
  font-weight: 600;
}
.brand span {
  font-size: 24px;
  letter-spacing: -1px;
}
.brand small {
  display: block;
  font-size: 8px;
  letter-spacing: 1.6px;
  margin-top: 6px;
  color: var(--muted);
}
.nav-label {
  font-size: 10px;
  letter-spacing: 1.8px;
  color: #929c95;
  margin: 54px 13px 18px;
}
nav {
  display: grid;
  gap: 8px;
}
nav button {
  text-align: left;
  border: 0;
  background: none;
  color: #737e77;
  padding: 14px 16px;
  border-radius: 7px;
  font-size: 13px;
}
nav button.active {
  background: #eaf2e9;
  color: #285b40;
  font-weight: 650;
}
nav button:hover {
  background: #f0f4ef;
}
.sidebar-bottom {
  margin-top: auto;
  padding: 20px 10px 0;
  font-size: 11px;
  color: #718176;
}
.sidebar-bottom p {
  line-height: 1.8;
  color: #9aa39d;
}
.status-dot {
  display: inline-block;
  background: #689b71;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
}
main {
  margin-left: 240px;
}
header {
  height: 84px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 42px;
}
.breadcrumb {
  font-size: 12px;
  color: var(--muted);
}
.breadcrumb span {
  margin: 0 16px;
  color: #c1c9c2;
}
.breadcrumb b {
  font-weight: 500;
  color: #3b4b40;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  font-size: 12px;
}
.avatar {
  border-radius: 50%;
  background: #e7ede3;
  color: #546c4a;
  padding: 10px 14px;
  font-weight: 600;
}
.content {
  max-width: 1480px;
  margin: auto;
  padding: 40px 42px 20px;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}
.eyebrow {
  font-size: 10px;
  color: #84917e;
  letter-spacing: 1.8px;
  margin-bottom: 10px;
}
h1 {
  font-size: 29px;
  letter-spacing: -1px;
  margin: 0 0 10px;
  font-weight: 600;
}
.page-head p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  line-height: 1.6;
}
.primary {
  background: var(--green);
  border: 1px solid var(--green);
  color: white;
  padding: 12px 19px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
}
.primary:hover {
  background: #174f37;
}
.secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 6px;
  color: #526154;
  font-size: 12px;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin: 22px 0;
}
.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.metric {
  padding: 23px;
}
.metric-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #728075;
  font-size: 12px;
}
.metric-icon {
  padding: 7px 10px;
  background: #eff4ec;
  border-radius: 6px;
  color: #607a53;
}
.metric strong {
  display: block;
  font-size: 27px;
  letter-spacing: -0.8px;
  margin: 18px 0 10px;
  font-weight: 600;
}
.metric small {
  color: #879087;
  font-size: 10px;
}
.metric.featured {
  background: #285b43;
  border-color: #285b43;
  color: #fff;
}
.metric.featured .metric-top,
.metric.featured small {
  color: #d4e2d5;
}
.metric.featured .metric-icon {
  color: #d4e2d5;
  background: #3e6c53;
}
.grid-two {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 22px;
  margin: 24px 0;
}
.panel {
  padding: 24px;
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 22px;
}
.panel h2 {
  font-size: 15px;
  margin: 0;
  font-weight: 600;
}
.panel p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.panel-head p {
  margin: 7px 0 0;
}
.link {
  border: 0;
  background: none;
  color: var(--green);
  font-size: 12px;
  padding: 5px;
}
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.filters input,
.filters select {
  background: var(--surface);
}
.pill {
  display: inline-block;
  font-size: 10px;
  border-radius: 4px;
  padding: 5px 8px;
  background: #edf4eb;
  color: #547a4a;
  white-space: nowrap;
}
.pill.red {
  color: #a66a49;
  background: #fcf0e7;
}
.table-wrap {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}
th {
  font-size: 10px;
  color: #879187;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
}
td {
  font-size: 12px;
  border-bottom: 1px solid #eff1ee;
  padding: 17px 10px;
}
tr:last-child td {
  border-bottom: 0;
}
.sub {
  display: block;
  font-size: 10px;
  color: #919a92;
  margin-top: 5px;
}
.positive {
  color: #337653;
}
.negative {
  color: #b36b51;
}
.empty {
  text-align: center;
  padding: 36px 15px;
  color: #8b968b;
  font-size: 13px;
  line-height: 1.8;
}
.empty strong {
  display: block;
  color: #526653;
  font-weight: 500;
}
.business-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 17px 0;
  border-bottom: 1px solid #eef1ec;
}
.business-row:last-child {
  border: 0;
}
.business-icon {
  background: #f0f3e9;
  border-radius: 8px;
  padding: 12px;
  font-size: 19px;
  color: #6c8056;
}
.business-row strong {
  font-size: 12px;
  font-weight: 550;
}
.business-row p {
  font-size: 10px;
  margin: 5px 0;
}
.business-row .amount {
  margin-left: auto;
  text-align: right;
  font-size: 13px;
}
.bar-chart {
  height: 190px;
  display: flex;
  gap: 15px;
  align-items: flex-end;
  padding-top: 15px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}
.chart-col {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 100%;
  justify-content: center;
}
.bar {
  width: 24%;
  background: #518162;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}
.bar.expense {
  background: #dbe5d4;
}
.chart-label {
  position: absolute;
  bottom: -25px;
  font-size: 9px;
  color: #84907f;
}
.chart-legend {
  display: flex;
  gap: 20px;
  font-size: 10px;
  color: #788471;
}
.chart-legend i {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #518162;
  margin-right: 6px;
  border-radius: 2px;
}
.chart-legend i.light {
  background: #dbe5d4;
}
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.asset-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.asset-title h2 {
  font-size: 18px;
}
.asset-stats {
  display: flex;
  gap: 28px;
  margin: 22px 0;
}
.asset-stats small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 8px;
}
.asset-stats strong {
  font-size: 19px;
}
.actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.progress {
  height: 6px;
  border-radius: 4px;
  background: #ecf0e8;
  overflow: hidden;
  margin: 15px 0;
}
.progress span {
  display: block;
  height: 100%;
  background: #64845a;
}
footer {
  font-size: 10px;
  color: #99a295;
  margin: 36px 0 8px;
}
footer span {
  margin: 0 8px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 480px;
  max-width: calc(100vw - 24px);
  padding: 26px;
  box-shadow: 0 20px 80px #112b2522;
}
dialog::backdrop {
  background: #172c2866;
  backdrop-filter: blur(3px);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
.modal-head h2 {
  font-size: 21px;
  margin: 0;
}
.icon-button {
  border: 0;
  background: transparent;
  font-size: 28px;
  color: #7f8b80;
}
label {
  display: block;
  font-size: 12px;
  color: #536453;
  margin-bottom: 15px;
}
input,
select,
textarea {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #dce3d9;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  margin-top: 7px;
  min-width: 0;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #acc7a5;
  outline-offset: 1px;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 15px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}
#form-error {
  font-size: 12px;
  color: #af4b3e;
  line-height: 1.5;
}
#notice:not(:empty) {
  background: #e8f0e4;
  padding: 12px 18px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 12px;
}
.hint {
  background: #f0f4eb;
  padding: 12px;
  font-size: 11px;
  color: #728069;
  line-height: 1.7;
  border-radius: 6px;
}
.section-gap {
  margin-top: 22px;
}
.search {
  max-width: 270px;
  margin: 0;
}
.badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.schedule {
  max-height: 220px;
  overflow: auto;
}
.alert {
  border-left: 3px solid #c18b5c;
  padding: 10px 14px;
  background: #faf4e9;
  color: #95734d;
  font-size: 12px;
  margin: 16px 0;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
@media (min-width: 1500px) {
  .content {
    padding-top: 50px;
  }
}
@media (max-width: 1100px) {
  aside {
    width: 205px;
    padding: 30px 14px;
  }
  main {
    margin-left: 205px;
  }
  .content {
    padding: 30px 25px;
  }
  header {
    padding: 0 25px;
  }
  .metrics {
    gap: 10px;
  }
  .metric {
    padding: 17px;
  }
  .metric strong {
    font-size: 22px;
  }
  .grid-two {
    grid-template-columns: 1fr;
  }
  .cards {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  .header-right {
    gap: 10px;
    font-size: 10px;
  }
  .content {
    padding: 25px 16px;
  }
  .page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 15px;
  }
  h1 {
    font-size: 25px;
  }
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .metric strong {
    font-size: 23px;
  }
  .metric {
    padding: 16px;
  }
  .panel {
    padding: 18px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
  .asset-stats {
    gap: 20px;
  }
  .asset-stats strong {
    font-size: 16px;
  }
}

.login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  margin: 0;
  width: 100%;
  max-width: 380px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 42px #20362a08;
}
.login-card h1 {
  margin-bottom: 28px;
  font-size: 27px;
}
.login-submit {
  width: 100%;
  margin-top: 10px;
}
.login-error {
  color: #af4b3e;
  font-size: 12px;
  line-height: 1.5;
}
.account-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
@media (max-width: 720px) {
  .header-right #today,
  .header-right .avatar {
    display: none;
  }
}
.account-actions[hidden] {
  display: none;
}

.chat-toggle {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 20;
  padding: 14px 20px;
  border: 1px solid #326f53;
  border-radius: 30px;
  background: var(--green);
  color: white;
  font-weight: 600;
  box-shadow: 0 6px 24px #173b2930;
}
.chat-panel {
  position: fixed;
  right: 28px;
  bottom: 86px;
  z-index: 25;
  width: 440px;
  height: min(690px, calc(100dvh - 110px));
  border: 1px solid #d5e1d4;
  border-radius: 14px;
  background: #f6f8f5;
  box-shadow: 0 15px 65px #1d3d2a30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-panel[hidden] {
  display: none;
}
.chat-head {
  padding: 18px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-head h2 {
  font-size: 16px;
  margin: 0 0 6px;
}
.chat-head span {
  color: var(--muted);
  font-size: 10px;
}
.chat-head > div:last-child {
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-messages {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  min-height: 100px;
  overscroll-behavior: contain;
}
.chat-message {
  padding: 13px 15px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.chat-message strong {
  display: block;
  font-size: 10px;
  color: #6e8569;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.chat-message > div {
  white-space: pre-wrap;
}
.chat-message.user {
  background: #e9f1e5;
  border-color: #dfe9d9;
  margin-left: 35px;
}
.chat-scope {
  font-size: 10px;
  color: #7c887a;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-bottom: 0;
}
.chat-message details {
  font-size: 10px;
  color: #71836b;
  margin-top: 9px;
}
.chat-message ul {
  padding-left: 16px;
}
.chat-examples {
  display: flex;
  gap: 6px;
  overflow: auto;
  padding: 10px 16px;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
}
.chat-examples button {
  border: 1px solid #dbe5d5;
  background: var(--surface);
  border-radius: 20px;
  font-size: 10px;
  color: #53714d;
  padding: 8px 12px;
  white-space: nowrap;
}
.chat-examples button:hover {
  background: #e7eee1;
}
.chat-form {
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-form textarea {
  resize: none;
  max-height: 90px;
  font-size: 12px;
  margin: 0;
}
.chat-form button {
  padding: 12px;
}
.chat-disclaimer {
  color: #87927f;
  font-size: 9px;
  line-height: 1.6;
  margin: 0;
  padding: 0 16px 12px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
@media (max-width: 540px) {
  .chat-panel {
    right: 10px;
    left: 10px;
    bottom: 78px;
    width: auto;
    height: calc(100dvh - 102px);
  }
  .chat-toggle {
    right: 16px;
    bottom: 16px;
    padding: 12px 17px;
  }
  .chat-head {
    padding: 14px 16px;
  }
}

/* Navigation and small-screen layout */
#sidebar {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.header-left,
.sidebar-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.sidebar-heading {
  justify-content: space-between;
}
.mobile-wordmark,
.menu-toggle,
.nav-close {
  display: none;
}
.nav-backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  border: 0;
  background: #142c2470;
  backdrop-filter: blur(2px);
  touch-action: none;
}
.nav-backdrop[hidden] {
  display: none;
}
.sidebar-bottom .account-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.sidebar-bottom .account-actions button {
  min-height: 44px;
  text-align: left;
  font-size: 12px;
}
#workspace,
.metric,
.header-location,
.page-head > div,
.asset-stats > div {
  min-width: 0;
}
.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.metric strong,
.asset-stats strong {
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.metric-top {
  gap: 8px;
}
.metric-top .metric-icon {
  flex-shrink: 0;
}
.asset-title {
  gap: 12px;
}
.asset-title h2 {
  overflow-wrap: anywhere;
}
.business-row > div {
  min-width: 0;
  overflow-wrap: anywhere;
}
.business-row .amount {
  max-width: 45%;
  flex-shrink: 0;
}
.table-wrap {
  max-width: 100%;
  min-width: 0;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid #739b65;
  outline-offset: 3px;
}
#title:focus {
  outline: none;
}
dialog {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (max-width: 900px) {
  html.nav-open,
  html.nav-open body {
    overflow: hidden;
  }
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(300px, calc(100vw - 48px));
    height: 100dvh;
    padding: calc(20px + env(safe-area-inset-top)) 20px
      calc(20px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--line);
    border-bottom: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 0.2s ease,
      visibility 0.2s ease;
    box-shadow: 10px 0 40px #172e2520;
  }
  html.nav-open #sidebar {
    transform: translateX(0);
    visibility: visible;
  }
  #sidebar .brand {
    font-size: 30px;
  }
  #sidebar .brand span {
    font-size: 22px;
  }
  #sidebar .brand small {
    display: block;
    font-size: 7px;
    letter-spacing: 1.2px;
  }
  #sidebar .nav-label {
    display: block;
    margin: 30px 12px 14px;
  }
  #sidebar nav {
    display: grid;
    gap: 7px;
    margin: 0;
    overflow: visible;
  }
  #sidebar nav button {
    min-height: 48px;
    white-space: normal;
    font-size: 14px;
    padding: 13px 16px;
  }
  #sidebar .sidebar-bottom {
    display: block;
    padding: 26px 6px 0;
  }
  .nav-close,
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    border-radius: 8px;
  }
  .menu-toggle {
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--green);
    padding: 0;
  }
  #workspace {
    margin-left: 0;
    width: 100%;
  }
  #workspace > header {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 72px;
    height: auto;
    padding: 12px max(16px, env(safe-area-inset-right)) 12px
      max(16px, env(safe-area-inset-left));
    gap: 12px;
  }
  .mobile-wordmark {
    display: block;
    font-weight: 650;
    font-size: 13px;
    color: var(--green);
    letter-spacing: -0.3px;
    margin-bottom: 3px;
  }
  .breadcrumb-workspace {
    display: none;
  }
  .breadcrumb b {
    display: block;
    font-size: 12px;
    overflow-wrap: anywhere;
  }
  .header-right {
    gap: 0;
    flex-shrink: 0;
    font-size: 11px;
  }
  .content {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }
  .page-head {
    align-items: flex-start;
  }
  .page-head h1 {
    font-size: clamp(24px, 3.5vw, 29px);
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .panel-head {
    flex-wrap: wrap;
    gap: 12px;
  }
  .asset-stats {
    flex-wrap: wrap;
    gap: 20px;
  }
  .asset-stats > div {
    flex: 1 1 100px;
  }
  .primary,
  .secondary,
  .actions .link,
  summary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  summary {
    justify-content: flex-start;
    padding-block: 10px;
  }
  .chat-toggle {
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: max(16px, env(safe-area-inset-right));
    min-height: 48px;
  }
  input,
  select,
  textarea,
  .chat-form textarea {
    font-size: 16px;
  }
  .form-actions {
    position: sticky;
    bottom: -1px;
    background: var(--surface);
    padding: 14px 0 max(2px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
  }
  .icon-button {
    min-width: 44px;
    min-height: 44px;
  }
}
@media (max-width: 540px) {
  .page-head {
    align-items: stretch;
  }
  .page-head #add-button {
    width: 100%;
  }
  .panel {
    padding: 16px;
  }
  .panel-head {
    margin-bottom: 16px;
  }
  .panel-head > .secondary {
    flex-shrink: 0;
  }
  .filters {
    gap: 10px;
  }
  .filters input,
  .filters select {
    width: 100% !important;
    max-width: none;
  }
  .filters .sub {
    width: 100%;
    line-height: 1.6;
  }
  .business-row {
    gap: 10px;
  }
  .business-icon {
    padding: 10px;
    font-size: 17px;
  }
  .business-row .amount {
    font-size: 12px;
  }
  dialog {
    width: calc(100vw - 24px);
    padding: 20px;
    max-height: calc(100dvh - 24px);
  }
  .modal-head h2 {
    font-size: 20px;
    overflow-wrap: anywhere;
  }
  .chat-panel {
    z-index: 45;
    top: calc(var(--chat-offset-top, 0px) + env(safe-area-inset-top) + 8px);
    bottom: auto;
    left: 8px;
    right: 8px;
    width: auto;
    height: calc(
      var(--chat-viewport-height, 100dvh) - 16px - env(safe-area-inset-top) -
        env(safe-area-inset-bottom)
    );
    max-height: none;
  }
  .chat-head {
    flex-shrink: 0;
    padding: 10px 12px;
  }
  .chat-head h2 {
    font-size: 15px;
  }
  .chat-head .link {
    min-height: 44px;
    padding: 10px;
  }
  .chat-messages {
    min-height: 0;
    padding: 12px;
  }
  .chat-message {
    font-size: 13px;
    padding: 12px;
  }
  .chat-form {
    flex-shrink: 0;
    padding: 8px 12px;
  }
  .chat-form button {
    min-height: 48px;
  }
  .chat-form textarea {
    min-width: 0;
  }
  .chat-examples button {
    min-height: 40px;
  }
  .chat-examples {
    padding: 8px 12px;
  }
  .chat-disclaimer {
    font-size: 10px;
    padding: 0 12px 10px;
  }
}
@media (max-width: 350px) {
  .metrics {
    grid-template-columns: minmax(0, 1fr);
  }
  .login-card {
    padding: 24px;
  }
  .content {
    padding-inline: 12px;
  }
  .asset-stats > div {
    flex-basis: 110px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #sidebar {
    transition: none;
  }
}

@media (max-width: 900px) {
  #sidebar {
    padding-left: max(20px, env(safe-area-inset-left));
  }
  .content {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .login-body {
    padding: max(24px, env(safe-area-inset-top))
      max(24px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(24px, env(safe-area-inset-left));
  }
}
@media (max-width: 540px) {
  .chat-panel {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
  }
}

.analytics-table table {
  width: 100%;
  table-layout: fixed;
}
.analytics-table td,
.analytics-table th {
  white-space: normal;
  overflow-wrap: anywhere;
  padding: 12px 6px;
}
.analytics-table .link {
  text-align: left;
  white-space: normal;
}
@media (max-width: 540px) {
  .analytics-table td,
  .analytics-table th,
  .analytics-table .link {
    font-size: 11px;
  }
}

.confirmation-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  line-height: 1.6;
  cursor: pointer;
}
.confirmation-check input {
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 3px 0 0;
  flex-shrink: 0;
}

.pig-record {
  padding-block: 18px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.pig-record-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.pig-record p {
  white-space: pre-wrap;
}
.pig-record .sub {
  line-height: 1.7;
}

/* Shared palette across dashboard, login, forms, drawer and assistant. */
:root[data-theme="dark"] {
  --ink: #e6f0e9;
  --muted: #afc0b5;
  --green: #83d4ad;
  --line: #384a40;
  --bg: #101a15;
  --surface: #1b2a22;
  --soft: #2a4032;
  color-scheme: dark;
}
.theme-toggle {
  white-space: nowrap;
  min-height: 40px;
}
dialog {
  background: var(--surface);
  color: var(--ink);
}
:root[data-theme="dark"]
  :is(
    .breadcrumb b,
    .panel p,
    .metric-top,
    .metric small,
    label,
    th,
    td,
    .sub,
    .hint,
    .empty,
    .empty strong,
    .asset-stats small,
    .chat-message details,
    .chat-message strong,
    .chat-scope,
    .chat-disclaimer,
    .chat-head span,
    .chart-label,
    .chart-legend,
    .business-row p,
    .sidebar-bottom p,
    .nav-label,
    .login-error
  ) {
  color: var(--muted);
}
:root[data-theme="dark"]
  :is(
    .secondary,
    .link,
    .brand,
    nav button,
    .icon-button,
    .chat-examples button
  ) {
  color: var(--ink);
}
:root[data-theme="dark"]
  :is(
    nav button.active,
    nav button:hover,
    .pill,
    .metric-icon,
    .business-icon,
    .chat-message.user,
    .chat-examples button:hover,
    .avatar,
    .progress,
    #notice:not(:empty)
  ) {
  background: var(--soft);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"]
  :is(
    input,
    select,
    textarea,
    .chat-panel,
    .chat-message,
    .chat-examples button
  ) {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
:root[data-theme="dark"] :is(.primary, .chat-toggle) {
  background: #2c7652;
  color: #fff;
}
:root[data-theme="dark"] .metric.featured {
  background: #27573f;
  color: white;
}
:root[data-theme="dark"] .positive {
  color: #8cdeb2;
}
:root[data-theme="dark"] :is(.negative, #form-error, .login-error) {
  color: #ffab96;
}
:root[data-theme="dark"] :is(.alert, .pill.red) {
  background: #4a3026;
  color: #ffd4b4;
}
@media (max-width: 540px) {
  .theme-toggle {
    padding: 8px;
    font-size: 12px;
  }
}

/* A separate, distraction-free assistant view, not a floating dashboard tab. */
body.chat-open {
  overflow: hidden;
}
body.chat-open > :is(main, aside, .nav-backdrop, .chat-toggle) {
  visibility: hidden;
  pointer-events: none;
}
body.chat-open #chat-panel {
  position: fixed;
  inset: auto 0 auto 0;
  top: var(--chat-offset-top, 0px);
  bottom: auto;
  width: 100%;
  height: var(--chat-viewport-height, 100dvh);
  max-height: none;
  border: 0;
  border-radius: 0;
  z-index: 100;
  box-shadow: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg);
}
body.chat-open
  :is(.chat-messages, .chat-form, .chat-examples, .chat-disclaimer) {
  width: 100%;
  max-width: 820px;
  margin-inline: auto;
}
body.chat-open .chat-messages {
  padding: 24px 16px;
}
body.chat-open .chat-message {
  font-size: 14px;
}
body.chat-open .chat-head {
  min-height: 64px;
  flex-shrink: 0;
}
body.chat-open .chat-form {
  padding: 12px 16px;
  flex-shrink: 0;
}
body.chat-open .chat-disclaimer {
  padding-bottom: 12px;
}
.chat-examples:empty {
  display: none;
}
.chat-message details > div {
  white-space: pre-wrap;
}

:root[data-theme="dark"] .hint {
  background: var(--soft);
  color: var(--ink);
  border-color: var(--line);
}
