:root{
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --surface-3: #e8e6e0;
  --border: #e2e0da;
  --border-soft: #ebeae5;
  --text: #171613;
  --text-dim: #66635c;
  --text-faint: #9a978f;
  --principal: #171613;
  --interest: #d6d3ca;
  --success: #4a6a4a;
  --error: #a5453b;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(23,22,19,0.04), 0 1px 1px rgba(23,22,19,0.02);
  --shadow-md: 0 8px 24px rgba(23,22,19,0.07), 0 2px 6px rgba(23,22,19,0.04);
  --shadow-lg: 0 24px 64px rgba(23,22,19,0.18);
}

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-feature-settings: 'tnum' 1, 'cv05' 1;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  font-size: 14px;
}

a{ color: inherit; }

.page{
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 28px 64px;
}
.page.narrow{ max-width: 420px; padding-top: 72px; }

/* ---------- Header ---------- */
header.page-header{
  display:flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.eyebrow{
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 8px;
}
h1{
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
header.page-header p{
  color: var(--text-dim);
  font-size: 13px;
  max-width: 340px;
  margin: 0;
  line-height: 1.5;
}

/* ---------- Admin shell (sidebar layout) ---------- */
.admin-shell{
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}
.admin-sidebar{
  width: 216px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-sidebar .brand{
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 6px 10px 20px;
}
.admin-sidebar .brand span{ display:block; color: var(--text-faint); font-weight: 500; font-size: 11px; margin-top: 2px; }
.admin-sidebar nav{ display:flex; flex-direction: column; gap: 2px; }
.admin-sidebar nav a{
  display:flex;
  align-items:center;
  gap: 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  padding: 9px 10px;
  border-radius: 8px;
  transition: background .15s ease, color .15s ease;
}
.admin-sidebar nav a svg{ flex-shrink:0; opacity:0.7; }
.admin-sidebar nav a:hover{ background: var(--surface-2); color: var(--text); }
.admin-sidebar nav a.active{ background: var(--principal); color: var(--surface); }
.admin-sidebar nav a.active svg{ opacity:1; }
.admin-sidebar .sidebar-footer{ margin-top: auto; display:flex; flex-direction:column; gap:10px; }
.admin-sidebar .sidebar-user{ font-size: 11.5px; color: var(--text-faint); padding: 0 10px; }
.admin-sidebar .powered-by{ padding: 0 10px; }
.admin-sidebar .powered-by img{ display:block; opacity: 0.9; }

.admin-main{ flex: 1; min-width: 0; }
.admin-main .page{ max-width: none; width: 100%; margin: 0; padding: 32px 40px 64px; }

/* ---------- Panels / cards ---------- */
.panel{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
}

/* ---------- Inputs ---------- */
.field{ margin-bottom: 16px; }
.field:last-child{ margin-bottom: 0; }
label{
  display:block;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 7px;
}
.input-wrap{
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color .15s ease, background .15s ease;
}

/* Chrome/Safari force their own autofill background with square corners,
   which otherwise bleeds past the rounded .input-wrap edges. Override the
   forced color and let the transition delay hide the flash of the default. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active{
  -webkit-box-shadow: 0 0 0 30px var(--surface-2) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
  font-family: inherit !important;
}
.plain-input:-webkit-autofill,
.plain-input:-webkit-autofill:hover,
.plain-input:-webkit-autofill:focus{
  -webkit-box-shadow: 0 0 0 30px #ffffff inset !important;
}
.input-wrap:focus-within{ border-color: #b9b6ac; background: var(--surface); }
.input-wrap .prefix{ padding: 0 0 0 13px; color: var(--text-faint); font-size: 13.5px; font-weight: 500; }
.input-wrap .suffix{ padding: 0 13px 0 0; color: var(--text-faint); font-size: 12px; font-weight: 500; white-space: nowrap; }
input[type="number"], input[type="text"], input[type="email"], input[type="password"], input[type="date"], select{
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 13px;
  width: 100%;
}
select{ cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239a978f'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 30px; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button{ -webkit-appearance: none; margin: 0; }

.plain-input{
  background: #ffffff;
  border: 1px solid #c9c6bd;
  border-radius: 8px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.plain-input:focus{ border-color: var(--text-dim); box-shadow: 0 0 0 3px rgba(23,22,19,0.06); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 7px;
  background: var(--principal);
  color: var(--surface);
  border: 1px solid var(--principal);
  border-radius: 8px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover{ opacity: 0.88; }
.btn:disabled{ opacity: 0.5; cursor: default; }
.btn.secondary{ background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.secondary:hover{ background: var(--surface-3); opacity:1; }
.btn.ghost{ background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn.ghost:hover{ background: var(--surface-2); color: var(--text); opacity:1; }
.btn.danger{ background: var(--error); border-color: var(--error); }
.btn.small{ padding: 7px 13px; font-size: 12px; }
.btn.full{ width: 100%; }
.btn svg{ flex-shrink:0; }

/* ---------- Status messages ---------- */
.status-msg{ font-size: 12px; margin-top: 10px; }
.status-msg.success{ color: var(--success); }
.status-msg.error{ color: var(--error); }

/* ---------- Tables ---------- */
.table-wrap{
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
table{
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
thead th{
  background: var(--surface-2);
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th.num, tbody td.num{ text-align: right; }
tbody td{
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  white-space: nowrap;
}
tbody td.strong{ color: var(--text); font-weight: 500; }
tbody tr:last-child td{ border-bottom: none; }
tbody tr:hover td{ background: rgba(23,22,19,0.02); }
tbody tr.expanded td{ background: rgba(23,22,19,0.03); }

.badge{
  display:inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.badge.active{ background: #e8ede8; color: var(--success); }
.badge.inactive{ background: #f0e6e4; color: var(--error); }

.icon-btn{
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}
.icon-btn:hover{ background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover{ color: var(--error); }

/* ---------- Filter bar (compact, 4 fields) ---------- */
.filter-bar{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  align-items: end;
}
.filter-bar .filter-field{ flex: 1 1 160px; min-width: 140px; }
.filter-bar .filter-field label{ margin-bottom: 5px; font-size: 10px; }
.filter-bar .filter-actions{ display:flex; gap: 8px; flex: 0 0 auto; }

/* ---------- Expand row detail ---------- */
.expand-detail{ padding: 18px 22px; background: var(--bg); }
.expand-detail .mini-summary{ display:flex; gap: 22px; flex-wrap: wrap; margin-bottom: 16px; }
.expand-detail .mini-stat .label{ font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); font-weight: 600; margin-bottom: 4px; }
.expand-detail .mini-stat .value{ font-size: 14px; font-weight: 600; color: var(--text); }

/* ---------- Footer / Powered by Ascent ---------- */
footer.site-footer{ margin-top: 32px; display: flex; justify-content: flex-end; align-items: center; }
footer.site-footer img{ display: block; }

.table-note{ margin-top: 12px; font-size: 11px; color: var(--text-faint); }

/* ---------- Modal ---------- */
.modal-overlay{
  position: fixed; inset: 0;
  background: rgba(23,22,19,0.38);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
  padding: 20px;
}
.modal-overlay.open{ opacity: 1; pointer-events: auto; }
.modal{
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(0.98);
  transition: transform .15s ease;
}
.modal-overlay.open .modal{ transform: translateY(0) scale(1); }
.modal-head{ display:flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3{ font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.modal-close{ background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 4px; border-radius: 6px; display:flex; }
.modal-close:hover{ background: var(--surface-2); color: var(--text); }
.modal-actions{ display:flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn{ flex: 1; }

::-webkit-scrollbar{ width: 8px; height: 8px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{ background: #d8d6cf; border-radius: 4px; }

@media (max-width: 780px){
  .admin-shell{ flex-direction: column; }
  .admin-sidebar{ width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 16px; }
  .admin-sidebar .brand{ padding: 0 16px 0 0; }
  .admin-sidebar nav{ flex-direction: row; }
  .admin-sidebar .sidebar-footer{ margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; }
  .admin-sidebar .powered-by{ display: none; }
  .admin-main .page{ padding: 24px 20px 48px; }
}
