/* Account — flat soft UI (inherits shell tokens; local overrides below) */
:root {
  --ink: #0f0f10;
  --muted: #6b6b73;
  --line: #e6e6ea;
  --bg: #f5f5f7;
  --card: #ffffff;
  --accent: #0f0f10;
  --accent-soft: #e8e8ec;
  --pastel-mint: #d8f0e3;
  --pastel-peach: #ffe0c2;
  --pastel-sky: #d6e8ff;
  --gave: #dc2626;
  --gave-soft: #fef2f2;
  --got: #15803d;
  --got-soft: #f0fdf4;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --display: "Plus Jakarta Sans", system-ui, sans-serif;
  --radius-card: 24px;
  --radius-tile: 20px;
  --radius-pill: 999px;
  --radius-sheet: 28px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

.hidden { display: none !important; }

.screen {
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 100vh;
  padding-bottom: calc(96px + var(--safe-bottom));
  position: relative;
  background: var(--bg);
}

/* Content column — nav bars stay full viewport width */
.account-pad {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}

.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 16px;
}

.total {
  border-radius: var(--radius-card);
  padding: 18px 16px;
  border: 0;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.total.give { background: var(--pastel-peach); }
.total.get { background: var(--pastel-mint); }

.total .lbl {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.total strong {
  font-family: var(--display);
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.total.give strong { color: var(--gave); }
.total.get strong { color: var(--got); }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.search-row {
  flex: 1;
  min-width: 0;
  padding: 0;
}

.search-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 13px 18px;
  font: inherit;
  font-weight: 500;
  background: var(--card);
  color: var(--ink);
}

.search-row input:focus {
  outline: 2px solid rgba(15, 15, 16, 0.15);
  border-color: var(--ink);
}

.btn-add-party {
  display: none;
  flex-shrink: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 12px 18px;
  min-height: 48px;
  cursor: pointer;
  white-space: nowrap;
}

.section-label {
  padding: 14px 4px 10px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.muted { color: var(--muted); font-weight: 600; }

.party-list {
  padding: 0;
  display: grid;
  gap: 10px;
}

.party-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 14px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0 12px;
  align-items: center;
  font: inherit;
  cursor: pointer;
  color: inherit;
  box-shadow: none;
}

.party-card:active { transform: scale(0.99); }

@media (hover: hover) and (pointer: fine) {
  .party-card:hover {
    border-color: var(--ink);
  }
}

.party-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--pastel-sky);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.05rem;
}

.party-main { min-width: 0; }
.party-card .name {
  font-weight: 700;
  font-size: 1.02rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.party-card .meta {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.party-card .bal {
  font-family: var(--display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.02rem;
  white-space: nowrap;
}
.party-card .bal.get { color: var(--got); }
.party-card .bal.give { color: var(--gave); }
.party-card .bal.settled { color: var(--muted); }

.party-chevron {
  color: var(--muted);
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1;
  opacity: 0.55;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  padding: 40px 16px;
  background: var(--card);
  border-radius: var(--radius-card);
  border: 1px dashed var(--line);
  margin-top: 4px;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  width: 58px;
  height: 58px;
  border-radius: var(--radius-pill);
  border: 0;
  background: var(--ink);
  color: #ffffff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 15, 16, 0.18);
  z-index: 20;
}

@media (min-width: 720px) {
  .account-pad { max-width: 860px; padding: 24px 24px 16px; }
  .totals { gap: 16px; margin-bottom: 20px; }
  .total { padding: 22px 20px; min-height: 110px; }
  .party-list { grid-template-columns: 1fr 1fr; gap: 12px; }
  .btn-add-party { display: inline-flex; align-items: center; }
  .fab { display: none; }
}

@media (min-width: 1024px) {
  .account-pad { max-width: 1120px; }
  .party-list { grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
  .totals { grid-template-columns: 1fr 1fr; max-width: 640px; }
}

.party-head {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px;
  background: var(--ink);
  color: #ffffff;
}

.party-head-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.back, .icon-text {
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.back {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
}

.icon-text {
  border-radius: var(--radius-pill);
  padding: 9px 13px;
  min-height: 40px;
  font-size: 0.78rem;
}

.party-head-text { flex: 1; min-width: 0; }
.party-head-text h2 {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.party-head .sub {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.88rem;
  margin-top: 4px;
  font-weight: 500;
}

.balance-card {
  margin: 0 0 14px;
  padding: 18px 16px;
  border-radius: var(--radius-card);
  background: var(--card);
  border: 0;
  text-align: center;
  box-shadow: none;
}

.balance-card .lbl {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.balance-card strong {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.balance-card.get strong { color: var(--got); }
.balance-card.give strong { color: var(--gave); }

.entry-list { padding: 0 0 20px; display: grid; gap: 10px; }

.entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 0;
  border-radius: var(--radius-tile);
  padding: 14px 16px;
  border-left: 4px solid var(--line);
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.entry:hover { filter: brightness(0.98); }

.entry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  grid-column: 1 / -1;
}

.pay-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px 8px;
  background: var(--accent-soft);
}

.entry.gave { border-left-color: var(--gave); background: var(--gave-soft); }
.entry.got { border-left-color: var(--got); background: var(--got-soft); }

.entry .etype {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.entry.gave .etype { color: var(--gave); }
.entry.got .etype { color: var(--got); }

.entry .amt {
  font-family: var(--display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.entry.gave .amt { color: var(--gave); }
.entry.got .amt { color: var(--got); }

.entry .note { font-size: 0.85rem; font-weight: 600; color: var(--ink); grid-column: 1 / -1; }
.entry .date { font-size: 0.75rem; color: var(--muted); font-weight: 600; }

.btn-danger {
  border: 0;
  border-radius: var(--radius-tile);
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  color: #ffffff;
  background: var(--gave);
  cursor: pointer;
}

.action-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(100%, 860px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: rgba(245, 245, 247, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  z-index: 15;
}

@media (min-width: 1024px) {
  .action-bar { width: min(100%, 1120px); }
}

.btn-gave, .btn-got {
  border: 0;
  border-radius: var(--radius-tile);
  padding: 14px 10px;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  color: #ffffff;
}

.btn-gave { background: var(--gave); }
.btn-got { background: var(--got); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 16, 0.45);
  animation: modalFadeIn 0.2s ease;
}

.modal-sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 480px);
  background: var(--card);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  box-shadow: none;
  animation: modalSlideUp 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalSlideUp {
  from { transform: translate(-50%, 24px); opacity: 0.4; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet h3 {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.modal-sheet label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  margin: 10px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-sheet input,
.modal-sheet select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-weight: 600;
  background: #fff;
  color: var(--ink);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.btn-muted, .btn-primary {
  border-radius: var(--radius-tile);
  padding: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-muted {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
}

.btn-primary {
  border: 0;
  background: var(--ink);
  color: #ffffff;
}

.btn-primary.gave { background: var(--gave); }
.btn-primary.got { background: var(--got); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Scan bill + payment mode tags (Account AI / entry form) */
.btn-scan {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 4px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-tile);
  background: var(--accent-soft);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 12px 14px;
  cursor: pointer;
}

.btn-scan:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-scan:hover {
  border-color: var(--ink);
}

.pay-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pay-tag {
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}

.pay-tag.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.modal-actions:has(.btn-danger:not(.hidden)) {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Second FAB — chat sits above the + button */
.fab-chat {
  bottom: calc(88px + var(--safe-bottom));
  background: var(--pastel-sky);
  color: var(--ink);
  font-size: 1.45rem;
  box-shadow: 0 8px 24px rgba(15, 15, 16, 0.12);
}

@media (min-width: 720px) {
  .fab-chat { display: none; }
}

/* Khata Assistant chat sheet */
.chat-sheet {
  display: flex;
  flex-direction: column;
  width: min(100%, 560px);
  height: min(88vh, 720px);
  max-height: calc(100vh - 12px);
  padding: 0;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.chat-head h3 {
  margin: 0;
  font-size: 1.1rem;
}

.chat-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.chat-bubble {
  max-width: 92%;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-assistant,
.chat-bubble-model {
  align-self: flex-start;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--ink);
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

.chat-bubble-error {
  align-self: stretch;
  background: var(--gave-soft);
  color: var(--gave);
  border: 1px solid #fecaca;
  font-weight: 600;
}

.chat-attachment-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  margin: 0 16px 8px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background: var(--pastel-sky);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
}

.chat-attachment-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  padding: 10px 14px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--card);
}

.chat-attach-btn,
.chat-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 1.15rem;
  cursor: pointer;
}

.chat-attach-btn {
  background: var(--accent-soft);
  color: var(--ink);
}

.chat-send {
  background: var(--ink);
  color: #ffffff;
}

.chat-send:disabled {
  opacity: 0.45;
  cursor: wait;
}

.chat-input-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 500;
  line-height: 1.35;
  background: var(--bg);
  color: var(--ink);
}

.chat-input-row textarea:focus {
  outline: 2px solid rgba(15, 15, 16, 0.15);
  border-color: var(--ink);
}

/* Interactive chat cards (select / confirm / data) */
.chat-card {
  align-self: stretch;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-card-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
}

.chat-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-option-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-tile);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 11px 14px;
  cursor: pointer;
}

.chat-option-btn:hover {
  border-color: var(--ink);
}

.chat-card-rows {
  display: grid;
  gap: 6px;
}

.chat-card-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
}

.chat-card-row-label {
  color: var(--muted);
  font-weight: 600;
}

.chat-card-row-value {
  font-weight: 700;
  text-align: right;
  color: var(--ink);
}

.chat-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.chat-card-cancel,
.chat-card-confirm-btn {
  border-radius: var(--radius-tile);
  padding: 11px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.chat-card-cancel {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
}

.chat-card-confirm-btn {
  border: 0;
  background: var(--ink);
  color: #ffffff;
}

.chat-card-resolved {
  opacity: 0.72;
  pointer-events: none;
}

.chat-card-note {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

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

.chat-data-table th,
.chat-data-table td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.chat-data-table th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
}

.chat-data-table td {
  font-weight: 600;
  color: var(--ink);
}
