/* Shared visual rhythm. Layout and financial behavior live in the existing modules. */
:root {
  --ink: #203d34;
  --muted: #64796e;
  --line: #e2e9e2;
  --accent: #176853;
  --surface: #fff;
  --soft: #f0f5f0;
  --shadow: 0 4px 20px #24473806;
}
body {
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  transition:
    border-color 0.18s,
    background-color 0.18s,
    box-shadow 0.18s,
    color 0.18s,
    transform 0.18s;
}
button {
  touch-action: manipulation;
}
button:disabled {
  cursor: default;
}
button:not(:disabled):active {
  transform: scale(0.98);
}
input,
select,
textarea {
  border-color: #d8e2d9;
  border-radius: 11px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #659780;
  box-shadow: 0 0 0 3px #17685312;
}
input[type="checkbox"] {
  accent-color: var(--accent);
}
/* Safari gives date/month controls an intrinsic width and centers their value. */
input[type="date"],
input[type="month"] {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 46px;
  line-height: 1.45;
  text-align: left;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="month"]::-webkit-date-and-time-value {
  min-width: 0;
  min-height: 1.45em;
  text-align: left;
}
input[type="date"]::-webkit-datetime-edit,
input[type="month"]::-webkit-datetime-edit {
  min-width: 0;
  padding: 0;
}
@media (max-width: 760px) {
  input[type="date"],
  input[type="month"] {
    font-size: 16px;
  }
}
.formrow {
  align-items: flex-end;
}
.income-history-head label {
  min-width: 0;
}
#incomeList .income-entry {
  flex-direction: column;
  align-items: stretch;
}
#incomeList .income-entry > button {
  align-self: flex-start;
  min-height: 44px;
}
h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}
h2,
h3 {
  line-height: 1.35;
}
label {
  font-weight: 500;
  line-height: 1.45;
}
.primary,
.secondary {
  min-height: 46px;
  border-radius: 12px;
  line-height: 1.35;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary {
  box-shadow: 0 3px 8px #17685312;
}
.secondary {
  border-color: #d5e1d7;
}
.text {
  font-weight: 500;
}
.sectionhead {
  align-items: center;
  gap: 12px;
}
.sectionhead h2 {
  font-weight: 700;
  letter-spacing: -0.25px;
}
.accounts,
.group-card,
.invitation-card,
.profile-card {
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.stats strong,
.summary-grid strong,
.balance-hero strong,
.wallet-cards strong,
.billamount,
.upcoming-row > strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.65px;
}
.summary-grid {
  align-items: stretch;
}
.summary-grid article {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.summary-grid article > span {
  line-height: 1.4;
}
.summary-grid article > strong {
  margin: 0;
  line-height: 1.2;
}
.summary-grid article > small {
  margin-top: auto;
  line-height: 1.4;
}
.group-card .sectionhead {
  align-items: flex-start;
  flex-wrap: wrap;
}
.group-card h2 {
  margin: 0;
  flex: 1;
  min-width: 100px;
}
.group-tag {
  line-height: 1.4;
  font-weight: 600;
  flex-shrink: 0;
}
.group-members li {
  padding: 11px 0;
  margin: 0;
  border-bottom: 1px solid #edf1ec;
}
.group-members li:last-child {
  border: 0;
}
.group-members strong {
  line-height: 1.4;
}
.group-members small {
  line-height: 1.5;
}
.mini-avatar {
  font-weight: 700;
}
.menu-list button {
  min-height: 66px;
  font-weight: 500;
}
.menu-list button:last-child {
  border: 0;
}
.menu-list button > span:first-child {
  color: var(--accent);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--soft);
}
#mobileLogout {
  color: #a54c3f;
}
#mobileLogout > span:first-child {
  color: #a54c3f;
  background: #fbefeb;
}
.dialoghead {
  align-items: center;
}
.dialoghead h2 {
  letter-spacing: -0.4px;
  line-height: 1.3;
}
.dialoghead .text {
  flex-shrink: 0;
}
fieldset {
  border-radius: 15px;
  padding: 16px;
  background: #fff;
}
legend {
  font-weight: 600;
  padding: 0 7px;
}
.share-entry,
.plan-person {
  gap: 12px;
}
.share-entry > div,
.plan-person > div {
  min-width: 0;
}
.share-entry strong,
.plan-person strong {
  display: block;
  line-height: 1.5;
  font-size: 13px;
}
.share-entry label,
.plan-person label {
  font-size: 12px;
}
.share-entry input,
.plan-person input {
  font-variant-numeric: tabular-nums;
}
.share-entry .text,
.plan-person .text {
  padding-left: 0;
  color: #8b6656;
}
.plan-table tr {
  background: #fff;
}
.plan-table td {
  line-height: 1.5;
}
.plan-person {
  padding: 10px 0;
}
.income-entry {
  gap: 14px;
}
.income-entry > div {
  min-width: 0;
}
.income-entry strong {
  display: block;
  line-height: 1.5;
}
.income-entry p {
  margin: 6px 0;
  line-height: 1.5;
  color: var(--muted);
}
.income-entry small {
  color: var(--muted);
}
.income-entry .text {
  flex-shrink: 0;
  border: 1px solid #e4e9df;
  border-radius: 9px;
}
.wallet-cards article {
  display: flex;
  flex-direction: column;
}
.wallet-cards h3 {
  min-height: 22px;
}
.wallet-cards p {
  margin: 9px 0 5px;
}
.wallet-cards small {
  margin-top: auto;
}
.privacy-tag {
  color: var(--accent);
  background: #e9f1e7;
  border: 1px solid #dce8d9;
  padding: 7px 11px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
@media (hover: hover) {
  .secondary:hover,
  .upcoming-row:hover {
    background: #f0f5ef;
  }
  .menu-list button:hover {
    background: #f7faf5;
  }
}
@media (max-width: 760px) {
  body {
    background: #f5f7f3;
  }
  body > header {
    height: 60px;
    padding: 0 22px;
  }
  .brand {
    gap: 9px;
    font-size: 25px;
  }
  .brand > span {
    font-size: 18px;
    letter-spacing: -0.65px;
  }
  main {
    padding: 0 20px calc(104px + env(safe-area-inset-bottom));
    overflow-x: clip;
  }
  #appViews {
    min-width: 0;
  }
  .workspace-bar {
    margin: 0 0 24px;
    padding: 7px 0 0;
  }
  .workspace-bar label {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.4px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .workspace-bar select {
    font-size: 14px;
    border: 0;
    padding: 2px 22px 0 0;
    margin: 2px 0 0;
    min-height: 27px;
    border-radius: 4px;
    background-color: transparent;
    font-weight: 600;
    color: var(--ink);
  }
  .workspace-bar select:focus {
    box-shadow: none;
    outline: 2px solid #659780;
    outline-offset: 3px;
  }
  .page-heading {
    display: flex;
    min-height: 60px;
    margin: 5px 0 22px;
    gap: 12px;
    align-items: center;
  }
  .page-heading > div {
    min-width: 0;
  }
  .page-heading h1 {
    margin: 5px 0 0;
    font-size: 28px;
    line-height: 1.15;
    letter-spacing: -1px;
  }
  .page-heading .eyebrow {
    margin: 0;
    font-size: 9px;
    line-height: 1.5;
    letter-spacing: 1.2px;
    font-weight: 600;
    color: #728776;
  }
  #homeScreen .page-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: start;
  }
  #homeScreen .compact-label {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    font-size: 12px;
  }
  #homeScreen .compact-label input {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 44px;
    margin: 0;
    font-size: 16px;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
  }
  #homeMonth::-webkit-date-and-time-value {
    min-width: 0;
    text-align: left;
  }
  .compact-label {
    flex: 0 0 125px;
    margin: 0;
    font-size: 10px;
    color: var(--muted);
  }
  .compact-label input {
    width: 100%;
    padding: 10px 9px;
    min-height: 40px;
    font-size: 12px;
    border-radius: 11px;
    margin-top: 5px;
    font-weight: 500;
  }
  .app-screen {
    animation: none;
  }
  .balance-hero {
    position: relative;
    overflow: hidden;
    padding: 24px;
    margin-bottom: 18px;
    border-radius: 22px;
    background: linear-gradient(125deg, #184c3e, #176853 68%, #24775a);
    box-shadow: 0 9px 22px #17685316;
  }
  .balance-hero > span {
    font-size: 12px;
    opacity: 0.85;
  }
  .balance-hero > strong {
    margin: 12px 0 6px;
    font-size: clamp(29px, 8.6vw, 38px);
    line-height: 1.15;
    letter-spacing: -1.2px;
  }
  .balance-hero p {
    font-size: 11px;
    margin: 0;
    line-height: 1.5;
  }
  .balance-hero > div {
    margin-top: 24px;
    padding-top: 18px;
    font-size: 12px;
  }
  .balance-hero > div strong {
    font-size: 19px;
    line-height: 1.2;
  }
  .summary-grid {
    gap: 12px;
    margin: 0 0 26px;
  }
  .summary-grid article {
    padding: 17px 15px;
    border-radius: 16px;
    min-height: 112px;
  }
  .summary-grid article > span {
    min-height: 29px;
    display: flex;
    align-items: flex-start;
    font-size: 11px;
  }
  .summary-grid strong {
    font-size: clamp(19px, 5.6vw, 24px);
  }
  .summary-grid small {
    font-size: 10px;
  }
  #homeScreen > .sectionhead {
    margin-top: 4px;
  }
  #homeScreen > .sectionhead h2 {
    font-size: 17px;
  }
  #homeScreen > .sectionhead .text {
    padding-right: 0;
    white-space: nowrap;
    font-size: 11px;
  }
  #homeUpcoming {
    margin-top: 8px;
    padding: 0 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
  }
  .upcoming-row {
    padding: 16px 0;
    gap: 10px;
  }
  .upcoming-row:last-child {
    border: 0;
  }
  .upcoming-row strong {
    font-size: 13px;
  }
  .upcoming-row small {
    font-size: 10px;
    line-height: 1.5;
    margin-top: 5px;
  }
  .home-shortcuts {
    gap: 12px;
    margin-top: 18px;
  }
  .home-shortcuts .primary,
  .home-shortcuts .secondary {
    min-height: 48px;
    font-size: 12px;
  }
  .bottom-nav {
    padding: 8px 10px calc(9px + env(safe-area-inset-bottom));
    background: #ffffffed;
    border-color: #e0e8df;
    box-shadow: 0 -8px 30px #254c3a07;
  }
  .bottom-nav button {
    gap: 6px;
    min-height: 51px;
    padding: 2px 0;
    font-size: 10px;
    font-weight: 500;
    color: #7e8c82;
  }
  .bottom-nav button > span:first-child {
    min-width: 47px;
    height: 29px;
    padding: 3px 12px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    transition:
      background-color 0.22s,
      transform 0.22s,
      box-shadow 0.22s;
  }
  .bottom-nav svg {
    width: 23px;
    height: 23px;
  }
  .bottom-nav button[aria-current="page"] {
    color: #155a46;
    font-weight: 700;
  }
  .bottom-nav button[aria-current="page"] > span:first-child {
    margin: 0;
    padding: 3px 12px;
    background: #e4f0e4;
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 1px #dbe9d9;
  }
  .bottom-nav button:active {
    transform: none;
  }
  .bottom-nav button:active > span:first-child {
    transform: scale(0.91);
  }
  .notification-dot {
    width: 5px;
    height: 5px;
  }
  .toolbar {
    margin: -1px 0 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .toolbar .month {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
  }
  .toolbar .month h2 {
    margin: 0;
    min-width: 0;
    font-size: 16px;
  }
  .toolbar .month button {
    width: 32px;
    height: 32px;
    border-color: #e5ebe0;
    background: #f8faf5;
  }
  .toolbar .primary {
    min-height: 48px;
  }
  .stats {
    gap: 9px;
  }
  .stats article {
    padding: 15px 10px;
    border-radius: 14px;
  }
  .stats p {
    font-size: 10px;
    line-height: 1.4;
    min-height: 28px;
    margin: 0 0 8px;
  }
  .stats strong {
    font-size: clamp(15px, 4.8vw, 21px);
    line-height: 1.2;
  }
  .stats small {
    font-size: 10px;
    line-height: 1.5;
    margin-top: 9px;
  }
  .accounts[data-mobile-screen="bills"] {
    margin-top: 18px;
    padding: 19px 15px;
  }
  .accounts[data-mobile-screen="bills"] > .sectionhead {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .accounts[data-mobile-screen="bills"] .file-actions {
    max-width: none;
    margin-left: -8px;
  }
  .accounts .sectionhead h2 {
    font-size: 17px;
  }
  .file-actions .text {
    font-size: 11px;
    padding: 8px;
  }
  .filters {
    margin: 12px 0 17px;
    gap: 5px;
    background: #f1f5ef;
    border-radius: 11px;
    padding: 4px;
  }
  .filters button {
    flex: 1;
    padding: 9px 7px;
    font-size: 11px;
    border-radius: 8px;
  }
  .filters button.active {
    background: #fff;
    box-shadow: 0 1px 5px #24473810;
  }
  .check {
    font-size: 12px;
    line-height: 1.6;
    gap: 9px;
  }
  .bill {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 11px;
    padding: 19px 0;
    align-items: start;
  }
  .bill .toggle {
    margin-top: 1px;
  }
  .billinfo {
    min-width: 0;
  }
  .billinfo strong {
    font-size: 14px;
    line-height: 1.4;
  }
  .billinfo small {
    font-size: 11px;
    line-height: 1.7;
    margin-top: 6px;
  }
  .billamount {
    grid-column: 2;
    margin: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    text-align: left;
  }
  .billamount strong {
    font-size: 16px;
  }
  .billamount .status {
    margin: 0 0 0 auto;
    font-size: 10px;
    padding: 5px 8px;
  }
  .billamount small {
    flex-basis: 100%;
    font-size: 11px;
    margin: 0;
    letter-spacing: 0;
  }
  .billactions {
    grid-column: 2;
    padding-top: 7px;
    margin-top: 1px;
    gap: 3px;
    justify-content: flex-start;
  }
  .billactions .text {
    padding: 7px 10px;
    min-height: 34px;
    border-radius: 8px;
    background: #f4f7f0;
    font-size: 11px;
  }
  .personal-wallet {
    padding: 20px 16px;
    margin-top: 0;
  }
  .personal-wallet .sectionhead {
    display: grid;
    gap: 12px;
  }
  .personal-wallet .sectionhead .hint {
    line-height: 1.6;
    font-size: 11px !important;
    margin: 6px 0 0;
  }
  .wallet-cards {
    gap: 12px;
    margin: 18px 0 14px;
  }
  .wallet-cards article {
    padding: 18px;
    border-radius: 16px;
  }
  .wallet-cards h3 {
    font-size: 13px;
    margin-bottom: 10px;
  }
  .wallet-cards strong {
    font-size: 30px;
    line-height: 1.2;
  }
  .wallet-cards p,
  .wallet-cards small {
    font-size: 11px;
  }
  #openOutflows {
    min-height: 46px;
    font-size: 12px;
    margin: 3px 0 20px;
  }
  .income-history-head {
    padding-top: 15px;
    border-top: 1px solid var(--line);
    gap: 10px;
  }
  .income-history-head h3 {
    font-size: 16px;
    margin: 0;
  }
  .income-history-head label {
    font-size: 11px;
    margin: 0 0 8px;
  }
  .income-history-head input {
    margin-top: 5px;
  }
  .income-entry {
    padding: 16px 0;
    flex-wrap: wrap;
    gap: 10px;
  }
  .income-entry strong {
    font-size: 13px;
  }
  .income-entry p,
  .income-entry small {
    font-size: 11px;
  }
  .income-entry .text {
    min-height: 34px;
    font-size: 11px;
    padding: 7px 10px;
  }
  .group-card {
    padding: 19px 17px;
    border-radius: 18px;
    margin: 18px 0;
  }
  .group-card.selected {
    box-shadow:
      0 0 0 1px #1768530d,
      var(--shadow);
  }
  .group-card h2 {
    font-size: 17px;
  }
  .group-members {
    margin-top: 14px;
  }
  .group-members strong {
    font-size: 13px;
  }
  .group-members small {
    font-size: 11px;
    margin-top: 3px;
  }
  .mini-avatar {
    width: 35px;
    height: 35px;
    font-size: 12px;
  }
  .action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
  }
  .action-grid > * {
    min-width: 0;
    font-size: 12px;
    padding: 12px 9px;
    min-height: 47px;
  }
  #groupsScreen > .action-grid {
    margin-top: 0;
  }
  .profile-card {
    margin: 0 0 20px;
    padding: 20px 16px;
    gap: 13px;
  }
  .profile-card strong {
    font-size: 16px;
    line-height: 1.45;
  }
  .profile-card p {
    line-height: 1.5;
    margin: 5px 0 0;
    font-size: 11px;
  }
  .avatar {
    width: 48px;
    height: 48px;
    font-size: 16px;
  }
  .menu-list button {
    padding: 16px;
    font-size: 14px;
  }
  dialog .dialoghead {
    align-items: center;
    padding: 9px 0 13px;
    margin-bottom: 22px;
  }
  dialog .dialoghead h2 {
    margin: 4px 0;
    font-size: 20px;
  }
  dialog .dialoghead .text {
    min-height: 38px;
    font-size: 12px;
    padding: 8px 10px;
    border: 1px solid #e0e7dd;
    border-radius: 10px;
    background: #fff;
  }
  dialog label {
    font-size: 13px;
    margin: 19px 0;
  }
  dialog input,
  dialog select {
    padding: 13px 12px;
    min-height: 48px;
  }
  dialog .hint {
    line-height: 1.7;
  }
  dialog .formrow {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
  }
  dialog .formrow label {
    margin: 0 0 19px;
  }
  .share-entry,
  .plan-person {
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 12px;
  }
  .plan-table tr {
    padding: 12px;
    border-radius: 16px;
  }
  .plan-table td:before {
    font-size: 13px;
    color: var(--accent);
    margin: 3px 0 8px;
  }
  #planSummary {
    border-radius: 12px;
    font-size: 13px;
  }
  #outflowsTotals {
    margin-top: 20px;
  }
}
@media (max-width: 359px) {
  main {
    padding-left: 16px;
    padding-right: 16px;
  }
  .page-heading h1 {
    font-size: 25px;
  }
  .page-heading .eyebrow {
    font-size: 8px;
    letter-spacing: 0.85px;
  }
  .compact-label {
    flex-basis: 114px;
  }
  .summary-grid {
    gap: 10px;
  }
  .summary-grid article {
    padding: 16px 12px;
  }
  .balance-hero {
    padding: 21px;
  }
  .balance-hero > div {
    flex-wrap: wrap;
    gap: 7px;
  }
  .group-members small {
    font-size: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  button,
  input,
  select,
  textarea,
  .bottom-nav button > span:first-child {
    transition: none;
  }
  .app-screen {
    animation: none;
  }
}

@media (max-width: 760px) {
  .toolbar .month h2 {
    text-transform: none;
  }
  .toolbar .month h2::first-letter {
    text-transform: uppercase;
  }
  .bill {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .bill .toggle {
    width: 44px;
    height: 44px;
    min-height: 44px;
    font-size: 19px;
    border-radius: 12px;
    display: grid;
    place-items: center;
  }
  .stats article:first-child p {
    min-height: 0;
    font-size: 11px;
  }
  .stats article:first-child small {
    font-size: 10px;
  }
}

.mobile-only.page-heading {
  display: none;
}
@media (max-width: 760px) {
  .mobile-only.page-heading {
    display: flex;
  }
}
