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

:root {
  --bg:        #f5ede4;
  --card:      #fff8f2;
  --header:    #5c3d2e;
  --border:    #ead8c8;
  --text:      #3d2b1f;
  --text-sec:  #9c8374;
  --bar-bg:    #f0e0d0;
  --terra:     #c4845a;
  --sage:      #6b8f71;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Auth ── */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3d2b1f 0%, #5c3d2e 100%);
}
.auth-card {
  background: var(--card);
  border-radius: 18px;
  padding: 48px 40px;
  text-align: center;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.auth-logo { font-size: 48px; margin-bottom: 16px; }
.auth-card h1 { font-size: 22px; font-weight: 800; margin-bottom: 8px; color: var(--text); }
.auth-card p  { color: var(--text-sec); margin-bottom: 32px; }
.apple-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; background: var(--header); color: white; border: none;
  border-radius: 10px; padding: 14px 20px; font-family: 'Nunito', sans-serif;
  font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity 0.2s;
}
.apple-btn:hover { opacity: 0.85; }

/* ── Header ── */
.header {
  background: var(--header); color: white; padding: 0 20px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.header-title { font-size: 16px; font-weight: 800; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; color: #d4b89c; }
.btn-link {
  background: none; border: none; color: #d4b89c; cursor: pointer;
  font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 600;
}
.btn-link:hover { color: white; }

/* ── Global search ── */
.global-search-bar {
  position: relative; background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
.global-search-bar input {
  width: 100%; max-width: 480px; padding: 9px 14px 9px 36px; box-sizing: border-box;
  border: 1.5px solid var(--border); border-radius: 20px;
  font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 600;
  color: var(--text); background: var(--bg)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239c8374' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E")
    no-repeat 12px center;
}
.global-search-bar input:focus {
  outline: none; border-color: var(--terra); box-shadow: 0 0 0 3px rgba(196,132,90,0.15);
}
.global-search-results {
  position: absolute; left: 16px; right: 16px; max-width: 480px; top: 100%; margin-top: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(61,43,31,0.2); max-height: 360px; overflow-y: auto; z-index: 150;
}
.search-result-item { padding: 10px 14px; border-bottom: 1px solid #f5ede4; cursor: pointer; }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #fdf5ee; }
.search-result-item.empty { cursor: default; color: var(--text-sec); font-weight: 600; }
.search-result-member { font-size: 11px; font-weight: 800; color: var(--terra); text-transform: uppercase; letter-spacing: 0.05em; }
.search-result-title { font-size: 14px; font-weight: 700; color: var(--text); margin: 2px 0; }
.search-result-snippet { font-size: 12px; color: var(--text-sec); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Member Tab Nav ── */
.tab-nav {
  background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; overflow-x: auto; padding: 0 16px; scrollbar-width: none;
  position: sticky; top: 111px; z-index: 90;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 14px 16px; font-family: 'Nunito', sans-serif; font-size: 13px;
  font-weight: 600; color: var(--text-sec); cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--terra); border-bottom-color: var(--terra); font-weight: 700; }

/* ── Layout ── */
.main-content { padding: 20px; width: 90%; margin: 0 auto; }
.section { margin-bottom: 28px; }
.section-title { font-size: 16px; font-weight: 800; color: var(--text); }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* ── Profile card ── */
.profile-card {
  background: var(--card); border-radius: 14px; padding: 18px 20px;
  box-shadow: 0 1px 6px rgba(92,61,46,0.08); border: 1px solid var(--border);
}
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; }
.profile-row { display: flex; flex-direction: column; gap: 2px; }
.profile-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-sec); }
.profile-value { font-size: 14px; font-weight: 600; color: var(--text); }
.profile-empty { color: var(--text-sec); font-weight: 500; }
.profile-actions { margin-top: 14px; display: flex; justify-content: flex-end; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: 10px; border: none; font-family: 'Nunito', sans-serif;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary   { background: var(--terra); color: white; }
.btn-secondary { background: #f0e0d0; color: var(--text); border: 1px solid var(--border); }
.btn-sm    { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-icon  { background: none; border: none; cursor: pointer; padding: 4px; font-size: 15px; opacity: 0.55; }
.btn-icon:hover { opacity: 1; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border-radius: 14px; overflow: hidden; box-shadow: 0 1px 6px rgba(92,61,46,0.08);
  border: 1px solid var(--border);
}
.data-table th {
  background: #f5ede4; text-align: left; padding: 10px 14px; font-size: 11px;
  font-weight: 800; color: var(--text-sec); text-transform: uppercase;
  letter-spacing: 0.05em; border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px; border-bottom: 1px solid #f5ede4; font-size: 13px;
  font-weight: 600; color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fdf5ee; }
.actions-cell { white-space: nowrap; text-align: right; }

/* ── Modals ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(61,43,31,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(61,43,31,0.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 800; color: var(--text); }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-sec); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.modal-footer {
  padding: 16px 20px; border-top: 1px solid var(--border); display: flex;
  justify-content: flex-end; gap: 10px; background: #f5ede4; border-radius: 0 0 16px 16px;
}

/* ── Forms ── */
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 12px; font-weight: 700; color: var(--text); }
.form-row input, .form-row textarea {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 600;
  color: var(--text); background: white; width: 100%; box-sizing: border-box;
}
.form-row input { height: 40px; }
.form-row input:focus, .form-row textarea:focus {
  outline: none; border-color: var(--terra); box-shadow: 0 0 0 3px rgba(196,132,90,0.15);
}

/* ── States ── */
.loading { color: #c4a882; padding: 20px 0; font-weight: 600; }
.empty   { color: #c4a882; padding: 20px 0; font-weight: 600; }

/* ── Responsive: data tables collapse to cards ── */
@media (max-width: 600px) {
  .main-content { padding: 14px; }
  .profile-grid { grid-template-columns: 1fr; }
  .global-search-bar input { max-width: none; }
  .global-search-results { max-width: none; }

  .table-wrap { overflow-x: visible; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table { border: none; background: none; box-shadow: none; border-radius: 0; }
  .data-table thead { display: none; }
  .data-table tr {
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 1px 6px rgba(92,61,46,0.08); margin-bottom: 10px; padding: 4px 14px;
  }
  .data-table tr:hover td { background: none; }
  .data-table td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    width: auto; padding: 7px 0; border-top: none; border-bottom: 1px solid #f5ede4;
    white-space: normal; text-align: right;
  }
  .data-table tr td:last-child { border-bottom: none; }
  .data-table td::before {
    content: attr(data-label); flex-shrink: 0; text-align: left; font-size: 11px;
    font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-sec);
  }
  .data-table td.actions-cell { justify-content: flex-end; gap: 4px; }
}
