/* ============================================
   HR Lunch — "Receipt" design system
   Palette: paper cream, tomato, leaf green,
   mustard, charcoal. Money is monospace.
   ============================================ */
:root {
  --paper:      #FBF6EC;
  --paper-deep: #F3EBDA;
  --ink:        #2B2620;
  --ink-soft:   #6E6558;
  --tomato:     #E8503A;
  --tomato-dk:  #C93A26;
  --leaf:       #2E7D4F;
  --leaf-soft:  #E3F0E8;
  --mustard:    #D9930D;
  --mustard-soft:#FBF0D7;
  --card:       #FFFFFF;
  --line:       #E5DCC9;
  --radius:     14px;
  --font-display: 'Fredoka', sans-serif;
  --font-body:  'Inter', sans-serif;
  --font-money: 'JetBrains Mono', monospace;
  --shadow: 0 2px 6px rgba(43,38,32,.07), 0 8px 24px rgba(43,38,32,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  background-image: radial-gradient(rgba(43,38,32,.035) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; }
a { color: var(--tomato-dk); text-decoration: none; }

/* ---------- Nav ---------- */
.topnav {
  display: flex; align-items: center; gap: 20px;
  background: var(--card);
  border-bottom: 3px dashed var(--line);
  padding: 12px 22px;
  position: sticky; top: 0; z-index: 50;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.3rem; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.brand span:last-child { color: var(--tomato); }
.brand-plate { font-size: 1.4rem; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  color: var(--ink-soft); font-weight: 500; font-size: .92rem;
  padding: 7px 13px; border-radius: 999px;
}
.nav-links a:hover { background: var(--paper-deep); color: var(--ink); }
.nav-links a.active { background: var(--ink); color: var(--paper); }
.nav-user { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.nav-name { font-weight: 600; font-size: .9rem; white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.logout {
  font-size: .78rem; font-weight: 600; color: var(--tomato-dk);
  border: 2px solid var(--line); border-radius: 999px;
  padding: 5px 12px; white-space: nowrap;
}
.logout:hover { border-color: var(--tomato); background: #FBE3DE; }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1060px; margin: 0 auto; padding: 28px 20px 60px; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.7rem; }
.page-sub { color: var(--ink-soft); font-size: .93rem; margin-top: 3px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2 { font-size: 1.1rem; margin-bottom: 14px; }

/* Receipt card — the signature */
.receipt {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 18px 20px 24px;
  position: relative;
  font-family: var(--font-money);
}
.receipt::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 10px;
  background:
    linear-gradient(-45deg, transparent 66%, var(--paper) 67%) 0 100%/12px 12px repeat-x,
    linear-gradient(45deg, transparent 66%, var(--paper) 67%) 0 100%/12px 12px repeat-x;
}
.receipt-head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 2px dashed var(--line);
  padding-bottom: 10px; margin-bottom: 10px;
}
.receipt-date { font-size: .78rem; color: var(--ink-soft); letter-spacing: .05em; text-transform: uppercase; }
.receipt-amount { font-weight: 700; font-size: 1.25rem; }
.receipt-row { display: flex; justify-content: space-between; font-size: .84rem; padding: 3px 0; color: var(--ink-soft); }
.receipt-row .who { color: var(--ink); }
.receipt-note { font-family: var(--font-body); font-size: .85rem; color: var(--ink-soft); margin-top: 8px; font-style: italic; }
.receipt-payer { font-family: var(--font-body); font-size: .88rem; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.receipt-payer b { color: var(--leaf); }

/* ---------- Balance chips ---------- */
.balance-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.bal {
  display: flex; align-items: center; gap: 12px;
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}
.bal .amt { font-family: var(--font-money); font-weight: 700; font-size: 1.05rem; margin-left: auto; }
.bal-owe   { border-left: 5px solid var(--tomato); }
.bal-owe   .amt { color: var(--tomato-dk); }
.bal-owed  { border-left: 5px solid var(--leaf); }
.bal-owed  .amt { color: var(--leaf); }
.bal .dir { font-size: .78rem; color: var(--ink-soft); display: block; }
.all-clear {
  text-align: center; padding: 34px 20px; color: var(--leaf);
  font-family: var(--font-display); font-size: 1.15rem;
}

/* ---------- Avatars ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--av, var(--tomato));
  color: #fff; font-weight: 700; font-family: var(--font-body); flex-shrink: 0;
}
.avatar-sm { width: 30px; height: 30px; font-size: .7rem; }
.avatar-md { width: 40px; height: 40px; font-size: .85rem; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-display); font-weight: 600; font-size: .95rem;
  background: var(--tomato); color: #fff;
  border: 0; border-radius: 999px;
  padding: 10px 22px; cursor: pointer;
  box-shadow: 0 3px 0 var(--tomato-dk);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:hover { transform: translateY(1px); box-shadow: 0 2px 0 var(--tomato-dk); }
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn-green { background: var(--leaf); box-shadow: 0 3px 0 #1F5C39; }
.btn-green:hover { box-shadow: 0 2px 0 #1F5C39; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-sm { padding: 6px 14px; font-size: .84rem; }
.btn:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; }

label { display: block; font-weight: 600; font-size: .87rem; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: 11px 13px;
  border: 2px solid var(--line); border-radius: 10px;
  background: #fff; font-family: var(--font-body); font-size: .95rem;
  transition: border-color .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--mustard); }
.amount-input { font-family: var(--font-money); font-weight: 700; font-size: 1.1rem; }

/* participants checkbox grid */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 6px; }
.person-check { position: relative; }
.person-check input { position: absolute; opacity: 0; }
.person-check label {
  display: flex; align-items: center; gap: 9px; margin: 0;
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px;
  cursor: pointer; background: #fff; font-weight: 500; transition: all .1s;
}
.person-check input:checked + label {
  border-color: var(--leaf); background: var(--leaf-soft);
}
.person-check input:checked + label::after { content: '✓'; margin-left: auto; color: var(--leaf); font-weight: 700; }
.person-check input:focus-visible + label { outline: 3px solid var(--mustard); }
.split-preview {
  margin-top: 14px; padding: 12px 16px; border-radius: 10px;
  background: var(--mustard-soft); border: 1px dashed var(--mustard);
  font-family: var(--font-money); font-weight: 700;
}

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-family: var(--font-display); font-weight: 600;
  font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-soft); padding: 10px 12px; border-bottom: 2px solid var(--line);
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .money { font-family: var(--font-money); font-weight: 700; }

.tag { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.tag-pending  { background: var(--mustard-soft); color: var(--mustard); }
.tag-received { background: var(--leaf-soft); color: var(--leaf); }

/* ---------- Settlement tick ---------- */
.receive-form { display: inline; }
.tickbox {
  display: inline-flex; align-items: center; gap: 8px;
  border: 2px solid var(--leaf); color: var(--leaf);
  background: #fff; border-radius: 999px;
  padding: 6px 16px; font-weight: 600; font-size: .85rem;
  cursor: pointer; font-family: var(--font-body); transition: all .1s;
}
.tickbox:hover { background: var(--leaf); color: #fff; }

/* ---------- Chat ---------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 240px); min-height: 420px; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 10px 4px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 82%; }
.msg-mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 9px 14px; box-shadow: var(--shadow);
  position: relative;
}
.msg-mine .msg-bubble { background: var(--leaf-soft); border-color: #CBE3D4; }
.msg-meta { font-size: .72rem; color: var(--ink-soft); margin-bottom: 2px; }
.msg-body { font-size: .93rem; white-space: pre-wrap; word-break: break-word; }
.msg-reactions { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.react-chip {
  font-size: .78rem; background: var(--paper-deep); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 8px; cursor: pointer; user-select: none;
}
.react-chip.on { background: var(--mustard-soft); border-color: var(--mustard); }
.react-add { opacity: .55; }
.react-picker {
  position: absolute; bottom: calc(100% + 6px); left: 0; display: none;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 10px; box-shadow: var(--shadow); gap: 6px; z-index: 5;
}
.react-picker.open { display: flex; }
.react-picker span { cursor: pointer; font-size: 1.15rem; }
.chat-form { display: flex; gap: 10px; padding-top: 14px; border-top: 2px dashed var(--line); }
.chat-form input { flex: 1; }

/* ---------- Reports ---------- */
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 8px 18px; border-radius: 999px; border: 2px solid var(--line);
  background: #fff; font-weight: 600; font-size: .88rem; color: var(--ink-soft);
}
.pill.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.stat-big { font-family: var(--font-money); font-size: 1.7rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.bar-row { display: flex; align-items: center; gap: 12px; margin: 9px 0; }
.bar-name { width: 110px; font-size: .88rem; font-weight: 600; flex-shrink: 0; }
.bar-track { flex: 1; height: 22px; background: var(--paper-deep); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--mustard); border-radius: 6px; min-width: 2px; }
.bar-val { font-family: var(--font-money); font-size: .82rem; font-weight: 700; width: 90px; text-align: right; }

/* ---------- Auth ---------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border-radius: 6px; border: 1px solid var(--line);
  box-shadow: var(--shadow); padding: 34px 30px 42px; position: relative;
}
.auth-card::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 12px;
  background:
    linear-gradient(-45deg, transparent 66%, var(--paper) 67%) 0 100%/14px 14px repeat-x,
    linear-gradient(45deg, transparent 66%, var(--paper) 67%) 0 100%/14px 14px repeat-x;
}
.auth-logo { text-align: center; font-size: 2.6rem; }
.auth-card h1 { text-align: center; font-size: 1.5rem; margin: 6px 0 2px; }
.auth-tag { text-align: center; color: var(--ink-soft); font-size: .88rem; margin-bottom: 10px; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 20px; }
.g-recaptcha { margin-top: 16px; }

/* ---------- Misc ---------- */
.flash { padding: 12px 18px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.flash-ok { background: var(--leaf-soft); color: var(--leaf); border: 1px solid #CBE3D4; }
.flash-err { background: #FBE3DE; color: var(--tomato-dk); border: 1px solid #F2C4BB; }
.empty { text-align: center; color: var(--ink-soft); padding: 40px 10px; font-size: .95rem; }
.footer { text-align: center; color: var(--ink-soft); font-size: .82rem; padding: 18px; border-top: 3px dashed var(--line); }
.mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; }

/* ---------- Bottom nav (mobile app-style) ---------- */
.bottomnav { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .nav-name { max-width: 90px; font-size: .82rem; }
  .topnav { padding: 10px 14px; gap: 10px; }
  .container { padding-bottom: 110px; }
  .footer { display: none; }
  .chat-wrap { height: calc(100vh - 320px); }

  .bottomnav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--card);
    border-top: 3px dashed var(--line);
    padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
    box-shadow: 0 -4px 16px rgba(43,38,32,.08);
  }
  .bottomnav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    flex: 1; min-width: 0;
    color: var(--ink-soft); font-size: .62rem; font-weight: 600;
    padding: 4px 2px; border-radius: 10px;
  }
  .bottomnav a .bn-ico { font-size: 1.25rem; line-height: 1.2; }
  .bottomnav a.active { color: var(--tomato-dk); background: var(--paper-deep); }
  .bottomnav a.bn-add .bn-ico {
    background: var(--tomato); color: #fff;
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700;
    margin-top: -18px;
    box-shadow: 0 3px 0 var(--tomato-dk), 0 4px 12px rgba(232,80,58,.4);
    border: 3px solid var(--paper);
  }
  .bottomnav a.bn-add.active .bn-ico { background: var(--tomato-dk); }
}
