@font-face {
  font-family: "Be Vietnam Pro";
  src: url("fonts/BeVietnamPro_400Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("fonts/BeVietnamPro_600SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/Lora_600SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

/* Same pink as the app (src/theme.ts) */
:root {
  --bg: #fff5f7;
  --card: #ffffff;
  --sunk: #fbe6ec;
  --ink: #3a2730;
  --ink-soft: #6b4d5a;
  --muted: #9c8590;
  --line: #f2d6df;
  --rose: #e8578a;
  --rose-deep: #c73e70;
  --rose-soft: #fde1ea;
  --plum: #7a3e66;
  --peach-soft: #fdebd2;
  --danger: #c2352b;
  --row: 34px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 "Be Vietnam Pro", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

h1, h2 { font-family: "Lora", Georgia, serif; font-weight: 600; margin: 0; color: var(--ink); }

.btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: 600 14px "Be Vietnam Pro", system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--rose); color: #fff; }
.btn.primary:hover { background: var(--rose-deep); }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn.ghost:hover { background: var(--card); }
.btn:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; }

/* ---------- sign in ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  justify-items: stretch;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 32px 28px;
}
.login-card img { justify-self: center; border-radius: 18px; }
.login-card h1 { font-size: 28px; margin-bottom: 6px; }
.login-card label { display: grid; gap: 6px; text-align: left; font-weight: 600; color: var(--ink-soft); font-size: 13px; }
.login-card input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font: 15px "Be Vietnam Pro", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.login-card input:focus { outline: 2px solid var(--rose); outline-offset: -1px; background: #fff; }
.login-card .btn { justify-content: center; height: 44px; margin-top: 6px; }
.error { min-height: 1.4em; margin: 0; color: var(--danger); font-size: 13px; }

/* ---------- layout ---------- */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: "Lora", Georgia, serif; font-weight: 600; font-size: 18px; }
.brand img { border-radius: 9px; }
.bar-actions { display: flex; align-items: center; gap: 10px; }
.status { font-size: 13px; color: var(--muted); min-width: 90px; text-align: right; }
.status.bad { color: var(--danger); }

.sheet { overflow: auto; padding: 22px 24px 32px; }

.sheet-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 26px; }
.sheet-head .sub { color: var(--muted); margin-top: 2px; }
.sheet-head .big { font-family: "Lora", Georgia, serif; font-size: 26px; font-weight: 600; color: var(--plum); white-space: nowrap; }

/* ---------- the grid ---------- */
.grid {
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-variant-numeric: tabular-nums;
}
.grid th {
  position: sticky;
  top: -22px;
  z-index: 1;
  height: var(--row);
  padding: 0 10px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--plum);
  background: var(--rose-soft);
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.grid th:first-child { border-top-left-radius: 13px; }
.grid th:last-child { border-top-right-radius: 13px; border-right: 0; }
.grid td {
  height: var(--row);
  padding: 0;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: middle;
}
.grid td:last-child { border-right: 0; }
.grid tbody tr:hover td { background: #fffafb; }
.grid .num { text-align: right; }
.grid .rownum { width: 40px; text-align: center; font-size: 12px; color: var(--muted); background: var(--bg); }
.grid .cell { display: block; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grid input, .grid select {
  display: block;
  width: 100%;
  height: calc(var(--row) - 1px);
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font: inherit;
  color: inherit;
}
.grid select { cursor: pointer; appearance: none; }
.grid select.none { color: var(--muted); }
.grid input[type="checkbox"] { width: 16px; height: 16px; margin: 0 auto; accent-color: var(--rose); cursor: pointer; }
.grid input:focus, .grid select:focus { outline: 2px solid var(--rose); outline-offset: -2px; background: #fff; }
.grid input.money { text-align: right; }
.grid input.bad { outline: 2px solid var(--danger); outline-offset: -2px; }
.grid input::placeholder { color: var(--muted); }
.grid tr.fresh td { background: var(--bg); }
.grid tr.saving td { color: var(--muted); }

.grid tfoot td {
  height: 38px;
  padding: 0 10px;
  font-weight: 600;
  color: var(--plum);
  background: var(--rose-soft);
  border-bottom: 0;
}
.grid tfoot td:first-child { border-bottom-left-radius: 13px; }
.grid tfoot td:last-child { border-bottom-right-radius: 13px; }

.del {
  width: 34px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}
tr:hover .del, .del:focus-visible { opacity: 1; }
.del:hover { color: var(--danger); }

.link {
  border: 0;
  padding: 0 10px;
  height: var(--row);
  width: 100%;
  text-align: left;
  background: transparent;
  font: 600 14px "Be Vietnam Pro", system-ui, sans-serif;
  color: var(--rose-deep);
  cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* ---------- money split under the grid ---------- */
.settle { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.settle .box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; min-width: 170px; }
.settle .box .k { font-size: 12px; color: var(--muted); }
.settle .box .v { font-weight: 600; font-size: 16px; }
.settle .box.hl { background: var(--peach-soft); border-color: transparent; }

.hint { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ---------- sheet tabs, like the bottom of a spreadsheet ---------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  overflow-x: auto;
  background: var(--sunk);
  border-top: 1px solid var(--line);
}
.tab {
  flex: none;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 0 0 12px 12px;
  background: transparent;
  font: 14px "Be Vietnam Pro", system-ui, sans-serif;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: rgba(255, 255, 255, 0.55); }
.tab[aria-selected="true"] { background: var(--card); color: var(--rose-deep); font-weight: 600; box-shadow: inset 0 2px 0 var(--rose); }
.tab:focus-visible { outline: 2px solid var(--plum); outline-offset: -2px; }

@media (max-width: 720px) {
  .bar { padding: 8px 12px; }
  .brand span { display: none; }
  .sheet { padding: 16px 12px 24px; }
  .status { display: none; }
}
