@charset "UTF-8";
:root {
  --ink: #183330;
  --muted: #75827f;
  --green: #137d68;
  --dark: #122e2c;
  --mint: #e6f5ee;
  --line: #e5ebe7;
  --bg: #f5f7f6;
  --orange: #e5814d;
  --red: #c84c50;
  --radius: 18px;
  font-family: Tahoma, "Leelawadee UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
  background: var(--bg);
}
*, *::before, *::after {
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, select {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button, select {
  cursor: pointer;
}
button {
  border: 0;
  background: none;
  color: inherit;
  line-height: 1.5;
}
button:disabled {
  opacity: .5;
  cursor: wait;
}
button:focus-visible, a:focus-visible {
  outline: 3px solid #5aafec;
  outline-offset: 3px;
}
input, select {
  max-width: 100%;
  border: 1px solid #d5dfda;
  background: white;
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 12px;
  min-height: 44px;
  font-size: 1rem;
}
input:focus, select:focus {
  outline: 2px solid #259f83;
  outline-offset: 1px;
}
label {
  display: grid;
  gap: 6px;
  font-size: .875rem;
}
a {
  color: inherit;
  text-decoration: none;
}
h1, h2, h3, p {
  margin: 0;
}
h1 {
  font-size: 1.85rem;
  letter-spacing: -.04em;
  line-height: 1.4;
}
h2 {
  font-size: 1.12rem;
  line-height: 1.5;
}
h3 {
  font-size: 1rem;
}
p {
  line-height: 1.7;
}
small, .muted {
  color: var(--muted);
}
[hidden], [hidden] * {
  display: none !important;
}
body.is-logged-in #login-view,
#login-view[hidden] {
  display: none !important;
}
body:not(.is-logged-in) #app,
body:not(.is-logged-in) .sidebar,
body:not(.is-logged-in) .sidebar nav,
body.is-guest #app,
body.is-guest .sidebar,
body.is-guest .sidebar nav,
#app[hidden],
#app[hidden] * {
  display: none !important;
}
.eyebrow {
  display: block;
  font-size: .75rem;
  font-weight: bold;
  letter-spacing: .16em;
  color: var(--green);
  margin-bottom: 8px;
}
.primary, .secondary, .danger {
  padding: 11px 18px;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: bold;
  min-height: 44px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.primary {
  background: var(--green);
  color: white;
  box-shadow: 0 4px 10px rgba(19, 125, 104, 0.15);
}
.primary:hover {
  background: #096653;
}
.secondary {
  background: #eff3f0;
}
.secondary:hover {
  background: #e2eae5;
}
.danger {
  background: var(--red);
  color: white;
}
.full {
  width: 100%;
  justify-content: space-between;
}
.icon-btn {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
}
.icon-btn:hover {
  background: var(--bg);
}

/* Sidebar Desktop */
.sidebar {
  width: 238px;
  background: var(--dark);
  color: #c3d4cf;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  padding: 35px 22px;
  z-index: 10;
}
.brand {
  font-size: 1.25rem;
  font-weight: bold;
  color: white;
  display: flex;
  gap: 10px;
  align-items: center;
}
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  border: 2px solid #ff7a18;
  flex: none;
}
.brand-logo-small {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  border: 2px solid #ff7a18;
  flex: none;
}
.sidebar-caption {
  font-size: .75rem;
  color: #9cb5ae;
  margin: 28px 12px 14px;
}
.sidebar nav {
  display: grid;
  gap: 6px;
}
.sidebar nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  text-align: left;
  font-size: .875rem;
  border-radius: 10px;
  color: #c3d4cf;
}
.sidebar nav button span {
  font-size: 1.2rem;
  width: 22px;
  text-align: center;
}
.sidebar nav button:hover {
  background: rgba(255,255,255,0.06);
}
.sidebar nav button.active {
  background: #235047;
  color: #c7f1db;
  font-weight: bold;
}
.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.12);
  padding: 20px 10px 0;
}
.shared-label {
  font-size: .875rem;
  color: #e5f2ec;
}
.avatars {
  display: flex;
  margin: 12px 0 8px;
}
.avatar {
  width: 33px;
  height: 33px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #d8e8df;
  color: #244739;
  font-weight: bold;
  font-size: .875rem;
  border: 2px solid var(--dark);
  margin-left: -4px;
}
.avatar:nth-child(2) { background: #f0d9bf; }
.avatar:nth-child(3) { background: #d8dcf0; }
.avatar:nth-child(4) { background: #ecced7; }
.sidebar-bottom p {
  font-size: .75rem;
  color: #9cb5ae;
}
.logout {
  font-size: .875rem;
  margin-top: 18px;
  padding: 0;
  color: #b7cec5;
}

/* Main Content & Topbar Desktop */
.main {
  margin-left: 238px;
}
.topbar {
  height: 80px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 38px;
  background: #fff;
  font-size: .875rem;
}
.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.topbar-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #ff7a18;
  vertical-align: middle;
}
.slash {
  color: #bac5bf;
  margin: 0 10px;
}
.top-right {
  display: flex;
  gap: 16px;
  align-items: center;
}
.sync {
  font-size: .75rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}
.sync::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #23a784;
  border-radius: 50%;
  margin-right: 6px;
}
.sync.offline {
  color: var(--red);
}
.sync.offline::before {
  background: var(--red);
}
.user-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  padding: 5px 12px !important;
  border-radius: 20px !important;
  background: #e6f5ee !important;
  color: #137d68 !important;
  font-weight: bold !important;
  font-size: .8125rem !important;
  border: 1px solid #c1e7d6 !important;
  white-space: nowrap !important;
  flex: 0 0 auto !important;
  cursor: pointer;
}
.user-pill::before {
  content: "👤 ";
  font-size: .85rem;
}

/* Topbar & Sidebar Buttons */
.btn-topbar-install, .btn-topbar-scan {
  padding: 7px 14px;
  border-radius: 20px;
  font-size: .8125rem;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .2s;
  white-space: nowrap;
}
.btn-topbar-install {
  background: #fff0e6;
  color: #d45b1d;
  border: 1px solid #ffd4bd;
}
.btn-topbar-install:hover {
  background: #ffe3d1;
}
.btn-topbar-scan {
  background: #e6f8f4;
  color: #0f7762;
  border: 1px solid #b3ebe0;
}
.btn-topbar-scan:hover {
  background: #d2f4ec;
}
.btn-sidebar-install, .btn-sidebar-scan {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  text-align: left;
  font-size: .875rem;
  border-radius: 10px;
  margin-top: 4px;
}
.btn-sidebar-install {
  background: #3a291f !important;
  color: #ffb885 !important;
  border: 1px solid rgba(255, 152, 102, 0.25);
}
.btn-sidebar-scan {
  background: #183e37 !important;
  color: #7fe6d3 !important;
  border: 1px solid rgba(32, 184, 160, 0.25);
}

/* Auto-Hide Install Buttons When App is Installed */
.app-installed [data-install-trigger],
.app-installed [data-install-help],
.app-installed .btn-topbar-install,
.app-installed .btn-sidebar-install,
.app-installed .install-help,
.app-installed #native-install-btn {
  display: none !important;
}

/* Workspace Desktop */
.workspace {
  padding: 30px 38px 24px;
  max-width: 1640px;
  margin: auto;
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.page-heading p {
  font-size: .875rem;
  margin-top: 4px;
}
.heading-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.period {
  display: flex;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1px 7px;
  align-items: center;
}
.period select {
  border: 0;
  background: transparent;
  padding: 9px 4px;
  font-size: .875rem;
}
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 0;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  padding: 20px 22px;
  position: relative;
}
.stat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: .875rem;
}
.stat-icon {
  width: 31px;
  height: 31px;
  background: var(--mint);
  color: var(--green);
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}
.stat.expense .stat-icon {
  background: #fff0e8;
  color: var(--orange);
}
.stat-value {
  font-size: 1.65rem;
  letter-spacing: -.03em;
  font-weight: bold;
  margin: 14px 0 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value span {
  font-size: 1rem;
  font-weight: normal;
  margin-right: 4px;
}
.stat p {
  font-size: .75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat.balance {
  background: var(--dark);
  border-color: var(--dark);
  color: #fff;
}
.balance .stat-head, .balance p {
  color: #bdd3c9;
}
.balance .stat-icon {
  background: #31554a;
  color: #b2e9cf;
}
.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr);
  gap: 22px;
  margin-bottom: 22px;
}
.card-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.card-heading p {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 3px;
}
.text-btn {
  color: var(--green);
  font-size: .875rem;
  padding: 4px 0;
  white-space: nowrap;
}
.chart-wrap {
  position: relative;
  height: 238px;
  width: 100%;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.legend {
  display: flex;
  gap: 18px;
  font-size: .75rem;
  color: var(--muted);
  align-items: center;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  background: var(--green);
  margin-right: 6px;
  flex: none;
}
.dot.expense {
  background: #ef9b71;
}
.donut-layout {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
}
.donut {
  position: relative;
  width: 176px;
  height: 176px;
  flex-shrink: 0;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-center strong {
  font-size: 1.18rem;
  font-variant-numeric: tabular-nums;
}
.donut-center small {
  font-size: .75rem;
}
.category-legend {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 10px;
}
.category-legend li {
  list-style: none;
  font-size: .75rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.category-legend ul {
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.category-name {
  display: flex;
  align-items: center;
  min-width: 0;
}
.category-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.category-legend strong {
  white-space: nowrap;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: .875rem;
}
th {
  text-align: left;
  font-weight: normal;
  color: var(--muted);
  font-size: .75rem;
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  background: #f8faf9;
  white-space: nowrap;
}
td {
  padding: 14px 10px;
  border-bottom: 1px solid #eff2ef;
}
tr:last-child td {
  border-bottom: 0;
}
.amount {
  font-variant-numeric: tabular-nums;
  font-weight: bold;
  text-align: right;
  white-space: nowrap;
}
.positive {
  color: var(--green);
}
.negative {
  color: #cb704a;
}
.saving-color {
  color: #7b63bc;
}
.badge {
  font-size: .75rem;
  border-radius: 6px;
  padding: 4px 8px;
  background: #f0f4f1;
  display: inline-block;
  white-space: nowrap;
}
.badge.orange {
  background: #fff0e7;
  color: #ae663f;
}
.badge.green {
  background: var(--mint);
  color: var(--green);
}
.badge.purple {
  background: #f0ebfa;
  color: #7b63bc;
}
.row-description {
  max-width: 250px;
  overflow-wrap: anywhere;
}
.row-description small {
  font-size: .75rem;
  display: block;
}
.row-actions {
  white-space: nowrap;
  text-align: right;
}
.row-actions button {
  font-size: .75rem;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
}
.row-actions button:hover {
  background: var(--bg);
  color: var(--green);
}
.row-actions button.delete {
  color: var(--red);
}
.budget-list {
  display: grid;
  gap: 20px;
}
.budget-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: .875rem;
  margin-bottom: 8px;
}
.budget-row-head small {
  font-size: .75rem;
}
.progress {
  height: 7px;
  background: #eef3ef;
  border-radius: 8px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 8px;
}
.progress.over > span {
  background: var(--red);
}
.progress.warning > span {
  background: #e8ac4e;
}
.budget-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: .75rem;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.goal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.goal-card h2 {
  overflow-wrap: anywhere;
}
.goal-symbol {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--mint);
  font-size: 1.65rem;
  border-radius: 14px;
  margin-bottom: 16px;
}
.goal-card .stat-value {
  font-size: 1.5rem;
  margin-top: 18px;
}
.goal-card .goal-target {
  font-size: .875rem;
  color: var(--muted);
  margin-bottom: 16px;
}
.goal-card .goal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.goal-card .secondary {
  font-size: .75rem;
  padding: 8px 12px;
}
.goal-meta {
  margin-top: 13px;
  display: grid;
  gap: 5px;
  font-size: .75rem;
  color: var(--muted);
}
.note {
  padding: 12px 16px;
  border-radius: 10px;
  background: #eaf1ee;
  color: #46635a;
  font-size: .875rem;
  margin-bottom: 20px;
}
.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.kanban-column {
  background: #edf1ee;
  border: 1px solid #e4eae5;
  border-radius: 14px;
  padding: 15px;
  min-height: 260px;
}
.kanban-column.drag-over {
  outline: 2px dashed var(--green);
}
.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .875rem;
  margin: 2px 2px 16px;
}
.column-count {
  background: white;
  border-radius: 7px;
  padding: 1px 8px;
  font-size: .75rem;
}
.task {
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 12px;
  cursor: grab;
  box-shadow: 0 2px 4px rgba(24, 51, 48, 0.04);
}
.task:active {
  cursor: grabbing;
}
.task h3 {
  overflow-wrap: anywhere;
}
.task-amount {
  font-size: 1.1rem;
  margin: 10px 0;
}
.task-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .75rem;
  gap: 8px;
}
.task select {
  margin-top: 12px;
  width: 100%;
  font-size: .75rem;
  min-height: 38px;
  padding: 7px;
}
.task .row-actions {
  margin-top: 6px;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 35px 18px;
  font-size: .875rem;
}
.empty-symbol {
  font-size: 2rem;
  display: block;
  color: #a0b8ab;
  margin-bottom: 8px;
}
.empty p {
  margin-bottom: 15px;
}
.budget-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.budget-card .progress {
  height: 10px;
  margin: 18px 0 5px;
}
.budget-card .budget-totals {
  display: flex;
  justify-content: space-between;
  margin: 14px 0;
  gap: 10px;
}
.budget-totals strong {
  display: block;
  font-size: 1.25rem;
}
.budget-totals small {
  font-size: .75rem;
  color: var(--muted);
}
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar select {
  font-size: .875rem;
}
.users-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.member-card {
  display: flex;
  align-items: center;
  gap: 16px;
}
.member-card .avatar {
  width: 48px;
  height: 48px;
  border: none;
  background: #e5f1ea;
  font-size: 1.2rem;
  flex: none;
}
.member-card p {
  font-size: .875rem;
  color: var(--muted);
}
.member-card button {
  margin-left: auto;
}

/* Footer & Logo Guaranteed Fixed Size */
footer, .app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding: 16px 0 20px;
  font-size: .75rem;
  color: #88968f;
  gap: 16px;
  border-top: 1px solid var(--line);
}
.footer-brand {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
}
.footer-logo {
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  max-width: 24px !important;
  max-height: 24px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  flex: 0 0 24px !important;
  border: 1.5px solid #ff7a18 !important;
  display: inline-block !important;
}
footer img, .app-footer img {
  width: 24px !important;
  height: 24px !important;
  max-width: 24px !important;
  max-height: 24px !important;
  flex: 0 0 24px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
}


/* Modals & Dialogs Desktop */
dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  max-width: 550px;
  width: calc(100% - 32px);
  max-height: 90vh;
  overflow: auto;
  color: var(--ink);
  box-shadow: 0 25px 100px rgba(18, 46, 44, 0.2);
}
dialog::backdrop {
  background: rgba(16, 47, 41, 0.4);
  backdrop-filter: blur(3px);
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.dialog-heading h2 {
  font-size: 1.25rem;
}
#modal-fields {
  display: grid;
  gap: 16px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.error {
  color: var(--red);
  font-size: .875rem;
  margin: 12px 0;
  overflow-wrap: anywhere;
}
.error:empty {
  display: none;
}
.toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 22px;
  background: var(--dark);
  color: white;
  border-radius: 12px;
  z-index: 200;
  font-size: .875rem;
  box-shadow: 0 10px 30px rgba(16, 47, 41, 0.25);
  max-width: calc(100% - 30px);
  text-align: center;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Login View Desktop */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: white;
}
.login-art {
  background: var(--dark);
  color: white;
  padding: 48px 12%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
}
.login-art .brand {
  font-size: 1.2rem;
}
.login-art .eyebrow {
  color: #9bd8ba;
}
.login-art h1 {
  font-size: 2.7rem;
  margin: 20px 0;
}
.login-art p {
  color: #b5cdc3;
  font-size: 1rem;
}
.login-art small {
  color: #b5cdc3;
}
.art-graph {
  height: 120px;
  display: flex;
  align-items: flex-end;
  gap: 13px;
  margin-top: 42px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.art-graph i {
  display: block;
  flex: 1;
  background: #73c7a3;
  border-radius: 6px 6px 0 0;
  height: 25%;
}
.art-graph i:nth-child(2) { height: 44%; opacity: .5; }
.art-graph i:nth-child(3) { height: 37%; }
.art-graph i:nth-child(4) { height: 65%; opacity: .5; }
.art-graph i:nth-child(5) { height: 58%; }
.art-graph i:nth-child(6) { height: 81%; opacity: .5; }
.art-graph i:nth-child(7) { height: 100%; }

.login-form {
  align-self: center;
  width: 100%;
  max-width: 460px;
  padding: 40px;
  margin: auto;
}
.login-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.login-header-brand h2 {
  font-size: 1.8rem;
}
.login-form form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}
.password-control {
  position: relative;
  display: flex;
  align-items: center;
}
.password-control input {
  width: 100%;
  padding-right: 76px;
  min-width: 0;
}
.password-toggle {
  position: absolute;
  right: 5px;
  top: 4px;
  bottom: 4px;
  padding: 0 13px;
  min-width: 62px;
  border-radius: 8px;
  font-size: .875rem;
  color: var(--green);
  background: #edf5f0;
}
.password-toggle:focus-visible {
  outline: 2px solid #137d68;
}
.install-help {
  margin-top: 20px;
}

/* Category Management Styles */
.category-manage-list {
  display: grid;
  gap: 8px;
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #eef2ef;
  gap: 10px;
}
.category-item .category-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.category-item .category-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.color-palette {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
}
.color-dot-opt {
  display: inline-flex;
  cursor: pointer;
  position: relative;
}
.color-dot-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.color-dot-opt span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-block;
  border: 3px solid transparent;
  transition: transform .15s;
}
.color-dot-opt input:checked + span {
  transform: scale(1.15);
  border-color: #122e2c;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Install Guide Modal */
.install-guide {
  display: grid;
  gap: 14px;
  margin: 14px 0;
}
.install-device-box {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.install-device-box h3 {
  font-size: .95rem;
  margin-bottom: 10px;
  color: var(--dark);
}
.install-device-box ol {
  margin: 0;
  padding-left: 20px;
  font-size: .875rem;
  display: grid;
  gap: 6px;
  color: #334d47;
}

/* General Ledger (สมุดบัญชีแยกประเภท) */
.ledger-filter-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.ledger-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.ledger-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}
.ledger-head {
  padding: 16px 20px;
  background: #f8faf9;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.ledger-head .ledger-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ledger-head .ledger-title h3 {
  font-size: 1.05rem;
  font-weight: bold;
}
.ledger-head .ledger-stats {
  display: flex;
  gap: 18px;
  font-size: .8125rem;
}
.ledger-head .ledger-stats div {
  text-align: right;
}
.ledger-head .ledger-stats small {
  display: block;
  color: var(--muted);
  font-size: .75rem;
}
.ledger-head .ledger-stats strong {
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
}
.ledger-table th {
  background: #f3f7f5;
  font-weight: bold;
  color: #39534c;
}
.ledger-row-special td {
  background: #fafcfb;
  font-weight: bold;
  color: #4a685e;
}
.ledger-row-ending td {
  background: #f0f7f3;
  font-weight: bold;
  border-top: 2px solid #ccdcd4;
  border-bottom: 2px solid #ccdcd4;
}
.ledger-scroll-hint {
  display: none;
}

/* AI Scanner Modal */
.scanner-wrap {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}
.scanner-dropzone {
  border: 2px dashed #1fb69e;
  border-radius: 14px;
  padding: 28px 18px;
  text-align: center;
  background: #f2faf7;
  cursor: pointer;
  display: grid;
  gap: 8px;
  place-items: center;
  transition: background .2s;
}
.scanner-dropzone:hover {
  background: #e5f5f0;
}
.scanner-icon {
  font-size: 2.2rem;
}
.scan-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #cfeae3;
  border-top-color: #137d68;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 12px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scan-preview-img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
  object-fit: contain;
  margin: auto;
  display: block;
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}
.scanner-parsed-box {
  background: #f7faf8;
  border: 1px solid #dbe6e0;
  border-radius: 10px;
  padding: 14px;
  margin-top: 10px;
  font-size: .875rem;
}
.ai-key-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f3f7f5;
  border-radius: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-form-scan {
  background: #e6f8f4;
  color: #0f7762;
  border: 1px dashed #20b8a0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%;
}
.btn-form-scan:hover {
  background: #d5f3ec;
}
.scan-inline-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #edf7f3;
  border-radius: 10px;
  border: 1px solid #cee5db;
  margin-bottom: 8px;
}
.scan-inline-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}

/* =========================================================
   RESPONSIVE MEDIA QUERIES (TABLET & MOBILE)
   ========================================================= */

@media(max-width: 1200px) {
  .sidebar { width: 205px; padding: 28px 15px; }
  .main { margin-left: 205px; }
  .workspace { padding: 24px 20px; }
  .topbar { padding: 0 24px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .grid-main { grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); }
  .donut-layout { flex-direction: column; }
  .category-legend { width: 100%; }
  .category-legend ul { grid-template-columns: 1fr 1fr; gap: 8px 15px; }
  .stats { gap: 12px; }
  .stat { padding: 16px 14px; }
  .stat-value { font-size: 1.4rem; }
  .goal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tablet & Mobile Landscape / Medium Screen (<= 900px) */
@media(max-width: 900px) {
  /* Hide desktop sidebar container so it does not duplicate topbar header */
  .sidebar {
    position: static !important;
    width: auto !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    background: transparent !important;
    overflow: visible !important;
  }
  .sidebar > .brand,
  .sidebar > .sidebar-caption,
  .sidebar > .sidebar-bottom {
    display: none !important;
  }
  .main {
    margin-left: 0 !important;
    padding-bottom: calc(75px + env(safe-area-inset-bottom)) !important;
  }

  /* Unified Single Header Bar */
  .topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 50 !important;
    height: auto !important;
    min-height: 52px !important;
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px !important;
    background: #ffffff !important;
    border-bottom: 1px solid var(--line) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 8px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03) !important;
  }
  .topbar-brand {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: .875rem !important;
    color: var(--ink) !important;
    white-space: nowrap !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .topbar-logo {
    width: 28px !important;
    height: 28px !important;
    flex: none !important;
  }
  .topbar-brand strong:first-of-type {
    color: var(--dark) !important;
    font-size: .875rem !important;
  }
  .topbar-brand .slash {
    color: #bac5bf !important;
    margin: 0 4px !important;
  }
  #breadcrumb {
    color: var(--green) !important;
    font-weight: bold !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .top-right {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex: 0 0 auto !important;
  }
  .btn-topbar-scan, .btn-topbar-install {
    padding: 5px 10px !important;
    font-size: .75rem !important;
    border-radius: 16px !important;
    min-height: 32px !important;
  }
  .sync {
    font-size: 0 !important;
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    margin: 0 2px !important;
    padding: 0 !important;
    display: inline-block !important;
  }
  .sync::before {
    margin-right: 0 !important;
  }
  .user-pill {
    font-size: .8125rem !important;
    padding: 4px 10px !important;
    max-width: 140px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    border-radius: 16px !important;
  }

  /* Bottom App Navigation Bar */
  .sidebar nav {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: #ffffff !important;
    border-top: 1px solid #dbe5e0 !important;
    box-shadow: 0 -4px 18px rgba(0,0,0,0.06) !important;
    padding: 4px max(4px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left)) !important;
    z-index: 100 !important;
    gap: 2px !important;
    margin: 0 !important;
  }
  .sidebar nav::-webkit-scrollbar {
    display: none;
  }
  .sidebar nav button {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 4px 3px !important;
    min-height: 48px !important;
    min-width: 50px !important;
    flex: 1 0 auto !important;
    font-size: .6875rem !important;
    line-height: 1.15 !important;
    color: #63776f !important;
    border-radius: 8px !important;
    background: transparent !important;
    white-space: nowrap !important;
    border: none !important;
    text-align: center !important;
  }
  .sidebar nav button span {
    display: block !important;
    font-size: 1.15rem !important;
    line-height: 1.1 !important;
    height: 20px !important;
    width: auto !important;
    margin-bottom: 2px !important;
  }
  .sidebar nav button.active {
    color: #0f6c57 !important;
    font-weight: bold !important;
    background: #e8f5ef !important;
  }
  .sidebar nav .btn-sidebar-scan {
    color: #0d6e5a !important;
    background: #e4f7f2 !important;
    border: 1px solid #c0eee4 !important;
    font-weight: 600 !important;
  }
  .sidebar nav .btn-sidebar-install {
    display: none !important;
  }

  .grid-main { grid-template-columns: 1fr 1fr; }
  .kanban { gap: 12px; }
  .kanban-column { padding: 10px; }
  .workspace { padding: 20px 16px; }
}

/* Mobile Phones (<= 650px) */
@media(max-width: 650px) {
  .workspace {
    padding: 14px 10px 10px !important;
    max-width: 100% !important;
  }
  .page-heading {
    margin-bottom: 14px !important;
    gap: 10px !important;
  }
  .page-heading h1 {
    font-size: 1.35rem !important;
    line-height: 1.3 !important;
  }
  .page-heading p {
    font-size: .8125rem !important;
  }
  .eyebrow {
    font-size: .6875rem !important;
    margin-bottom: 4px !important;
  }

  /* Heading Controls Grid */
  .heading-controls {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .heading-controls .period {
    grid-column: 1 / -1 !important;
    display: flex !important;
    justify-content: space-between !important;
    background: #ffffff !important;
    border: 1px solid var(--line) !important;
    border-radius: 10px !important;
    padding: 2px 6px !important;
    height: 42px !important;
  }
  .heading-controls .period select {
    flex: 1 !important;
    font-size: .9375rem !important;
    padding: 6px !important;
    border: none !important;
    text-align: center !important;
    min-height: 38px !important;
  }
  #add-main {
    grid-column: 1 / -1 !important;
    order: 2 !important;
    width: 100% !important;
    min-height: 46px !important;
    font-size: .95rem !important;
    font-weight: bold !important;
    border-radius: 10px !important;
    box-shadow: 0 3px 10px rgba(19, 125, 104, 0.2) !important;
  }
  #open-scan {
    grid-column: 1 / 2 !important;
    order: 3 !important;
    width: 100% !important;
    min-height: 40px !important;
    font-size: .8125rem !important;
    border-radius: 9px !important;
    padding: 8px !important;
  }
  #open-export {
    grid-column: 2 / 3 !important;
    order: 4 !important;
    width: 100% !important;
    min-height: 40px !important;
    font-size: .8125rem !important;
    border-radius: 9px !important;
    padding: 8px !important;
  }

  /* Stats & Ledger Summary Cards (2x2 Grid) */
  .stats, .ledger-summary-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
  }
  .stat {
    padding: 12px 10px !important;
    border-radius: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }
  .stat-head {
    font-size: .75rem !important;
    gap: 4px !important;
  }
  .stat-icon {
    display: none !important;
  }
  .stat-value {
    font-size: clamp(1.02rem, 3.8vw, 1.25rem) !important;
    letter-spacing: -0.02em !important;
    margin: 8px 0 2px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-weight: bold !important;
  }
  .stat p {
    font-size: .6875rem !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin: 0 !important;
  }

  /* Card Container */
  .card {
    border-radius: 14px !important;
    padding: 14px 12px !important;
    min-width: 0 !important;
  }
  .card-heading h2 {
    font-size: 1.05rem !important;
  }
  .grid-main, .goal-grid, .budget-grid, .users-grid, .kanban {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  /* Mobile Banking Card Style for Transactions */
  .table-wrap:not(.ledger-table-wrap) {
    overflow: visible !important;
  }
  .table-wrap:not(.ledger-table-wrap) thead {
    display: none !important;
  }
  .table-wrap:not(.ledger-table-wrap) table,
  .table-wrap:not(.ledger-table-wrap) tbody {
    display: block !important;
    width: 100% !important;
  }
  .table-wrap:not(.ledger-table-wrap) tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas:
      "description amount"
      "category category"
      "person actions" !important;
    gap: 8px !important;
    padding: 12px !important;
    margin-bottom: 8px !important;
    background: #fafcfb !important;
    border: 1px solid #e9efec !important;
    border-radius: 10px !important;
  }
  .table-wrap:not(.ledger-table-wrap) tr:last-child {
    margin-bottom: 0 !important;
  }
  .table-wrap:not(.ledger-table-wrap) td {
    padding: 0 !important;
    border: 0 !important;
    display: block !important;
    min-width: 0 !important;
  }
  .table-wrap:not(.ledger-table-wrap) td:nth-child(1) {
    grid-area: description !important;
    font-weight: 600 !important;
    font-size: .9375rem !important;
  }
  .table-wrap:not(.ledger-table-wrap) td:nth-child(2) {
    grid-area: category !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
  }
  .table-wrap:not(.ledger-table-wrap) td:nth-child(3) {
    grid-area: person !important;
    align-self: center !important;
    font-size: .75rem !important;
    color: var(--muted) !important;
  }
  .table-wrap:not(.ledger-table-wrap) td:nth-child(3)::before {
    content: "โดย " !important;
    color: var(--muted) !important;
  }
  .table-wrap:not(.ledger-table-wrap) td:nth-child(4) {
    grid-area: amount !important;
    font-size: 1.05rem !important;
    font-weight: bold !important;
    text-align: right !important;
  }
  .table-wrap:not(.ledger-table-wrap) td:nth-child(5) {
    grid-area: actions !important;
    text-align: right !important;
  }
  .row-actions button {
    font-size: .75rem !important;
    min-height: 34px !important;
    padding: 5px 9px !important;
    border-radius: 6px !important;
    border: 1px solid #d5dfda !important;
    background: #ffffff !important;
    margin-left: 4px !important;
  }
  .row-actions button.delete {
    border-color: #ffd2d2 !important;
    background: #fff6f6 !important;
    color: var(--red) !important;
  }

  /* Dedicated Ledger Table (Clean Accounting Sheet) */
  .ledger-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: block !important;
    width: 100% !important;
    border-top: 1px solid var(--line) !important;
    padding-bottom: 6px !important;
  }
  .ledger-table {
    display: table !important;
    min-width: 580px !important;
    width: 100% !important;
    border-collapse: collapse !important;
  }
  .ledger-table thead {
    display: table-header-group !important;
  }
  .ledger-table tbody {
    display: table-row-group !important;
  }
  .ledger-table tr {
    display: table-row !important;
    padding: 0 !important;
    background: transparent !important;
    border-bottom: 1px solid #eef2ef !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .ledger-table th, .ledger-table td {
    display: table-cell !important;
    padding: 8px 10px !important;
    font-size: .8125rem !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
  }
  .ledger-table td:nth-child(3)::before {
    content: none !important;
  }
  .ledger-table .row-description {
    white-space: normal !important;
    min-width: 150px !important;
    max-width: 200px !important;
  }
  .ledger-scroll-hint {
    display: block !important;
    font-size: .72rem !important;
    color: #0f7762 !important;
    background: #eef9f5 !important;
    padding: 5px 12px !important;
    text-align: center !important;
    border-bottom: 1px solid #dbebe3 !important;
  }
  .ledger-head {
    padding: 12px 14px !important;
    gap: 10px !important;
  }
  .ledger-head .ledger-title {
    width: 100% !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .ledger-head .ledger-title h3 {
    font-size: .95rem !important;
  }
  .ledger-head .ledger-stats {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 4px !important;
    background: #f1f6f3 !important;
    border-radius: 8px !important;
    padding: 8px 6px !important;
  }
  .ledger-head .ledger-stats div {
    text-align: center !important;
  }
  .ledger-head .ledger-stats small {
    font-size: .6875rem !important;
  }
  .ledger-head .ledger-stats strong {
    font-size: .8125rem !important;
  }

  /* Donut Chart & Legend */
  .donut-layout {
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
  }
  .donut {
    width: 150px !important;
    height: 150px !important;
  }
  .category-legend {
    width: 100% !important;
  }
  .category-legend ul {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px 10px !important;
  }
  .category-legend li {
    font-size: .75rem !important;
  }

  /* Mobile Bottom Sheet Dialogs */
  dialog {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 88vh !important;
    max-height: 88dvh !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom)) !important;
    overscroll-behavior: contain !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }
  .dialog-actions {
    position: sticky !important;
    bottom: 0 !important;
    background: #ffffff !important;
    padding-top: 10px !important;
    margin-top: 14px !important;
    border-top: 1px solid #eef2ef !important;
    display: flex !important;
    gap: 8px !important;
  }
  .dialog-actions button {
    flex: 1 !important;
    min-height: 44px !important;
    font-size: .9375rem !important;
    border-radius: 10px !important;
  }
  .dialog-heading h2 {
    font-size: 1.1rem !important;
  }

  /* Scanner Dialog Mobile */
  .scanner-dropzone {
    padding: 20px 14px !important;
    border-radius: 12px !important;
  }
  .scanner-icon {
    font-size: 2rem !important;
  }
  .scan-preview-img {
    max-height: 160px !important;
  }
  .scanner-parsed-box {
    padding: 12px !important;
    font-size: .8125rem !important;
  }

  /* Login View Mobile */
  .login-wrap:not([hidden]) {
    min-height: 100vh !important;
    min-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .login-art {
    padding: calc(14px + env(safe-area-inset-top)) 18px 14px !important;
    gap: 6px !important;
  }
  .login-art .brand {
    font-size: 1.05rem !important;
  }
  .login-art .brand-logo {
    width: 40px !important;
    height: 40px !important;
  }
  .login-art h1 {
    font-size: 1.3rem !important;
    margin: 4px 0 !important;
    line-height: 1.3 !important;
  }
  .login-art p, .login-art small, .art-graph {
    display: none !important;
  }
  .login-form {
    padding: 20px 18px calc(24px + env(safe-area-inset-bottom)) !important;
    flex: 1 !important;
    max-width: 100% !important;
  }
  .login-header-brand h2 {
    font-size: 1.25rem !important;
  }
  .login-form select, .login-form input {
    font-size: 1rem !important;
    min-height: 46px !important;
  }
  .login-form .primary {
    min-height: 46px !important;
    font-size: 1rem !important;
    border-radius: 10px !important;
  }
  .field-row {
    grid-template-columns: 1fr !important;
  }
  .users-grid .member-card {
    gap: 10px !important;
    flex-wrap: wrap !important;
  }
  .member-card .avatar {
    width: 40px !important;
    height: 40px !important;
  }
  footer {
    flex-direction: column !important;
    padding-bottom: 8px !important;
    gap: 6px !important;
  }
}
