/* Wardroom Bill — Everforest theme (dark hard / light medium) */
:root {
  --bg0: #2d353b; --bg1: #343f44; --bg2: #3d484d; --bg3: #475258; --bg4: #4f585e;
  --fg: #d3c6aa;
  --grey0: #7a8478; --grey1: #859289; --grey2: #9da9a0;
  --red: #e67e80; --orange: #e69875; --yellow: #dbbc7f;
  --green: #a7c080; --aqua: #83c092; --blue: #7fbbb3; --purple: #d699b6;
  --on-accent: #2d353b;
  --shadow: rgba(0, 0, 0, .4);
  --radius: 14px;
}
[data-theme="light"] {
  --bg0: #fdf6e3; --bg1: #f4f0d9; --bg2: #efebd4; --bg3: #e6e2cc; --bg4: #e0dcc7;
  --fg: #5c6a72;
  --grey0: #a6b0a0; --grey1: #939f91; --grey2: #829181;
  --red: #f85552; --orange: #f57d26; --yellow: #dfa000;
  --green: #8da101; --aqua: #35a77c; --blue: #3a94c5; --purple: #df69ba;
  --on-accent: #fdf6e3;
  --shadow: rgba(92, 106, 114, .25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  margin: 0;
  background: var(--bg0);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--grey1); }
.spacer { flex: 1; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--bg0);
  border-bottom: 1px solid var(--bg3);
}
.app-header h1 { margin: 0; font-size: 1.25rem; color: var(--green); letter-spacing: .3px; }
.app-header p { margin: 2px 0 0; font-size: .85rem; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--bg2); border: 1px solid var(--bg3); font-size: 1.2rem;
}

main { max-width: 560px; margin: 0 auto; padding: 14px 14px calc(96px + env(safe-area-inset-bottom)); }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--bg1); border-top: 1px solid var(--bg3);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px 8px; background: none; border: 0; color: var(--grey1); font-size: .78rem;
}
.tab-ico { font-size: 1.25rem; }
.tab.active { color: var(--green); font-weight: 600; }

/* Cards & text */
.card {
  background: var(--bg1); border: 1px solid var(--bg3);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.section-title {
  margin: 20px 4px 8px; font-size: .8rem; letter-spacing: 1px;
  text-transform: uppercase; color: var(--aqua); font-weight: 600;
}
.section-title:first-child { margin-top: 4px; }
.hint {
  background: var(--bg2); border-left: 4px solid var(--yellow);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: .92rem;
}
.empty { text-align: center; padding: 18px 8px; color: var(--grey1); }

/* Date / month bar */
.datebar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.datebar .btn-sq { flex: 0 0 44px; }
.datebar .date-mid { flex: 1; text-align: center; min-width: 0; }
.date-mid .big { font-weight: 600; font-size: 1.05rem; }
.date-mid input[type="date"] {
  width: 100%; text-align: center; background: var(--bg2); border: 1px solid var(--bg3);
  border-radius: 10px; padding: 8px; margin-top: 4px;
}

/* Totals */
.total-card { text-align: center; background: var(--bg2); }
.total-card .label { font-size: .85rem; color: var(--grey2); }
.total-card .amount { font-size: 2.1rem; font-weight: 700; color: var(--yellow); margin-top: 2px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.stat { background: var(--bg1); border-radius: 10px; padding: 8px; }
.stat .s-label { font-size: .75rem; color: var(--grey1); }
.stat .s-val { font-weight: 600; color: var(--blue); }

/* Rows */
.list { background: var(--bg1); border: 1px solid var(--bg3); border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--bg3);
}
.row:last-child { border-bottom: 0; }
.row.active { background: var(--bg2); }
.row-info { flex: 1; min-width: 0; }
.row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: .85rem; color: var(--grey1); }
.row.active .row-sub { color: var(--aqua); }
.row-end { font-weight: 600; color: var(--yellow); white-space: nowrap; }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 42px; height: 42px; border-radius: 50%; font-size: 1.4rem; line-height: 1;
  background: var(--bg3); border: 0; color: var(--fg);
}
.stepper button[data-act="inc"] { background: var(--green); color: var(--on-accent); font-weight: 700; }
.stepper button:disabled { opacity: .35; }
.stepper .qty { min-width: 28px; text-align: center; font-weight: 700; font-size: 1.1rem; }

/* Buttons & inputs */
.btn {
  background: var(--bg3); border: 0; border-radius: 10px; padding: 11px 16px;
  min-height: 44px; font-weight: 600;
}
.btn-primary { background: var(--green); color: var(--on-accent); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-block { width: 100%; }
.btn-sq { background: var(--bg2); border: 1px solid var(--bg3); border-radius: 10px; height: 44px; font-size: 1.2rem; }

label { display: block; font-size: .8rem; color: var(--grey2); margin: 12px 0 4px; }
input[type="text"], input[type="number"], input[type="date"] {
  width: 100%; background: var(--bg2); border: 1px solid var(--bg4);
  border-radius: 10px; padding: 11px 12px; min-height: 44px; outline: none;
}
input:focus { border-color: var(--green); }
.inline-form { display: flex; gap: 8px; }
.inline-form input[type="text"] { flex: 2; min-width: 0; }
.inline-form input[type="number"] { flex: 1; min-width: 0; }
.inline-form .btn { padding: 0 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* Bill details */
details { background: var(--bg1); border: 1px solid var(--bg3); border-radius: var(--radius); margin-bottom: 8px; }
summary {
  list-style: none; display: flex; justify-content: space-between; align-items: center;
  padding: 12px; font-weight: 600; cursor: pointer;
}
summary::-webkit-details-marker { display: none; }
summary .d-total { color: var(--yellow); }
details .d-body { padding: 0 12px 12px; }
.d-line { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: .92rem; color: var(--grey2); }
.d-line span:last-child { color: var(--fg); white-space: nowrap; }
.link-btn { background: none; border: 0; color: var(--blue); padding: 8px 0 0; font-weight: 600; }

/* Bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.sheet-body {
  position: relative; width: 100%; max-width: 560px; background: var(--bg1);
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px var(--shadow);
}
.sheet-body h2 { margin: 0 0 4px; font-size: 1.1rem; color: var(--green); }
.sheet-actions { display: flex; gap: 8px; margin-top: 18px; align-items: center; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 40;
  background: var(--bg4); color: var(--fg); padding: 10px 16px; border-radius: 999px;
  box-shadow: 0 4px 16px var(--shadow); transition: .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
