:root {
  --bg: #eef4f3;
  --surface: #ffffff;
  --ink: #102326;
  --muted: #5f6f73;
  --brand: #0b4f59;
  --brand-2: #127a69;
  --line: #d8e3e1;
  --warn: #a06410;
  --warn-bg: #fff4d9;
  --bad: #9c2d27;
  --bad-bg: #ffe9e6;
  --good: #166d45;
  --good-bg: #e7f7ed;
  --shadow: 0 10px 24px rgba(16, 35, 38, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(84px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 2px 12px;
  background: rgba(238, 244, 243, 0.94);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.icon-btn,
.text-btn,
.chip,
.nav-btn,
.primary-btn,
.secondary-btn,
.close-btn {
  border: 0;
  cursor: pointer;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow);
  font-size: 21px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  min-height: 82px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--brand);
  font-size: 25px;
  line-height: 1;
}

.metric-card.warning strong {
  color: var(--warn);
}

.metric-card.paid strong {
  color: var(--good);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 18px 0 10px;
}

.text-btn {
  padding: 8px 10px;
  border-radius: 8px;
  background: #dce9e7;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.search-wrap input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(18, 122, 105, 0.16);
}

.chips {
  display: flex;
  gap: 8px;
  margin: 10px 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  flex: 0 0 auto;
  padding: 9px 12px;
  border-radius: 999px;
  background: #dce8e6;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.chip.active {
  background: var(--brand);
  color: white;
}

.account-list {
  display: grid;
  gap: 10px;
}

.account-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.account-card.urgent {
  border-color: #f0c36b;
  background: var(--warn-bg);
}

.account-card.closed {
  border-color: #f1b6af;
  background: var(--bad-bg);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.account-title {
  min-width: 0;
}

.account-title strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.account-title span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  align-self: start;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--good-bg);
  color: var(--good);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.closed,
.status-pill.disconnected,
.status-pill.stopped {
  background: var(--bad-bg);
  color: var(--bad);
}

.money-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.money-row div {
  min-height: 58px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(16, 35, 38, 0.08);
}

.money-row span,
.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.money-row strong,
.detail-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.15;
}

.note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 12px;
}

.primary-btn,
.secondary-btn {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-btn {
  background: var(--brand);
  color: white;
}

.secondary-btn {
  background: #dce9e7;
  color: var(--brand);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
}

.nav-btn {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 7px 6px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.nav-btn span {
  font-size: 18px;
}

.nav-btn.active {
  background: #dce9e7;
  color: var(--brand);
}

.sheet-dialog {
  width: min(440px, calc(100vw - 18px));
  max-height: 90vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 14px 14px 0 0;
  background: transparent;
}

.sheet-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-card {
  position: relative;
  display: grid;
  gap: 13px;
  padding: 18px;
  border-radius: 14px 14px 0 0;
  background: var(--surface);
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #edf3f2;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.detail-grid div,
.issue-box {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfa;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  color: var(--ink);
  outline: none;
}

.field textarea {
  resize: vertical;
}

.issue-box strong {
  display: block;
  margin-bottom: 6px;
}

.issue-box p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #bdd0cd;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

@media (min-width: 520px) {
  .app-shell {
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }
}
