:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --text: #e8eaee;
  --muted: #8a93a3;
  --accent: #ffd24d;
  --positive: #46d39a;
  --negative: #ff7676;
  --border: #2a2f3a;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* The hidden attribute must win over any display the classes set (e.g. flex). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.jar {
  background: linear-gradient(160deg, #2a2206 0%, var(--surface) 70%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.jar__title {
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.jar__balance {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.jar__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.jar__sync {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.jar__sync input[type='date'] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  font-family: inherit;
  color-scheme: dark;
}

.jar__status {
  margin-top: 12px;
  color: var(--positive);
  font-size: 13px;
}

.jar__error {
  margin-top: 12px;
  color: var(--negative);
  font-size: 13px;
}

button {
  background: var(--accent);
  color: #1a1500;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}

button:hover { opacity: 0.9; }
button:active { transform: scale(0.98); }
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tx h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 500;
}

.tx__filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.tx__filter input[type='date'] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  font-family: inherit;
  color-scheme: dark;
}

.tx__filter-reset {
  background: var(--surface-2);
  color: var(--text);
}

.tx__totals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tx__total {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
}

.tx__total span {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tx__total--in span { color: var(--positive); }
.tx__total--out span { color: var(--negative); }

.tx__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tx__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.tx__desc {
  font-weight: 500;
  word-break: break-word;
}

.tx__amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.tx__amount--pos { color: var(--positive); }
.tx__amount--neg { color: var(--text); }

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

.tx__balance {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.tx__comment {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.tx__extras {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

/* Both sections re-render themselves; their children flow in the extras row. */
.tx__note-wrap,
.tx__attachments {
  display: contents;
}

.tx__note {
  flex: 1 0 100%;
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 6px 10px;
  font-size: 13px;
}

.tx__note-label {
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tx__note-text {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
}

.tx__note-btn {
  background: none;
  color: var(--muted);
  padding: 0 4px;
  font-size: 13px;
  line-height: 1;
}

.tx__note-btn:hover { color: var(--text); }

.tx__note-editor {
  flex: 1 0 100%;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.tx__note-input {
  flex: 1;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

.tx__note-save,
.tx__note-cancel {
  padding: 6px 12px;
  font-size: 13px;
}

.tx__note-cancel {
  background: var(--surface-2);
  color: var(--text);
}

.tx__att {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 4px 2px 10px;
  font-size: 12px;
  max-width: 100%;
}

.tx__att a {
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.tx__att a:hover { text-decoration: underline; }

.tx__att-del {
  background: none;
  color: var(--muted);
  padding: 0 6px;
  font-size: 14px;
  line-height: 1;
}

.tx__att-del:hover { color: var(--negative); }

.tx__att-add,
.tx__note-add {
  background: none;
  border: 1px dashed var(--border);
  color: var(--muted);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
}

#moreBtn {
  display: block;
  margin: 16px auto 0;
  background: var(--surface-2);
  color: var(--text);
}

.tx__empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 0;
}

.login {
  background: linear-gradient(160deg, #2a2206 0%, var(--surface) 70%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  margin-top: 15vh;
  text-align: center;
}

.login__title {
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.login__form {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.login__form input {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  width: 220px;
}

.login__error {
  margin-top: 12px;
  color: var(--negative);
  font-size: 13px;
}

.jar__logout {
  background: none;
  color: var(--muted);
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
}

.jar__logout:hover { color: var(--text); }

.admin {
  margin-top: 24px;
}

.admin h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 500;
}

.admin__list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin__item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 14px;
}

.admin__label {
  flex: 1;
  word-break: break-word;
}

.admin__meta {
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin__del {
  background: none;
  color: var(--muted);
  padding: 0 6px;
  font-size: 16px;
  line-height: 1;
}

.admin__del:hover { color: var(--negative); }

.admin__form {
  display: flex;
  gap: 8px;
}

.admin__form input {
  flex: 1;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
}

.admin__new {
  margin-top: 12px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  font-size: 13px;
  word-break: break-all;
}

.admin__new code {
  color: var(--accent);
  font-size: 14px;
  user-select: all;
}
