:root {
  --green: #135947;
  --muted: #60766d;
  --line: #e0e8e3;
  --page: #f4f7f5;
}
body {
  background: var(--page);
  -webkit-tap-highlight-color: transparent;
}
button,
a {
  touch-action: manipulation;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #d0a640;
  outline-offset: 3px;
}
.icon {
  width: 23px;
  height: 23px;
  flex-shrink: 0;
  vertical-align: middle;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.05rem;
}
.brand img {
  width: 35px;
  height: 35px;
  border-radius: 11px;
}
.sidebar-label {
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0.65rem 1.4rem;
  color: var(--muted);
}
.sidebar nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
}
.sidebar nav button .icon {
  width: 19px;
  height: 19px;
}
.app-bar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.03rem;
}
.app-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}
.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  padding: 8px;
}
.avatar-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: #e3eee7;
  border: 1px solid #d5e3da;
}
.welcome h1 {
  font-size: 2rem;
  margin: 0.25rem 0;
}
.welcome > small {
  font-size: 0.9rem;
}
.welcome p {
  color: var(--muted);
  margin: 0.4rem 0 0;
  font-size: 0.95rem;
}
.balance-card {
  position: relative;
  background: #135947;
  color: white;
  border-radius: 23px;
  padding: 1.7rem 1.8rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.balance-card::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  border: 1px solid #ffffff13;
  border-radius: 50%;
  right: -60px;
  top: -110px;
  pointer-events: none;
}
.balance-label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #d7e9df;
  font-size: 0.9rem;
  position: relative;
  z-index: 1;
}
.balance-period {
  margin-left: auto;
  font-size: 0.78rem;
}
.balance-amount {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.08rem;
  line-height: 1.3;
  margin: 1.15rem 0 1.4rem;
}
.balance-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #ffffff20;
  padding-top: 1rem;
  font-size: 0.82rem;
  color: #cee3d7;
}
.balance-link {
  border: 0;
  background: #ffffff14;
  color: white;
  font-size: 0.8rem;
  padding: 0.45rem 0.7rem;
  border-radius: 20px;
}
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 0 0 1.7rem;
}
.quick-actions > button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  border: 0;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem;
}
.quick-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid #dce8e0;
  border-radius: 18px;
  background: #fff;
  color: #1e6650;
  box-shadow: 0 4px 10px #213c3005;
}
.quick-actions > button:nth-child(2) .quick-icon {
  background: #ecf0fc;
  color: #5366a4;
  border-color: #e3e9f8;
}
.quick-actions > button:nth-child(3) .quick-icon {
  background: #fff1dd;
  color: #a07738;
  border-color: #f7e8ce;
}
.quick-actions > button:nth-child(4) .quick-icon {
  background: #eaf4ee;
  color: #39785a;
}
.quick-icon .icon {
  width: 26px;
  height: 26px;
}
.stats-cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stats-cards .card {
  border-radius: 16px;
  padding: 1.2rem;
}
.stats-cards .value {
  font-size: 1.35rem;
}
.bottom-nav {
  display: none;
}
.profile-card {
  padding: 1.3rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 2rem;
}
.profile-avatar {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: #e2eee5;
  font-size: 1.4rem;
  color: #185941;
}
.profile-card strong {
  font-size: 1.05rem;
}
.profile-card small {
  display: block;
  font-size: 0.82rem;
  margin: 0.2rem 0;
  overflow-wrap: anywhere;
}
.role-label {
  display: inline-block;
  font-size: 0.72rem;
  background: #eff4f0;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  color: #58705f;
  text-transform: capitalize;
}
.menu-section {
  max-width: 780px;
  margin-bottom: 1.8rem;
}
.menu-section h2 {
  font-size: 1rem;
  color: #5e7367;
  margin-bottom: 0.8rem;
}
.service-menu {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.service-menu button {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #edf1ee;
  border-radius: 0;
  padding: 1rem 1.1rem;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 500;
  min-height: 58px;
}
.service-menu button:last-child {
  border-bottom: 0;
}
.service-menu button span {
  flex: 1;
}
.service-menu button .icon:last-child {
  width: 17px;
  color: #94a79b;
}
.app-version {
  font-size: 0.8rem;
  color: #819488;
  text-align: center;
}
.login {
  border: 0;
  box-shadow: 0 15px 60px #183d2b08;
  border-radius: 25px;
  padding: 2rem;
}
.login .brand {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 2.5rem;
}
.login .brand .login-logo {
  width: 68px;
  height: 68px;
  border-radius: 22px;
  margin-bottom: 0.6rem;
}
.login .brand span {
  font-size: 0.65rem;
  letter-spacing: 0.12rem;
}
.login .install-login {
  background: transparent;
  border: 0;
  color: #60766d;
  font-size: 0.85rem;
  font-weight: 500;
}
.login .demo-entry {
  text-align: center;
  width: 100%;
  margin-top: 1rem;
  min-height: 44px;
}
.login .notice {
  font-size: 0.85rem;
}
.connection-banner {
  background: #fff1d7;
  color: #805a21;
  text-align: center;
  padding: 9px 16px;
  font-size: 0.83rem;
  line-height: 1.5;
}
.pwa-update {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  background: #173d30;
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 28px #0e2c332b;
  font-size: 0.85rem;
}
.pwa-update button {
  font-size: 0.8rem;
  background: #d7eedc;
  border: 0;
  padding: 0.5rem 0.7rem;
  white-space: nowrap;
}
.pwa-update[hidden],
.connection-banner[hidden] {
  display: none;
}
.offline-content {
  max-width: 450px;
  margin: 15vh auto;
  padding: 2rem;
}
.offline-content img {
  width: 70px;
  border-radius: 20px;
}
.offline-content h1 {
  font-size: 1.8rem;
}
.dialog-head {
  border-bottom: 1px solid #e8eee9;
  padding-bottom: 1.1rem;
  position: sticky;
  top: 0;
  background: white;
  z-index: 3;
}
.dialog-head h2 {
  line-height: 1.35;
}
.dialog-head button {
  min-height: 44px;
}
.record-action button {
  min-height: 42px;
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  font-size: 16px;
}
#edit-form > .actions {
  background: white;
  padding-top: 1rem;
}
.login button {
  min-height: 48px;
}
.graph .group {
  border-bottom: 1px solid #e1e9e3;
}
#toast {
  box-shadow: 0 5px 24px #152c2224;
}
.card,
.article {
  box-shadow: 0 2px 3px #183b2602;
}
.pagehead > .actions:empty {
  display: none;
}
@media (min-width: 769px) {
  .balance-card {
    max-width: 900px;
  }
  .quick-actions {
    max-width: 680px;
  }
  .welcome h1 {
    font-size: 2rem;
  }
  .content {
    padding-top: 1.75rem;
  }
  .topbar {
    min-height: 77px;
  }
  .stats-cards {
    max-width: 100%;
  }
  .app-bar-title .icon-button {
    display: none;
  }
}
@media (max-width: 768px) {
  .shell {
    display: block;
  }
  .sidebar {
    display: none;
  }
  .workspace {
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    min-height: 100dvh;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    border-bottom: 0;
    background: rgba(244, 247, 245, 0.97);
    padding: calc(9px + env(safe-area-inset-top, 0px)) 17px 9px;
    min-height: 63px;
    backdrop-filter: blur(14px);
  }
  .topbar .actions {
    gap: 5px;
  }
  .app-bar-title {
    font-size: 1rem;
    gap: 9px;
    min-width: 0;
  }
  .app-bar-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .app-logo {
    width: 29px;
    height: 29px;
  }
  .avatar-button {
    width: 38px;
    height: 38px;
  }
  .icon-button {
    min-width: 44px;
    min-height: 44px;
  }
  .content {
    padding: 1.25rem 18px 2rem;
    max-width: 600px;
  }
  .pagehead {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    margin-bottom: 1.35rem;
    gap: 10px;
  }
  .pagehead h1 {
    font-size: 1.55rem;
    letter-spacing: -0.05rem;
  }
  .pagehead .muted {
    font-size: 0.85rem;
    line-height: 1.6;
    max-width: 280px;
  }
  .pagehead .actions {
    gap: 7px;
    justify-content: flex-end;
  }
  .page-action {
    font-size: 0.85rem;
    min-height: 44px;
    padding: 0.65rem 0.9rem;
    white-space: nowrap;
  }
  .export-button {
    font-size: 0.75rem;
    min-height: 44px;
    padding: 0.5rem 0.7rem;
  }
  .welcome h1 {
    font-size: 1.8rem;
    font-weight: 750;
  }
  .welcome p {
    font-size: 0.82rem;
  }
  .welcome > small {
    font-size: 0.78rem;
  }
  .balance-card {
    border-radius: 22px;
    padding: 1.3rem 1.35rem;
    margin-bottom: 1.15rem;
    box-shadow: 0 8px 20px #1d5b3c14;
  }
  .balance-label {
    font-size: 0.8rem;
    gap: 7px;
  }
  .balance-label .icon {
    width: 18px;
    height: 18px;
  }
  .balance-period {
    font-size: 0.7rem;
  }
  .balance-amount {
    font-size: 2.05rem;
    margin: 1.2rem 0 1.1rem;
  }
  .balance-foot {
    font-size: 0.73rem;
    padding-top: 0.8rem;
  }
  .balance-link {
    font-size: 0.72rem;
    min-height: 36px;
  }
  .quick-actions {
    gap: 2px;
    margin: 0 -0.3rem 1.5rem;
  }
  .quick-actions > button {
    font-size: 0.75rem;
    line-height: 1.35;
    font-weight: 500;
    padding: 0.45rem 0.1rem;
    gap: 0.6rem;
    color: #3f5a4e;
  }
  .quick-icon {
    width: 51px;
    height: 51px;
    border-radius: 17px;
  }
  .quick-icon .icon {
    width: 24px;
    height: 24px;
  }
  .stats-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.3rem;
  }
  .stats-cards .stat-card:first-child {
    grid-column: 1/-1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.1rem;
    background: #edf2ee;
    border-color: #e3eae4;
  }
  .stats-cards .stat-card:first-child .value {
    font-size: 1.2rem;
    margin: 0;
  }
  .stats-cards .stat-card {
    padding: 1rem 1.1rem;
  }
  .stats-cards .stat-card small {
    font-size: 0.75rem;
  }
  .stats-cards .value {
    font-size: 1.5rem;
    margin: 0.55rem 0 0;
  }
  .twocol {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .card {
    padding: 1.2rem;
    border-radius: 18px;
  }
  .card h2 {
    font-size: 1rem;
    margin-bottom: 1rem;
  }
  .card .row {
    font-size: 0.87rem;
    padding: 0.9rem 0;
  }
  .card .row small {
    font-size: 0.75rem;
  }
  .card .row strong {
    line-height: 1.45;
  }
  .card .row button {
    min-height: 40px;
  }
  .row .icon {
    width: 20px;
  }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #e3eae5;
    z-index: 30;
    box-shadow: 0 -4px 24px #143a2305;
  }
  .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: #7e9287;
    font-size: 0.66rem;
    font-weight: 500;
    border-radius: 13px;
    padding: 7px 2px;
    min-height: 53px;
    letter-spacing: 0.005rem;
  }
  .bottom-nav .icon {
    width: 23px;
    height: 23px;
  }
  .bottom-nav button.active {
    background: #eaf3ec;
    color: #165b43;
    font-weight: 700;
  }
  .table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    white-space: normal;
    width: 100%;
  }
  .table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: white;
    margin-bottom: 0.8rem;
    padding: 1rem 1.1rem;
    box-shadow: 0 2px 5px #0e2d1c03;
  }
  .table-wrap td {
    padding: 0.35rem 0 !important;
    display: grid;
    grid-template-columns: minmax(95px, 0.8fr) minmax(0, 1.2fr);
    gap: 12px;
    border: 0;
    align-items: start;
    font-size: 0.85rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }
  .table-wrap td:before {
    content: attr(data-label);
    color: #7c8f82;
    font-size: 0.77rem;
  }
  .table-wrap td.record-title {
    display: block;
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.015rem;
    padding: 0.05rem 0 0.7rem !important;
    color: #244c38;
  }
  .table-wrap td.record-title:before,
  .table-wrap td.record-action:before {
    display: none;
  }
  .table-wrap td.record-action {
    display: flex;
    justify-content: flex-end;
    padding: 0.7rem 0 0 !important;
  }
  .table-wrap td.record-action:empty {
    display: none;
  }
  .table-wrap .record-action button {
    min-width: 85px;
    min-height: 40px;
    border-color: #dce8df;
    border-radius: 11px;
    background: #f4f8f5;
    font-size: 0.8rem;
  }
  .table-wrap .badge {
    width: fit-content;
  }
  .table-wrap td .sub {
    margin: 0;
    font-size: 0.78rem;
  }
  .toolbar {
    gap: 0.65rem;
    align-items: stretch;
    flex-direction: column;
  }
  .toolbar input {
    max-width: 100%;
    border: 1px solid #dce6df;
    border-radius: 14px;
    background: #fff;
    min-height: 48px;
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
  }
  .toolbar small {
    font-size: 0.75rem;
  }
  .toolbar > .muted {
    font-size: 0.83rem;
  }
  .toolbar > .primary {
    min-height: 48px;
  }
  .service-menu button {
    padding: 0.95rem 1rem;
    font-size: 0.9rem;
  }
  .menu-section h2 {
    font-size: 0.85rem;
  }
  .profile-card {
    margin-top: 0.3rem;
    margin-bottom: 1.5rem;
  }
  .article {
    padding: 1.25rem;
    border-radius: 18px;
    margin-bottom: 0.8rem;
  }
  .article p {
    font-size: 0.9rem;
  }
  .article small {
    font-size: 0.75rem;
  }
  .article h2 {
    font-size: 1.1rem;
    margin: 0.75rem 0;
  }
  .badge {
    font-size: 0.7rem;
  }
  .detail-grid {
    grid-template-columns: 105px minmax(0, 1fr);
    font-size: 0.9rem;
  }
  dialog {
    margin: auto 0 0;
    max-width: none;
    width: 100%;
    max-height: calc(100dvh - 36px - env(safe-area-inset-top, 0px));
    border-radius: 25px 25px 0 0;
    padding: 0;
    overscroll-behavior: contain;
  }
  dialog::backdrop {
    background: #10291e75;
    backdrop-filter: blur(3px);
  }
  #dialog-body {
    padding: 1.3rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }
  #dialog-body:before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 5px;
    background: #d8e1db;
    margin: -0.5rem auto 1rem;
  }
  .dialog-head {
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
  }
  .dialog-head h2 {
    font-size: 1.12rem;
    max-width: 78%;
  }
  .dialog-head button {
    font-size: 0.8rem;
    border: 0;
    background: #f1f5f2;
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .field {
    margin-bottom: 1.15rem;
  }
  .field label,
  .choices legend {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
  }
  .field input,
  .field select,
  .field textarea {
    min-height: 48px;
    border-color: #d4e0d7;
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
    background: #fafcfb;
  }
  .choices label {
    padding: 0.7rem 0.85rem;
    font-size: 0.85rem;
    border-radius: 11px;
    min-height: 44px;
  }
  .choices input {
    min-height: 0;
  }
  .choices > div {
    gap: 0.5rem;
  }
  #edit-form > .actions {
    position: sticky;
    bottom: calc(-1.25rem - env(safe-area-inset-bottom, 0px));
    margin: 1rem -1.25rem calc(-1.25rem - env(safe-area-inset-bottom, 0px));
    padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e8eee9;
    display: flex;
    gap: 0.75rem;
    z-index: 2;
  }
  #edit-form > .actions button {
    min-height: 49px;
    font-size: 0.9rem;
    border-radius: 12px;
  }
  #edit-form > .actions > .primary {
    flex: 1;
    order: 2;
  }
  #edit-form > .actions > [data-action="close"] {
    order: 1;
  }
  .settings-layout #edit-form > .actions {
    position: static;
    margin: 0;
    padding: 1rem 0 0;
  }
  .notice {
    font-size: 0.82rem;
  }
  .login {
    margin: 0 auto;
    min-height: 100dvh;
    max-width: 480px;
    border-radius: 0;
    padding: calc(3rem + env(safe-area-inset-top, 0px)) 26px
      calc(2rem + env(safe-area-inset-bottom, 0px));
    box-shadow: none;
    background: var(--page);
  }
  .login .brand {
    font-size: 1.5rem;
    margin-bottom: 2.5rem;
  }
  .login h1 {
    font-size: 1.8rem;
  }
  .login input {
    background: white;
    min-height: 52px;
    border-radius: 13px;
  }
  .login label {
    font-size: 0.85rem;
  }
  .login button,
  .login .button {
    min-height: 50px;
    border-radius: 13px;
    font-size: 0.9rem;
  }
  .login .install-login {
    margin-top: 0.4rem;
  }
  .login .muted {
    font-size: 0.95rem;
  }
  .login .muted-caption {
    font-size: 0.8rem;
  }
  .pwa-update {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    font-size: 0.78rem;
  }
  #toast {
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    font-size: 0.85rem;
    width: max-content;
    max-width: calc(100% - 32px);
    line-height: 1.5;
    border-radius: 14px;
  }
  .demo-banner {
    padding: 0.35rem 0.75rem;
    font-size: 0.7rem;
    gap: 0.5rem;
  }
  .demo-banner button,
  .demo-banner select {
    font-size: 0.7rem;
  }
  .graph {
    height: 145px;
  }
  .offline-content {
    margin: 8vh auto;
  }
  .empty {
    font-size: 0.9rem;
    background: #fff;
    border: 1px dashed #d8e3db;
    border-radius: 16px;
    padding: 2rem 1rem;
  }
  .pagehead .actions {
    flex-shrink: 0;
    flex-direction: column;
  }
  .app-version {
    font-size: 0.74rem;
  }
}
@media (prefers-reduced-motion: no-preference) {
  dialog[open] {
    animation: sheet-in 0.2s ease-out;
  }
  @keyframes sheet-in {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}
@media (max-width: 360px) {
  .content {
    padding-left: 13px;
    padding-right: 13px;
  }
  .balance-amount {
    font-size: 1.85rem;
  }
  .balance-period {
    font-size: 0.65rem;
  }
  .quick-actions > button {
    font-size: 0.7rem;
  }
  .pagehead h1 {
    font-size: 1.4rem;
  }
  .bottom-nav button {
    font-size: 0.63rem;
  }
}

.sidebar .brand {
  font-size: 20px;
  white-space: nowrap;
}
