/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #080C16;
  --surface:    #101828;
  --surface-2:  #192138;
  --surface-3:  #222E46;
  --border:     rgba(255,255,255,0.07);
  --border-2:   rgba(255,255,255,0.14);

  --text:       #EFF4FC;
  --text-muted: #5D6F8E;
  --text-dim:   #374259;

  --green:      #00D68F;
  --green-dim:  rgba(0,214,143,0.12);
  --green-glow: rgba(0,214,143,0.25);
  --amber:      #F5A623;
  --amber-dim:  rgba(245,166,35,0.12);
  --red:        #FF4757;
  --red-dim:    rgba(255,71,87,0.12);
  --blue:       #4A90E2;
  --blue-dim:   rgba(74,144,226,0.12);

  --header-h:   60px;
  --nav-h:      70px;
  --radius:     20px;
  --radius-sm:  14px;
  --radius-xs:  8px;
  --ease:       200ms ease;
  --ease-slow:  360ms cubic-bezier(0.32,0.72,0,1);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  font-size: 16px;
}

button { cursor: pointer; font-family: inherit; }
input  { font-family: inherit; }

/* ============================================================
   FULL-SCREEN OVERLAYS (Boot / Auth / Pair)
   ============================================================ */
.full-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.full-screen.hidden { display: none; }
.hidden { display: none !important; }

.boot-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}
.brand-big {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-big .brand-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00D68F 0%, #4A90E2 100%);
  box-shadow: 0 0 24px rgba(0,214,143,0.55);
  flex-shrink: 0;
}
.brand-name-big {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #EFF4FC 0%, #00D68F 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.boot-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--green);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-card, .pair-card {
  width: 100%;
  max-width: 380px;
  margin: auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
}
.auth-head, .pair-head {
  margin-bottom: 28px;
  text-align: center;
}
.auth-head .brand-big, .pair-head .brand-big {
  justify-content: center;
  margin-bottom: 24px;
}
.auth-head h1, .pair-head h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}
.auth-head p, .pair-head p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 100px;
  padding: 4px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 11px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  border-radius: 100px;
  transition: var(--ease);
  cursor: pointer;
}
.auth-tab.active { background: var(--surface-3); color: var(--text); }

.auth-field, .pair-field {
  margin-bottom: 14px;
}
.auth-field label, .pair-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 7px;
}
.auth-input, .pair-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  outline: none;
  transition: border-color var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.auth-input:focus, .pair-input:focus { border-color: var(--green); }
.auth-input::placeholder, .pair-input::placeholder { color: var(--text-dim); font-weight: 400; }

.pair-input.code-input {
  text-align: center;
  letter-spacing: 6px;
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  font-family: ui-monospace, 'Menlo', monospace;
}

.auth-btn, .pair-btn {
  width: 100%;
  background: var(--green);
  color: #000;
  border: none;
  padding: 15px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 800;
  transition: var(--ease);
  margin-top: 6px;
  cursor: pointer;
}
.auth-btn:active, .pair-btn:active { transform: scale(0.98); }
.auth-btn:disabled, .pair-btn:disabled { background: var(--surface-3); color: var(--text-muted); cursor: not-allowed; transform: none; }

.reveal-wrap { position: relative; }
.reveal-wrap .settings-input,
.reveal-wrap .auth-input { padding-right: 46px; }
.reveal-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  padding: 6px 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.reveal-btn:active { transform: translateY(-50%) scale(0.9); }

.auth-error {
  background: var(--red-dim);
  border: 1px solid rgba(255,71,87,0.3);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 12px;
  color: var(--red);
  margin-bottom: 14px;
  line-height: 1.4;
}
.auth-foot {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 20px;
  line-height: 1.5;
}

.pair-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pair-option {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  transition: var(--ease);
}
.pair-option:active { transform: scale(0.99); }
.pair-option.active { border-color: var(--green); background: linear-gradient(160deg, var(--surface) 60%, rgba(0,214,143,0.06)); }
.pair-option-h {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
}
.pair-option-h .emoji { font-size: 22px; }
.pair-option-p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.pair-code-display {
  background: var(--surface);
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  margin: 14px 0;
}
.pair-code-display .lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-bottom: 10px;
}
.pair-code-display .code {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 8px;
  font-family: ui-monospace, 'Menlo', monospace;
  color: var(--green);
  margin-bottom: 12px;
}
.pair-code-display .hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

.pair-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 14px;
  cursor: pointer;
  align-self: center;
  margin-top: 10px;
}

/* Migrate banner (offer to import Phase 1 local data) */
.migrate-banner {
  margin: 12px 0 0;
  background: linear-gradient(135deg, var(--blue-dim) 0%, rgba(74,144,226,0.04) 100%);
  border: 1px solid rgba(74,144,226,0.3);
  border-radius: var(--radius);
  padding: 16px;
}
.migrate-banner h4 { font-size: 14px; font-weight: 800; color: var(--blue); margin-bottom: 6px; }
.migrate-banner p { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }
.migrate-actions { display: flex; gap: 8px; }
.migrate-actions button {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 800;
  border: none;
  cursor: pointer;
}
.migrate-yes { background: var(--blue); color: #fff; }
.migrate-no  { background: var(--surface-2); border: 1px solid var(--border) !important; color: var(--text-muted); }

/* Cloud / online indicator chip on header */
.cloud-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.cloud-status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(0,214,143,0.6); }
.cloud-status.offline .dot { background: var(--amber); box-shadow: none; }
.cloud-status.offline { color: var(--amber); }
.cloud-status.local   { color: var(--text-dim); }
.cloud-status.local .dot { background: var(--text-dim); box-shadow: none; }

/* Partner activity toast variant */
.toast.partner {
  background: linear-gradient(135deg, var(--blue-dim) 0%, rgba(74,144,226,0.08) 100%);
  color: var(--blue);
  border-color: rgba(74,144,226,0.4);
  max-width: 320px;
  white-space: normal;
  text-align: center;
  line-height: 1.4;
  padding: 12px 18px;
}

/* Account section in Settings */
.account-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.account-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00D68F, #4A90E2);
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  font-weight: 900;
  flex-shrink: 0;
}
.account-info { flex: 1; min-width: 0; }
.account-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-mail { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(0,214,143,0.3);
}

.invite-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  margin-bottom: 10px;
}
.invite-card .lbl { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 9px; }
.invite-card .code {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 7px;
  font-family: ui-monospace, 'Menlo', monospace;
  color: var(--green);
  margin-bottom: 10px;
}
.invite-card .hint { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }
.invite-copy {
  background: var(--green-dim);
  border: 1px solid rgba(0,214,143,0.3);
  color: var(--green);
  padding: 9px 18px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
  max-width: 430px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
#app-header {
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.hdr-left  { display: flex; align-items: center; justify-content: flex-start; }
.hdr-right { display: flex; align-items: center; justify-content: flex-end; }
.hdr-center { display: flex; align-items: center; justify-content: center; }

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
}
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00D68F 0%, #4A90E2 100%);
  box-shadow: 0 0 14px rgba(0,214,143,0.5);
  flex-shrink: 0;
}
.brand-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.2px;
  background: linear-gradient(135deg, #EFF4FC 0%, #00D68F 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.month-arrow {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--ease);
  line-height: 1;
  padding-bottom: 1px;
}
.month-arrow:hover { background: var(--surface-3); color: var(--text); }
.month-arrow:active { transform: scale(0.9); }

#current-month-label {
  font-size: 14px;
  font-weight: 700;
  min-width: 94px;
  text-align: center;
}


/* ============================================================
   TAB PANES
   ============================================================ */
#tab-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-pane {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 16px 16px calc(var(--nav-h) + 28px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity var(--ease), transform var(--ease);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#tab-home > * { margin-bottom: 14px; }
#tab-home > *:last-child { margin-bottom: 0; }
.tab-pane::-webkit-scrollbar { display: none; }
.tab-pane.active { opacity: 1; pointer-events: all; transform: none; }

/* ============================================================
   BOTTOM NAV
   ============================================================ */
#bottom-nav {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  background: rgba(8,12,22,0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  transition: color var(--ease);
  padding: 8px 4px 6px;
  position: relative;
}
.nav-tab span { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; }
.nav-tab.active { color: var(--green); }
.nav-tab.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 2px;
  background: var(--green);
  border-radius: 0 0 3px 3px;
}

/* ============================================================
   SHARED COMPONENTS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ============================================================
   HOME TAB
   ============================================================ */

/* Setup prompt */
.setup-prompt {
  background: var(--surface);
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  margin-bottom: 12px;
}
.setup-prompt h2 { font-size: 19px; font-weight: 800; margin-bottom: 8px; }
.setup-prompt p  { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.5; }

.btn-primary {
  background: var(--green);
  color: #000;
  border: none;
  padding: 14px 32px;
  border-radius: 100px;
  font-size: 15px;
  font-weight: 800;
  transition: var(--ease);
}
.btn-primary:active { transform: scale(0.97); background: #00bf82; }

/* Status card */
.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px 18px;
  margin-bottom: 12px;
  transition: border-color var(--ease);
}
.status-card.safe    { border-color: rgba(0,214,143,0.25);  background: linear-gradient(160deg, var(--surface) 55%, rgba(0,214,143,0.05)); }
.status-card.at-risk { border-color: rgba(245,166,35,0.25); background: linear-gradient(160deg, var(--surface) 55%, rgba(245,166,35,0.05)); }
.status-card.breached{ border-color: rgba(255,71,87,0.3);   background: linear-gradient(160deg, var(--surface) 55%, rgba(255,71,87,0.05)); }

.status-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.status-top-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
}
.status-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.safe     { background: var(--green-dim); color: var(--green); border: 1px solid rgba(0,214,143,0.3); }
.status-badge.at-risk  { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,166,35,0.3); }
.status-badge.breached { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(255,71,87,0.3); }

.savings-target-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.savings-target-value {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1;
  margin-bottom: 6px;
}
.savings-target-value .curr { font-size: 16px; font-weight: 600; color: var(--text-muted); margin-right: 3px; }

.savings-msg { font-size: 12px; font-weight: 600; margin-bottom: 16px; }
.savings-msg.safe    { color: var(--green); }
.savings-msg.at-risk { color: var(--amber); }
.savings-msg.breached{ color: var(--red); }

.bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.bar-track {
  height: 7px;
  background: var(--surface-3);
  border-radius: 100px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
}
.bar-fill.safe    { background: var(--green); }
.bar-fill.at-risk { background: linear-gradient(90deg, var(--green), var(--amber)); }
.bar-fill.breached{ background: linear-gradient(90deg, var(--amber), var(--red)); }

/* 3-metric row */
.metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
}
.metric-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.metric-value {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}
.metric-value .curr { font-size: 10px; color: var(--text-muted); margin-right: 1px; font-weight: 600; }
.metric-value.positive { color: var(--green); }
.metric-value.negative { color: var(--red); }

/* Quick stats bottom cards */
.quick-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.qs-left  { display: flex; align-items: center; gap: 12px; }
.qs-icon  { font-size: 26px; }
.qs-lbl   { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.qs-val   { font-size: 14px; font-weight: 700; }
.qs-right { font-size: 15px; font-weight: 800; }

.info-row {
  display: flex;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 10px;
}
.info-block .info-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); margin-bottom: 4px; }
.info-block .info-val { font-size: 20px; font-weight: 800; }

/* Secure-savings action (pay yourself first) */
.secure-btn {
  width: 100%;
  margin-top: 16px;
  background: var(--green-dim);
  border: 1px solid rgba(0,214,143,0.35);
  color: var(--green);
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2px;
  transition: var(--ease);
}
.secure-btn:active { transform: scale(0.98); background: rgba(0,214,143,0.2); }
.secure-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  gap: 10px;
}
.secure-pill {
  font-size: 12px;
  font-weight: 800;
  color: var(--green);
  background: var(--green-dim);
  border: 1px solid rgba(0,214,143,0.3);
  padding: 8px 13px;
  border-radius: 100px;
  flex: 1;
}
.secure-undo {
  background: none;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 100px;
  transition: var(--ease);
}
.secure-undo:active { transform: scale(0.96); }
.help-btn {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.help-btn:active { transform: scale(0.92); color: var(--text); }

/* Money-flow ledger card */
.flow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  margin-bottom: 12px;
}
.flow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
}
.flow-lbl { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.flow-amt { font-size: 14px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.flow-amt.pos { color: var(--text); }
.flow-row.sub .flow-lbl { color: var(--text-muted); }
.flow-row.sub .flow-amt { color: var(--text-muted); font-weight: 600; }
.flow-tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 5px;
}
.flow-divider { height: 1px; background: var(--border); margin: 5px 0; }
.flow-row.total .flow-lbl { color: var(--text); font-weight: 700; font-size: 13px; }
.flow-row.total .flow-amt { font-size: 15px; font-weight: 800; }
.flow-row.grand { padding-top: 9px; }
.flow-row.grand .flow-lbl { font-size: 14px; font-weight: 800; color: var(--text); }
.flow-row.grand .flow-amt { font-size: 22px; font-weight: 900; letter-spacing: -0.5px; }
.flow-row.grand.pos .flow-amt { color: var(--green); }
.flow-row.grand.neg .flow-amt { color: var(--red); }
.flow-row.grand.neg .flow-lbl { color: var(--red); }

/* Running savings "bank" card */
.bank-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--surface) 0%, rgba(74,144,226,0.07) 100%);
  border: 1px solid rgba(74,144,226,0.2);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
}
.bank-lbl { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; }
.bank-amt { font-size: 28px; font-weight: 900; letter-spacing: -1px; color: var(--text); line-height: 1; }
.bank-amt .curr { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.bank-sub { font-size: 11px; color: var(--text-muted); margin-top: 6px; max-width: 210px; line-height: 1.4; }
.bank-ring {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.bank-ring.done { background: var(--green-dim); border-color: rgba(0,214,143,0.4); }

/* Fixed/Flexible type tags & split bar */
.type-tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 100px;
  vertical-align: middle;
  margin-left: 4px;
}
.type-tag.fixed    { background: var(--amber-dim); color: var(--amber); }
.type-tag.flexible { background: var(--blue-dim);  color: var(--blue); }

.split-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}
.split-bar {
  display: flex;
  height: 10px;
  border-radius: 100px;
  overflow: hidden;
  background: var(--surface-3);
  margin-bottom: 12px;
}
.split-fixed { background: var(--amber); transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.split-flex  { background: var(--blue);  transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.split-legend { display: flex; flex-direction: column; gap: 6px; }
.split-leg { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.split-leg b { color: var(--text); font-weight: 700; }
.split-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.split-dot.fixed { background: var(--amber); }
.split-dot.flex  { background: var(--blue); }

/* Savings rate ring on bank card */
.bank-right { flex-shrink: 0; }
.savings-rate-ring {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 2px solid var(--green);
  background: var(--green-dim);
}
.savings-rate-ring.great   { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.savings-rate-ring.ok      { border-color: var(--amber); background: var(--amber-dim); color: var(--amber); }
.savings-rate-ring.low     { border-color: var(--red);   background: var(--red-dim);   color: var(--red); }
.savings-rate-ring.pending { border-color: var(--border-2); background: var(--surface-2); color: var(--text-dim); }
.srr-pct { font-size: 17px; font-weight: 900; line-height: 1; letter-spacing: -0.4px; }
.srr-lbl { font-size: 9px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; margin-top: 3px; }

/* Cap bar variants on Breakdown */
.cat-bar-fill.cap-bar.ok    { background: var(--green); }
.cat-bar-fill.cap-bar.near  { background: var(--amber); }
.cat-bar-fill.cap-bar.over  { background: var(--red); }
.cat-amount.over-cap { color: var(--red); }
.cat-cap-of { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.over-cap-tag { color: var(--red); font-weight: 800; }
.near-cap-tag { color: var(--amber); font-weight: 700; }

/* Cap input row in Manage Categories */
.cat-cap-row { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.cat-cap-row label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 7px;
}
.cat-cap-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0 4px 0 10px;
}
.cat-cap-input-wrap .cap-curr { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.cat-cap-input-wrap input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: var(--text); font-size: 14px; font-weight: 700;
  padding: 9px 4px;
}
.cat-cap-input-wrap button {
  background: var(--green); color: #000; border: none;
  padding: 7px 14px; border-radius: var(--radius-xs);
  font-size: 12px; font-weight: 800; cursor: pointer;
}

/* Insights card */
.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.insight-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
}
.insight-lbl { font-size: 13px; color: var(--text-muted); }
.insight-val { display: flex; align-items: center; gap: 8px; }
.insight-now { font-size: 14px; font-weight: 800; color: var(--text); }
.insight-delta {
  font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 100px;
  letter-spacing: 0.3px;
}
.insight-delta.good { background: var(--green-dim); color: var(--green); }
.insight-delta.bad  { background: var(--red-dim);   color: var(--red); }

/* Coming-up card */
.upc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.upc-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.upc-row:last-of-type { border-bottom: none; }
.upc-row.done { opacity: 0.55; }
.upc-emoji { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
.upc-mid { flex: 1; min-width: 0; }
.upc-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upc-day  { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.upc-amt { font-size: 13px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.upc-log {
  background: var(--green-dim);
  border: 1px solid rgba(0,214,143,0.35);
  color: var(--green);
  padding: 6px 12px; border-radius: 100px;
  font-size: 11px; font-weight: 800; cursor: pointer;
  flex-shrink: 0;
}
.upc-done { font-size: 16px; color: var(--green); flex-shrink: 0; padding: 0 6px; }
.upc-summary {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted);
}
.upc-summary b { color: var(--text); font-weight: 800; }
.upc-owe     { color: var(--amber); font-weight: 700; }
.upc-allgood { color: var(--green); font-weight: 700; }

/* Recurring template list & form (Settings) */
.rec-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.rec-row:last-child { border-bottom: none; }
.rec-emoji { font-size: 20px; width: 28px; flex-shrink: 0; }
.rec-mid { flex: 1; min-width: 0; }
.rec-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.rec-del {
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; padding: 4px 8px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.rec-del:hover, .rec-del:active { color: var(--red); }

.rec-form { display: flex; flex-direction: column; gap: 8px; }
.rec-form input, .rec-form select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  outline: none;
}
.rec-form input:focus, .rec-form select:focus { border-color: var(--green); }
.rec-form-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; }
.rec-form input, .rec-form select { min-width: 0; }

/* Edit-transaction modal */
.edit-tx { margin: 4px 0 18px; }
.edit-lbl {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 12px 0 6px;
}
.edit-tx > .edit-lbl:first-child { margin-top: 0; }
.edit-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 600;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.edit-input:focus { border-color: var(--green); }
.edit-input[type="date"] { color-scheme: dark; }

/* Category type pill (Settings) */
.cat-type-pill {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid transparent;
  transition: var(--ease);
}
.cat-type-pill.fixed    { background: var(--amber-dim); color: var(--amber); border-color: rgba(245,166,35,0.3); }
.cat-type-pill.flexible { background: var(--blue-dim);  color: var(--blue);  border-color: rgba(74,144,226,0.3); }
.cat-type-pill:active { transform: scale(0.92); }

/* ============================================================
   LOG TAB
   ============================================================ */
.type-toggle {
  display: flex;
  background: var(--surface-2);
  border-radius: 100px;
  padding: 4px;
  margin-bottom: 28px;
  border: 1px solid var(--border);
}
.type-btn {
  flex: 1;
  padding: 11px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  border-radius: 100px;
  transition: var(--ease);
}
.type-btn.active { background: var(--surface-3); color: var(--text); }
.type-btn.active.expense { color: var(--red); }
.type-btn.active.income  { color: var(--green); }

.amount-block {
  text-align: center;
  margin-bottom: 28px;
  padding: 0 8px;
}
.amount-curr {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}
.amount-input {
  background: none;
  border: none;
  outline: none;
  font-size: 54px;
  font-weight: 900;
  color: var(--text);
  text-align: center;
  width: 100%;
  font-family: 'Inter', sans-serif;
  letter-spacing: -2px;
  caret-color: var(--green);
}
.amount-input::placeholder { color: var(--text-dim); }
.amount-line {
  height: 2px;
  background: var(--surface-3);
  border-radius: 2px;
  margin: 10px auto 0;
  max-width: 220px;
  position: relative;
  overflow: hidden;
}
.amount-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}
.amount-input:focus ~ .amount-line::after { transform: scaleX(1); }

.form-section { margin-bottom: 22px; }
.form-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
}

/* Category group grid */
.group-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.group-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 6px 10px;
  text-align: center;
  cursor: pointer;
  transition: var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  -webkit-tap-highlight-color: transparent;
}
.group-chip:active { transform: scale(0.94); }
.group-chip .g-emoji { font-size: 22px; }
.group-chip .g-lbl  { font-size: 10px; font-weight: 600; color: var(--text-muted); line-height: 1.3; text-align: center; }
.group-chip.selected { border-color: var(--green); background: var(--green-dim); }
.group-chip.selected .g-lbl { color: var(--green); }

/* Sub-category chips */
.sub-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green-dim);
  color: var(--green);
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: none;
  margin-left: 8px;
  border: 1px solid rgba(0,214,143,0.3);
}
.sub-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sub-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.sub-chip:active { transform: scale(0.95); }
.sub-chip.selected { background: var(--green-dim); border-color: var(--green); color: var(--green); }

/* Who toggle */
.who-row {
  display: flex;
  gap: 8px;
}
.who-btn {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 13px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  transition: var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.who-btn:active { transform: scale(0.96); }
.who-btn.selected { border-color: var(--blue); background: var(--blue-dim); color: var(--blue); }

/* Income source */
.source-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.source-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  transition: var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.source-btn:active { transform: scale(0.95); }
.source-btn .s-emoji { font-size: 22px; display: block; margin-bottom: 5px; }
.source-btn .s-lbl   { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.source-btn.selected { border-color: var(--green); background: var(--green-dim); }
.source-btn.selected .s-lbl { color: var(--green); }

/* Form inputs */
.form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--green); }
.form-input[type="date"] { color-scheme: dark; }

/* Submit button */
.log-btn {
  width: 100%;
  background: var(--green);
  color: #000;
  border: none;
  padding: 18px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.5px;
  transition: var(--ease);
  margin-top: 8px;
}
.log-btn:active { transform: scale(0.98); background: #00bf82; }
.log-btn:disabled { background: var(--surface-3); color: var(--text-muted); cursor: not-allowed; transform: none; }

/* ============================================================
   BREAKDOWN TAB
   ============================================================ */
.bk-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.bk-s-val { font-size: 26px; font-weight: 900; }
.bk-s-val .curr { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-right: 2px; }
.bk-s-lbl { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: hidden;
}
.cat-header {
  display: flex;
  align-items: center;
  padding: 15px 16px;
  cursor: pointer;
  gap: 14px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.cat-emoji { font-size: 22px; flex-shrink: 0; }
.cat-info  { flex: 1; min-width: 0; }
.cat-name  { font-size: 14px; font-weight: 700; margin-bottom: 7px; }
.cat-bar-track { height: 4px; background: var(--surface-3); border-radius: 100px; overflow: hidden; }
.cat-bar-fill  { height: 100%; background: var(--green); border-radius: 100px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }
.cat-right { text-align: right; flex-shrink: 0; }
.cat-amount { font-size: 15px; font-weight: 800; }
.cat-pct    { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.cat-chevron {
  color: var(--text-dim);
  transition: transform var(--ease);
  flex-shrink: 0;
}
.cat-card.expanded .cat-chevron { transform: rotate(90deg); }

.cat-sub-list { display: none; border-top: 1px solid var(--border); }
.cat-card.expanded .cat-sub-list { display: block; }
.cat-sub-item {
  display: flex;
  justify-content: space-between;
  padding: 11px 16px 11px 54px;
  border-bottom: 1px solid var(--border);
}
.cat-sub-item:last-child { border-bottom: none; }
.cat-sub-name   { font-size: 13px; color: var(--text-muted); }
.cat-sub-amount { font-size: 13px; font-weight: 700; }

.empty-state {
  text-align: center;
  padding: 52px 24px;
}
.empty-state .e-icon { font-size: 42px; margin-bottom: 14px; }
.empty-state p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ============================================================
   FEED TAB
   ============================================================ */
.feed-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  transition: var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.filter-btn.active {
  background: var(--surface-3);
  border-color: var(--border-2);
  color: var(--text);
}

.feed-list { display: flex; flex-direction: column; gap: 8px; }

.feed-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  transition: border-color var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.feed-item.expanded { border-color: var(--border-2); align-items: flex-start; }

.feed-icon {
  font-size: 22px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}
.feed-icon.income-icon { background: var(--green-dim); }

.feed-body   { flex: 1; min-width: 0; }
.feed-cat    { font-size: 14px; font-weight: 700; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-meta   { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.feed-note   { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 6px; display: none; }
.feed-del-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.feed-del-icon:hover, .feed-del-icon:active {
  background: var(--red-dim);
  color: var(--red);
}
.feed-item.expanded .feed-note { display: block; }

.feed-right  { text-align: right; flex-shrink: 0; }
.feed-amount { font-size: 16px; font-weight: 800; line-height: 1.2; }
.feed-amount.expense { color: var(--red); }
.feed-amount.income  { color: var(--green); }
.feed-who    { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ============================================================
   SETTINGS BOTTOM SHEET
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity var(--ease-slow);
}
.overlay.confirm-mode { align-items: center; justify-content: center; }
.overlay.hidden { opacity: 0; pointer-events: none; }

.bottom-sheet {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: 0 24px 36px;
  transform: translateY(100%);
  transition: transform var(--ease-slow);
  border-top: 1px solid var(--border-2);
  max-height: 85vh;
  overflow-y: auto;
}
.overlay:not(.hidden) .bottom-sheet { transform: none; }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-2);
  border-radius: 2px;
  margin: 16px auto 24px;
}
.sheet-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 24px;
}
.sheet-field {
  margin-bottom: 18px;
}
.sheet-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-bottom: 8px;
}
.sheet-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  outline: none;
  transition: border-color var(--ease);
}
.sheet-input:focus { border-color: var(--green); }
.sheet-input::placeholder { color: var(--text-dim); font-weight: 400; }

.sheet-save-btn {
  width: 100%;
  background: var(--green);
  color: #000;
  border: none;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.3px;
  transition: var(--ease);
  margin-top: 8px;
}
.sheet-save-btn:active { transform: scale(0.98); }

/* Confirm dialog */
.dialog {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 24px;
  width: calc(100% - 48px);
  max-width: 380px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.94);
  transition: transform var(--ease-slow);
  -webkit-overflow-scrolling: touch;
}
.overlay:not(.hidden) .dialog { transform: scale(1); }
.dialog h3 { font-size: 16px; font-weight: 800; margin-bottom: 8px; }
.dialog p  { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; line-height: 1.5; }
.dlg-actions { display: flex; gap: 10px; }
.btn-cancel {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
}
.btn-danger {
  flex: 1;
  background: var(--red-dim);
  border: 1px solid rgba(255,71,87,0.4);
  color: var(--red);
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1A2440;
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  white-space: nowrap;
  z-index: 300;
  max-width: 90vw;
  box-shadow: 0 14px 34px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success {
  background: #00B377;
  color: #042116;
  border-color: rgba(255,255,255,0.18);
  box-shadow: 0 14px 34px rgba(0,179,119,0.45), 0 0 0 1px rgba(255,255,255,0.08);
}
.toast.error {
  background: #FF4757;
  color: #fff;
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 14px 34px rgba(255,71,87,0.5), 0 0 0 1px rgba(255,255,255,0.08);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.anim { animation: fadeUp 0.28s ease both; }

@keyframes flashRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,71,87,0); }
  20%, 60% { box-shadow: 0 0 0 4px rgba(255,71,87,0.5); }
}
.flash { animation: flashRed 0.9s ease; border-radius: var(--radius-sm); }

/* ============================================================
   SETTINGS TAB
   ============================================================ */
.settings-section {
  margin-bottom: 22px;
}
.settings-h {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 4px 10px;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 4px;
}
.settings-field {
  margin-bottom: 16px;
}
.settings-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 7px;
}
.settings-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-weight: 700;
  outline: none;
  transition: border-color var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.settings-input:focus { border-color: var(--green); }
.settings-input::placeholder { color: var(--text-dim); font-weight: 400; }

.settings-warn {
  background: var(--red-dim);
  border: 1px solid rgba(255,71,87,0.3);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 12px;
  color: var(--red);
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}
.settings-info {
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  padding: 9px 12px;
  font-size: 11px;
  color: var(--text-muted);
  margin: -6px 0 14px;
  line-height: 1.5;
}

.settings-btn {
  width: 100%;
  background: var(--green);
  color: #000;
  border: none;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
  transition: var(--ease);
  margin-bottom: 14px;
}
.settings-btn:active { transform: scale(0.98); }
.settings-btn:disabled { background: var(--surface-3); color: var(--text-muted); cursor: not-allowed; transform: none; }
.settings-btn.subtle {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-2);
}
.settings-btn.danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255,71,87,0.3);
}

.cat-mgmt-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.cat-mgmt-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cat-mgmt-emoji { font-size: 18px; }
.cat-mgmt-name { font-size: 14px; font-weight: 700; flex: 1; }
.cat-mgmt-count {
  background: var(--surface-3);
  color: var(--text-muted);
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
}
.cat-mgmt-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 12px 14px;
}
.cat-mgmt-group.open .cat-mgmt-body { display: block; }
.cat-mgmt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.cat-mgmt-item:last-child { border-bottom: none; }
.cat-mgmt-item-name { color: var(--text); }
.cat-mgmt-item-rm {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  -webkit-tap-highlight-color: transparent;
}
.cat-mgmt-item-rm:hover, .cat-mgmt-item-rm:active { color: var(--red); }
.cat-mgmt-add {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.cat-mgmt-add input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  outline: none;
}
.cat-mgmt-add input:focus { border-color: var(--green); }
.cat-mgmt-add button {
  background: var(--green);
  color: #000;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.add-group-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}
.add-group-row input {
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  outline: none;
}
.add-group-row input:focus { border-color: var(--green); }
.add-group-row input.emoji-in { text-align: center; font-size: 18px; }
.add-group-row button {
  background: var(--green);
  color: #000;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 800;
}

.export-row { display: flex; gap: 8px; }
.export-row .settings-btn { margin-bottom: 0; }

.settings-meta {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin: 24px 0 8px;
  line-height: 1.6;
}

/* ============================================================
   DESKTOP FRAME
   ============================================================ */
@media (min-width: 431px) {
  body {
    background: #040811;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
  }
  #app {
    height: 90vh;
    max-height: 900px;
    border-radius: var(--radius);
    border: 1px solid var(--border-2);
    box-shadow: 0 32px 100px rgba(0,0,0,0.85), 0 0 0 1px rgba(255,255,255,0.03);
    overflow: hidden;
  }
}
