/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream: #FAF8F3;
  --cream-dark: #F0EDE4;
  --ink: #1C1A17;
  --ink-mid: #4A4640;
  --ink-light: #8C8478;
  --gold: #C8952A;
  --gold-light: #F5E9D0;
  --blue: #2563EB;
  --blue-light: #DBEAFE;
  --green: #16A34A;
  --green-light: #DCFCE7;
  --amber: #D97706;
  --amber-light: #FEF3C7;
  --red: #DC2626;
  --red-light: #FEE2E2;
  --border: #E4DFD6;
  --shadow: 0 1px 3px rgba(28,26,23,0.08), 0 1px 2px rgba(28,26,23,0.04);
  --shadow-md: 0 4px 12px rgba(28,26,23,0.1), 0 2px 4px rgba(28,26,23,0.06);
  --radius: 10px;
  --radius-lg: 14px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1, h2, h3 { font-family: 'Lora', Georgia, serif; font-weight: 600; line-height: 1.3; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth Layout ── */
.auth-page { min-height: 100vh; }

.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.auth-brand {
  background: var(--ink);
  color: white;
  padding: 60px 48px;
  display: flex;
  align-items: center;
}

.brand-inner { max-width: 380px; }

.brand-logo { font-size: 40px; margin-bottom: 16px; display: block; }

.brand-title {
  font-family: 'Lora', serif;
  font-size: 32px;
  color: white;
  margin-bottom: 16px;
}

.brand-tagline {
  color: #B0A898;
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 32px;
}

.brand-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand-features li {
  color: #D4C9B8;
  font-size: 14px;
}

.auth-form-side {
  padding: 60px 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
}

.auth-box {
  width: 100%;
  max-width: 380px;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-light);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.auth-tab.active {
  color: var(--ink);
  border-bottom-color: var(--gold);
}

.auth-tab-panel { display: none; }
.auth-tab-panel.active { display: block; }

.auth-tab-panel h2 {
  font-size: 24px;
  margin-bottom: 4px;
}

.auth-sub { color: var(--ink-light); font-size: 14px; margin-bottom: 24px; }

.auth-alt {
  text-align: center;
  font-size: 13px;
  color: var(--ink-light);
  margin-top: 16px;
}

/* ── App Layout ── */
.app-page { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--ink);
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-logo { font-size: 22px; }
.topbar-title {
  font-family: 'Lora', serif;
  font-size: 18px;
  color: white;
  font-weight: 600;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: 13px; color: #B0A898; }

.app-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  flex: 1;
  min-height: 0;
}

.sidebar {
  background: white;
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-mid);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  width: 100%;
}

.nav-item:hover { background: var(--cream); color: var(--ink); }
.nav-item.active { background: var(--gold-light); color: var(--ink); }
.nav-icon { font-size: 16px; }

.main-content {
  padding: 32px;
  overflow-y: auto;
  max-width: 780px;
}

/* ── Panels ── */
.panel { display: none; }
.panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.panel-title { font-size: 22px; margin-bottom: 2px; }
.panel-sub { font-size: 13px; color: var(--ink-light); }

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-n { font-size: 28px; font-weight: 600; font-family: 'Lora', serif; }
.stat-l { font-size: 12px; color: var(--ink-light); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Filter chips ── */
.filter-bar { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }

.chip {
  padding: 5px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  color: var(--ink-mid);
  cursor: pointer;
  transition: all 0.12s;
}

.chip:hover { border-color: var(--ink-light); }
.chip.active { background: var(--ink); color: white; border-color: var(--ink); }
.filter-select {
  padding: 5px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  color: var(--ink-mid);
  cursor: pointer;
  transition: all 0.12s;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
}
.filter-select:hover { border-color: var(--ink-light); }
.filter-bar { flex-wrap: wrap; gap: 6px; }

/* ── Cards ── */
.item-list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.12s, transform 0.12s;
}

.card:hover { box-shadow: var(--shadow-md); }
.card-clickable { cursor: pointer; }
.card-clickable:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.10); transform: translateY(-1px); }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.card-title { font-size: 14px; font-weight: 600; line-height: 1.4; }
.card-desc { font-size: 13px; color: var(--ink-mid); margin-bottom: 10px; }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-light);
}

.card-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-open { background: var(--blue-light); color: #1D4ED8; }
.badge-inprogress { background: var(--amber-light); color: #B45309; }
.badge-done { background: var(--green-light); color: #166534; }
.badge-urgent { background: var(--red-light); color: #B91C1C; }
.badge-cat { background: var(--cream-dark); color: var(--ink-mid); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  background: white;
  color: var(--ink);
  font-family: inherit;
  transition: background 0.12s, transform 0.1s;
  text-decoration: none;
}

.btn:hover { background: var(--cream); }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--ink); color: white; border-color: var(--ink); }
.btn-primary:hover { background: #333; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-mid); }
.btn-ghost:hover { background: var(--cream); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-light);
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1;
  transition: color 0.1s, background 0.1s;
}

.icon-btn:hover { color: var(--ink); background: var(--cream); }

/* ── Forms ── */
.form-row { margin-bottom: 14px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-mid);
  margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--ink);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,149,42,0.12);
}

textarea { resize: vertical; min-height: 72px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }

.form-error {
  background: var(--red-light);
  color: var(--red);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.form-success {
  background: var(--green-light);
  color: var(--green);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.hidden { display: none !important; }

/* ── Search ── */
.search-wrap { margin-bottom: 16px; }
.search-wrap input { max-width: 280px; }

/* ── Modal ── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28,26,23,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-bg.open { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 { font-size: 18px; }

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-light);
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.1s;
}
.close-btn:hover { color: var(--ink); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Vault password row ── */
.pw-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 6px;
  font-family: monospace;
  font-size: 13px;
}

.pw-label { font-size: 10px; font-weight: 600; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.05em; min-width: 36px; font-family: inherit; }
.pw-val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }

/* ── Member cards ── */
.member-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
}

.member-info { display: flex; align-items: center; gap: 14px; }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold-light);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.member-name { font-size: 15px; font-weight: 600; }
.member-role { font-size: 13px; color: var(--ink-light); }

.member-stats { text-align: right; }
.member-stat-n { font-size: 22px; font-weight: 600; font-family: 'Lora', serif; }
.member-stat-l { font-size: 11px; color: var(--ink-light); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 999;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-light);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 500; color: var(--ink-mid); margin-bottom: 6px; }
.empty-sub { font-size: 14px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form-side { padding: 32px 20px; }

  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { padding: 20px 16px; }
  .stats-row { grid-template-columns: 1fr 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .panel-header { flex-direction: column; align-items: flex-start; }
}
