/* Money app shell. Page art, header, tabs, and cards come from /ui/shell.css.
   These rules only map Money's own pieces onto the kit tokens. */

:root {
  --pos: 142 70% 24%;
  --neg: 0 72% 40%;
  --warn: 38 92% 26%;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark {
  --pos: 142 60% 52%;
  --neg: 0 80% 66%;
  --warn: 38 92% 58%;
}

body.dx {
  background: transparent;
  color: var(--dx-text);
  font-family: var(--dx-font);
}

[hidden] {
  display: none !important;
}

.app-skip {
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  z-index: 100;
  padding: 0.5rem 0.75rem;
  border-radius: var(--dx-radius-sm);
  background: var(--dx-accent);
  color: var(--dx-primary-fg);
  transform: translateY(-200%);
}

.app-skip:focus {
  transform: none;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: transparent;
  min-width: 0;
}

code {
  font-size: 0.88em;
  padding: 0.05rem 0.3rem;
  border-radius: 6px;
  background: var(--dx-primary-soft);
}

.app-main a:not(.btn):not(.dx-btn),
.banner a {
  color: var(--dx-accent);
}

/* Header extras: sync status sits under the title so 360px still fits. */

.dx-heading {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}

.dx-header .dx-title {
  flex: none;
}

.topbar-sync {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  margin: 0;
  color: var(--dx-muted);
  font-size: 0.72rem;
  font-weight: 600;
}

#sync-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  flex: 0 0 auto;
  background: var(--dx-accent);
}

.topbar-sync-ok .topbar-dot { background: hsl(var(--pos)); }
.topbar-sync-off .topbar-dot { background: hsl(var(--neg)); }
.topbar-sync-demo .topbar-dot { background: hsl(var(--warn)); }
.topbar-sync-busy .topbar-dot { animation: pulse 1.2s var(--ease) infinite; }

@keyframes pulse {
  50% { opacity: 0.3; }
}

.dx-header .btn-icon {
  color: var(--dx-text);
}

.dx-header .dong-theme-toggle {
  position: static;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.dx-header .dong-theme-toggle__track {
  width: 2.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid var(--dx-border);
  background: var(--dx-card);
}

/* Layout */

.app-main {
  flex: 1;
  outline: none;
  min-width: 0;
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--dx-gap);
  min-width: 0;
}

.banner {
  width: min(720px, calc(100% - 24px));
  margin: 8px auto 0;
  color: var(--dx-text);
  font-size: 0.85rem;
  text-align: center;
}

.banner a {
  color: inherit;
  font-weight: 650;
}

/* Buttons and fields */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 0.95rem;
  border-radius: var(--dx-radius-sm);
  border: 1px solid transparent;
  background: var(--dx-accent);
  color: var(--dx-primary-fg);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  background: var(--dx-card);
  color: var(--dx-text);
  border-color: var(--dx-border);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--dx-radius-sm);
  border: 0;
  background: transparent;
  color: var(--dx-text);
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--dx-primary-soft);
}

.btn:focus-visible,
.btn-icon:focus-visible,
.chip:focus-visible,
.bar-col:focus-visible {
  outline: 2px solid var(--dx-ring);
  outline-offset: 2px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.75rem 0;
}

.field-label,
.label {
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dx-muted);
}

.field input,
.field select {
  height: 44px;
  padding: 0 0.7rem;
  border-radius: var(--dx-radius-sm);
  border: 1px solid var(--dx-border);
  background: var(--dx-card-solid);
  color: var(--dx-text);
  font: inherit;
  font-size: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---- Shared view primitives ---- */

.card {
  padding: var(--dx-gap);
  border-radius: var(--dx-radius);
  background: var(--dx-card);
  color: var(--dx-text);
  border: 1px solid var(--dx-border);
  box-shadow: var(--dx-shadow);
  min-width: 0;
  max-width: 100%;
  -webkit-backdrop-filter: blur(var(--dx-blur));
  backdrop-filter: blur(var(--dx-blur));
}

.card-title {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.card-head .card-title {
  margin: 0;
}

.muted {
  margin: 0;
  color: var(--dx-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.small {
  font-size: 0.78rem;
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tone-pos { color: hsl(var(--pos)); }
.tone-neg { color: hsl(var(--neg)); }
.tone-zero { color: var(--dx-text); }
.tone-unknown { color: var(--dx-muted); }

.notice {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--dx-radius-sm);
  font-size: 0.88rem;
  line-height: 1.45;
}

.notice-error {
  background: hsl(var(--neg) / 0.1);
  border: 1px solid hsl(var(--neg) / 0.35);
  color: var(--dx-text);
}

.notice-error p {
  margin: 0 0 0.6rem;
}

.empty {
  text-align: center;
  border-style: dashed;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-big {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: normal;
}

.chips {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
  padding-bottom: 0.1rem;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--dx-border);
  background: var(--dx-card-solid);
  color: var(--dx-text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  background: var(--dx-accent);
  border-color: var(--dx-accent);
  color: var(--dx-primary-fg);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--dx-primary-soft);
  color: var(--dx-muted);
  white-space: nowrap;
}

.badge-active { background: hsl(var(--pos) / 0.15); color: hsl(var(--pos)); }
.badge-review,
.badge-partial { background: hsl(var(--warn) / 0.16); color: hsl(var(--warn)); }
.badge-ended { background: var(--dx-primary-soft); color: var(--dx-muted); }

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--dx-border);
}

.row:first-child {
  border-top: 0;
}

.row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.row-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-end {
  flex: 0 0 auto;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}

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

.table th,
.table td {
  padding: 0.45rem 0.15rem;
  text-align: right;
  border-top: 1px solid var(--dx-border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table th:first-child,
.table td:first-child {
  text-align: left;
}

.table thead th {
  border-top: 0;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dx-muted);
}

.table tr.is-total td {
  font-weight: 700;
}

.progress {
  position: relative;
  height: 0.85rem;
  border-radius: 999px;
  background: var(--dx-primary-soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: hsl(var(--pos));
  transition: width 400ms var(--ease);
}

.progress-fill.is-alt {
  background: var(--dx-accent);
}

.bars {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  height: 9rem;
  max-width: 100%;
  overflow-x: auto;
}

.bar-col {
  flex: 1 0 44px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.bar-stack {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  border-bottom: 1px solid var(--dx-border);
}

.bar {
  width: 0.6rem;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: color-mix(in srgb, var(--dx-muted) 50%, transparent);
}

.bar-in { background: hsl(var(--pos)); }
.bar-out { background: hsl(var(--neg)); }
.bar-unknown {
  background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--dx-muted) 35%, transparent) 0 3px, transparent 3px 6px);
}

.bar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  color: var(--dx-muted);
}

.bar-col[aria-pressed="true"] .bar-label {
  color: var(--dx-accent);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--dx-muted);
}

.legend-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.3rem;
  border-radius: 3px;
  vertical-align: -0.05rem;
}

.note-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--dx-muted);
}

@media (max-width: 380px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
