:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-soft: #dbeafe;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --color-bg: #f8fafc;
  --color-card: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-muted: #64748b;
  --radius: 6px;
  --radius-tight: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --shadow-hover: 0 6px 18px rgba(37,99,235,.14);
}

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

body { font-family: system-ui, sans-serif; font-size: 15px; color: var(--color-text); background: var(--color-bg); line-height: 1.6; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ────────────────────────────────────── */
.navbar { position: sticky; top: 0; z-index: 60; background: var(--color-primary); color: #fff; }
.navbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 54px; margin: 0 auto; }
.navbar a { color: #fff; font-weight: 500; }
.navbar a:hover { text-decoration: none; opacity: .9; }
.nav-brand { flex-shrink: 0; }
.nav-brand a { font-size: 1.08rem; font-weight: 700; letter-spacing: .01em; }
.nav-toggle,
.module-nav-toggle { display: none !important; cursor: pointer; }
.nav-toggle { border: 1px solid rgba(255,255,255,.45); background: transparent; color: #fff; font-size: .78rem; font-weight: 700; letter-spacing: .02em; padding: .42rem .72rem; border-radius: 9px; }
.nav-links { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex: 1; }
.main-menu-links { display: flex; align-items: center; gap: .8rem; margin-left: 1rem; }
.main-menu-links a { padding: .22rem .1rem; }
.main-menu-meta { margin-left: auto; }
.welcome { margin-right: .25rem; opacity: .88; font-size: .88rem; }
.lang-switch { display: inline-flex; gap: .45rem; font-size: .8rem; opacity: .92; }
.lang-switch a { opacity: .9; }

.project-subnav-wrap { position: sticky; top: 54px; z-index: 50; background: rgba(247, 250, 255, .96); border-bottom: 1px solid var(--color-border); backdrop-filter: blur(6px); }
.project-subnav-inner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-top: .55rem; padding-bottom: .55rem; margin: 0 auto; }
.project-subnav-title { font-size: .9rem; font-weight: 700; color: var(--color-text); max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Flash ─────────────────────────────────────── */
.flash { padding: .75rem 1.5rem; border-left: 4px solid; margin: 0; }
.flash-success { background: #dcfce7; border-color: var(--color-success); color: var(--color-success); }
.flash-error   { background: #fee2e2; border-color: var(--color-error);   color: var(--color-error);   }

/* ── Container ─────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
main.container { padding-top: 1.5rem; }

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: .55rem 1rem;
  border-radius: var(--radius-tight);
  border: 1px solid var(--color-border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: var(--color-text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}
.btn:hover {
  background: #fff;
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
  text-decoration: none;
  transform: translateY(-1px);
}
.btn-primary {
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-hover);
}
.btn-primary:hover { background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%); color: #fff; }
.btn-danger {
  background: linear-gradient(180deg, var(--color-error) 0%, #b91c1c 100%);
  color: #fff;
  border-color: #b91c1c;
}
.btn-danger:hover { background: linear-gradient(180deg, #b91c1c 0%, #991b1b 100%); color: #fff; }
button.btn { font-family: inherit; }

/* ── Auth card ─────────────────────────────────── */
.auth-card { max-width: 420px; margin: 3rem auto; background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 1.5rem; }
.auth-card p  { margin-top: 1rem; font-size: .9rem; }

/* ── Forms ─────────────────────────────────────── */
form label { display: flex; flex-direction: column; margin-bottom: 1rem; font-size: .9rem; color: var(--color-muted); gap: .3rem; }
form label select,
form label input,
form label textarea { font-size: 1rem; padding: .45rem .7rem; border: 1px solid var(--color-border); border-radius: var(--radius); color: var(--color-text); font-family: inherit; }
form label textarea { resize: vertical; }
form .btn { margin-right: .5rem; margin-top: .5rem; }

.choice-group { margin: 0 0 1rem 0; border: 1px solid var(--color-border); border-radius: var(--radius); padding: .75rem .85rem; }
.choice-group legend { padding: 0 .25rem; color: var(--color-muted); font-size: .9rem; }
.choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem .75rem; }
.choice-option { display: flex; align-items: center; gap: .45rem; margin: 0; color: var(--color-text); }
.choice-option input { width: auto; margin: 0; padding: 0; }

.txn-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 1rem; }
.txn-form-grid .field-span-2 { grid-column: span 2; }
.txn-form-grid .field-span-full { grid-column: span 4; }

/* ── Page header ───────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; }

h1 { font-size: 1.4rem; margin-bottom: 1.25rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }

/* ── Projects grid ─────────────────────────────── */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; margin-top: 1.5rem; }
.project-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.project-card h2 { font-size: 1rem; margin: 0 0 .5rem; }
.project-card .desc { color: var(--color-muted); font-size: .9rem; margin-bottom: .5rem; }
.project-card small { color: var(--color-muted); font-size: .8rem; }

/* ── Project header ────────────────────────────── */
.project-header { margin-bottom: 1.5rem; }
.project-header p { color: var(--color-muted); margin-top: .25rem; }

.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.profile-note { margin-bottom: 1rem; padding: .85rem 1rem; border: 1px solid var(--color-border); background: #f8fbff; border-radius: var(--radius); color: var(--color-muted); }
.checkbox-row { display: flex; flex-direction: row; align-items: center; gap: .65rem; }
.checkbox-row input { width: auto; }
.profile-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 9px; border: 1px solid var(--color-border); }
.profile-thumb-large { width: 96px; height: 96px; margin-bottom: 1rem; }
.profile-photo-preview { margin-bottom: .5rem; }

/* ── Module nav ────────────────────────────────── */
.module-nav { display: flex; gap: .45rem; flex-wrap: wrap; border-bottom: 1px solid var(--color-border); padding-bottom: .65rem; margin-bottom: 1.5rem; }
.module-nav a,
.module-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: .42rem .82rem;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: #1d4ed8;
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  white-space: nowrap;
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}
.module-nav a:hover,
.module-nav-toggle:hover {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e3a8a;
  border-color: #93c5fd;
  text-decoration: none;
  transform: translateY(-1px);
}
.module-nav a.active {
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  border-color: var(--color-primary-dark);
  box-shadow: 0 6px 14px rgba(37,99,235,.18);
}
.module-nav-shared { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; justify-content: flex-end; }

/* ── Data table ────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: 1rem; min-width: 760px; }
.data-table th { text-align: left; padding: .6rem 1rem; background: #f1f5f9; border-bottom: 2px solid var(--color-border); color: var(--color-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.data-table td { padding: .6rem 1rem; border-bottom: 1px solid var(--color-border); }
.data-table tr:hover td { background: #f8fafc; }

.data-table,
.module-nav,
.upload-form { overflow-x: auto; }

/* ── Status badges ─────────────────────────────── */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 9px; font-size: .78rem; font-weight: 600; }
.status-open        { background: #dbeafe; color: #1d4ed8; }
.status-in_progress { background: #fef9c3; color: #854d0e; }
.status-review      { background: #e0e7ff; color: #4338ca; }
.status-done        { background: #dcfce7; color: #16a34a; }
.status-cancelled   { background: #fce7f3; color: #9d174d; }

/* ── Transactions ──────────────────────────────── */
.summary-cards { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.summary { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem 1.5rem; min-width: 160px; box-shadow: var(--shadow); }
.summary span { display: block; font-size: .8rem; color: var(--color-muted); }
.summary strong { display: block; font-size: 1.3rem; font-weight: 700; }
.summary.income  strong { color: var(--color-success); }
.summary.expense strong { color: var(--color-error); }
.txn-income td:nth-child(3) { color: var(--color-success); font-weight: 600; }
.txn-expense td:nth-child(3) { color: var(--color-error); font-weight: 600; }

.tag-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.tag-filters-label { color: var(--color-muted); font-size: .9rem; margin-right: .25rem; }

/* ── Activity log ──────────────────────────────── */
.activity-log { list-style: none; }
.activity-item { padding: .65rem 0; border-bottom: 1px solid var(--color-border); font-size: .9rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: baseline; }
.activity-item .actor   { font-weight: 600; color: var(--color-primary); }
.activity-item .action  { color: var(--color-text); }
.activity-item .entity  { background: #f1f5f9; padding: .1rem .4rem; border-radius: 4px; font-size: .8rem; }
.activity-item .ts      { margin-left: auto; font-size: .78rem; color: var(--color-muted); }

/* ── Members section ───────────────────────────── */
.members-section { margin-top: 2rem; }

/* ── Upload form ───────────────────────────────── */
.upload-form { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; padding: 1rem; background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); }
.upload-form label { margin: 0; }

/* ── Footer ────────────────────────────────────── */
.site-footer { text-align: center; padding: 2rem; color: var(--color-muted); font-size: .85rem; border-top: 1px solid var(--color-border); margin-top: 3rem; }

@media (max-width: 840px) {
  .main-menu-links { gap: .55rem; }
  .welcome { display: none; }
}

@media (max-width: 780px) {
  .container { padding: 0 1rem; }
  .navbar-inner { min-height: 52px; }
  .nav-toggle { display: inline-block !important; }
  .nav-links { display: none; position: absolute; top: 52px; left: 0; right: 0; background: var(--color-primary); border-top: 1px solid rgba(255,255,255,.2); padding: .75rem 1rem; flex-direction: column; align-items: stretch; gap: .6rem; }
  .nav-links.is-open { display: flex; }
  .main-menu-links { margin-left: 0; display: flex; flex-direction: column; align-items: stretch; gap: .15rem; }
  .main-menu-links a,
  .main-menu-meta a,
  .welcome { padding: .46rem .2rem; margin: 0; }
  .welcome { display: block; font-size: .9rem; }
  .main-menu-meta { margin-left: 0; border-top: 1px solid rgba(255,255,255,.2); padding-top: .55rem; }
  .lang-switch { font-size: .9rem; gap: .75rem; }

  .project-subnav-wrap { top: 52px; }
  .project-subnav-inner { align-items: flex-start; gap: .5rem; }
  .module-nav-toggle { display: inline-flex !important; }
  .module-nav-shared { display: none; width: 100%; justify-content: flex-start; }
  .module-nav-shared.is-open { display: flex; }
  .module-nav { gap: .35rem; }
  .module-nav a { font-size: .82rem; }

  .projects-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .choice-grid { grid-template-columns: 1fr; }
  .txn-form-grid { grid-template-columns: 1fr; }
  .txn-form-grid .field-span-2 { grid-column: span 1; }
  .txn-form-grid .field-span-full { grid-column: span 1; }
  .summary { min-width: 100%; }
  .activity-item .ts { margin-left: 0; width: 100%; }
  .site-footer { margin-top: 2rem; padding: 1.25rem; }
}
