*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:       #9fd34c;
  --green-dark:  #388e3c;
  --green-light: #e8f5e9;
  --accent:      #ff5722;
  --text:        #222;
  --muted:       #777;
  --border:      #e0e0e0;
  --bg:          #f4f6f3;
  --white:       #ffffff;
  --shadow:      0 2px 12px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── LOGO ─────────────────────────────────────────────────────────────────── */
.logo {
  text-align: center;
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
  margin-bottom: .3rem;
}
.logo-w {
  color: black;
  font-size: 1.1em;
}
.tagline {
  text-align: center;
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 1.4rem;
}
.nav-logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -.5px;
  flex: 1;
}

/* ── AUTH ─────────────────────────────────────────────────────────────────── */
.screen { min-height: 100vh; }

.card {
  max-width: 400px;
  margin: 60px auto;
  background: var(--white);
  padding: 2.2rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.tabs { display: flex; gap: .5rem; margin-bottom: 1.2rem; }
.tab {
  flex: 1; padding: .65rem;
  border: 2px solid var(--green);
  border-radius: 8px; cursor: pointer;
  background: var(--white); color: var(--green);
  font-size: 1rem; font-weight: 600; transition: .2s;
}
.tab.active { background: var(--green); color: var(--white); }

form { display: flex; flex-direction: column; gap: .8rem; }

input, select {
  padding: .75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: border .2s;
  background: var(--white);
  width: 100%;
}
input:focus, select:focus { border-color: var(--green); }

button {
  padding: .75rem 1.2rem;
  background: var(--green);
  color: var(--white);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: background .2s, transform .1s;
}
button:hover   { background: var(--green-dark); }
button:active  { transform: scale(.98); }

.btn-cancel {
  background: #f5f5f5;
  color: var(--text);
}
.btn-cancel:hover { background: #e0e0e0; }

.msg { margin-top: .8rem; text-align: center; font-size: .9rem; }
.msg.error { color: #e53935; }
.msg.ok    { color: var(--green); }

/* ── NAV ──────────────────────────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.5rem;
  background: var(--green);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  position: sticky;
  top: 0;
  z-index: 50;
}
nav button {
  background: rgba(255,255,255,.2);
  font-size: .9rem;
  padding: .4rem .9rem;
  white-space: nowrap;
}
nav button:hover { background: rgba(255,255,255,.35); }
#nav-user { font-size: .9rem; opacity: .9; white-space: nowrap; }

/* ── MOBILE BAR ───────────────────────────────────────────────────────────── */
.mobile-bar {
  display: none;
  align-items: center;
  gap: .8rem;
  padding: .6rem 1rem;
  background: var(--green-light);
  border-bottom: 1px solid var(--border);
}
.mobile-bar button {
  background: var(--green);
  color: var(--white);
  padding: .4rem .8rem;
  font-size: .9rem;
  border-radius: 8px;
}
#mobile-group-name {
  font-weight: 600;
  color: var(--green-dark);
  font-size: .95rem;
}

/* ── LAYOUT ───────────────────────────────────────────────────────────────── */
.main {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1100px;
  margin: auto;
  align-items: flex-start;
}

aside {
  width: 240px;
  min-width: 240px;
  background: var(--white);
  border-radius: 14px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 70px;
}
aside h3 { margin-bottom: .8rem; color: var(--green); font-size: 1rem; }
aside > button { width: 100%; margin-bottom: .8rem; }

#group-list { list-style: none; display: flex; flex-direction: column; gap: .3rem; }
#group-list li {
  padding: .65rem .9rem;
  border-radius: 9px;
  cursor: pointer;
  transition: .15s;
  font-size: .95rem;
}
#group-list li:hover  { background: var(--green-light); color: var(--green-dark); }
#group-list li.active { background: var(--green); color: var(--white); font-weight: 600; }

/* ── GROUP SECTION ────────────────────────────────────────────────────────── */
section {
  flex: 1;
  background: var(--white);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  min-width: 0;
}

.group-header {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: 1.3rem;
  flex-wrap: wrap;
}
.group-header h2 { flex: 1; font-size: 1.4rem; min-width: 0; }
.group-header button {
  background: var(--green-light);
  color: var(--green-dark);
  font-size: .88rem;
  padding: .5rem .9rem;
  white-space: nowrap;
}
.group-header button:hover { background: var(--green); color: var(--white); }

/* ── PANELS ───────────────────────────────────────────────────────────────── */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.panels h3 {
  margin-bottom: .8rem;
  color: var(--muted);
  font-size: .95rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  padding-bottom: .4rem;
}

ul { list-style: none; display: flex; flex-direction: column; gap: .5rem; }

li.expense-item, li.balance-item {
  padding: .75rem;
  background: #fafafa;
  border-radius: 10px;
  font-size: .92rem;
  border: 1px solid var(--border);
}
.expense-item .title { font-weight: 600; }
.expense-item .meta  { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.gbp-note            { color: var(--muted); font-size: .8rem; font-weight: 400; }

.balance-item.positive { border-left: 4px solid #43a047; }
.balance-item.negative { border-left: 4px solid #e53935; }
.balance-item.zero     { border-left: 4px solid #bbb; }
.balance-item.neutral  {
  border-left: 4px solid var(--green);
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settle-btn {
  background: #43a047;
  font-size: .78rem;
  padding: .25rem .6rem;
  border-radius: 6px;
  white-space: nowrap;
  margin-left: .5rem;
  flex-shrink: 0;
}
.settle-btn:hover { background: var(--green-dark); }

/* ── EMPTY STATE ──────────────────────────────────────────────────────────── */
#empty-state { flex: 1; display: flex; align-items: center; justify-content: center; }
.empty-box {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--muted);
}
.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-box p { font-size: 1rem; }

/* ── MODAL ────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-box {
  background: var(--white);
  border-radius: 16px;
  padding: 1.8rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.modal-box h3 { color: var(--green); font-size: 1.2rem; }

.amount-row { display: flex; gap: .5rem; }
.amount-row input  { flex: 1; }
.amount-row select { width: 110px; flex-shrink: 0; }

.fx-info {
  font-size: .8rem;
  color: var(--muted);
  min-height: 1.2em;
  padding: .3rem .6rem;
  background: var(--green-light);
  border-radius: 6px;
}

#split-checkboxes {
  display: flex; flex-direction: column; gap: .4rem;
  max-height: 160px; overflow-y: auto;
  padding: .4rem;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid var(--border);
}
#split-checkboxes label {
  display: flex; align-items: center; gap: .5rem;
  font-size: .95rem; padding: .2rem 0; cursor: pointer;
}

/* ── UTILITIES ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 768px) {
  .main {
    padding: 1rem;
    gap: 1rem;
    flex-direction: column;
  }

  aside {
    width: 100%;
    min-width: unset;
    position: static;
    display: none; /* hidden by default on mobile, toggled */
  }
  aside.open { display: block; }

  .mobile-bar { display: flex; }

  .panels {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .group-header h2 { font-size: 1.2rem; }
  .group-header button { font-size: .82rem; padding: .4rem .7rem; }

  section { padding: 1rem; }
}

/* Mobile */
@media (max-width: 480px) {
  .card {
    margin: 20px 1rem;
    padding: 1.5rem 1.2rem;
  }
  .logo { font-size: 2rem; }

  nav { padding: .7rem 1rem; }
  nav button { padding: .35rem .7rem; font-size: .85rem; }

  .main { padding: .75rem; }

  .modal-box { padding: 1.3rem; }

  .amount-row { flex-direction: column; }
  .amount-row select { width: 100%; }

  .group-header { gap: .5rem; }
  .group-header button { width: 100%; }
}

/* Total badge */
.total-badge {
  font-size: .85rem;
  background: var(--green-light);
  color: var(--green-dark);
  padding: .3rem .8rem;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

/* Clickable expense */
.expense-item.clickable { cursor: pointer; transition: background .15s, transform .1s; }
.expense-item.clickable:hover { background: #f0f7f0; transform: translateX(3px); }
.edit-hint { color: var(--green); font-size: .75rem; margin-left: .5rem; opacity: .7; }

/* Field label */
.field-label { font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: -.3rem; }