:root {
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-border: #e5e9f0;
  --color-text: #1c2434;
  --color-text-muted: #6b7385;
  --color-primary: #3457d5;
  --color-primary-dark: #2842ab;
  --color-primary-light: #eef1fd;
  --color-success: #1aa053;
  --color-success-bg: #e8f8ef;
  --color-danger: #e0455c;
  --color-danger-bg: #fdecee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(20, 25, 40, 0.06), 0 1px 2px rgba(20, 25, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(20, 25, 40, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

a { color: inherit; text-decoration: none; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
}

.logo .icon { width: 24px; height: 24px; color: var(--color-primary); }

.admin-link, .btn-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  transition: all .15s ease;
}
.admin-link:hover, .btn-link:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ---------- Summary cards ---------- */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.summary-label {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.summary-value { font-size: 24px; font-weight: 700; }

/* ---------- Year navigation ---------- */
.year-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 18px;
}

.year-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.year-nav a:hover { border-color: var(--color-primary); color: var(--color-primary); }
.year-nav .year-label { font-size: 18px; font-weight: 700; min-width: 60px; text-align: center; }

/* ---------- Table ---------- */
.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; min-width: 760px; }

thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  padding: 14px 12px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }

.member-name { font-weight: 600; }
.member-mobile { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

.status-cell { text-align: center; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.badge .icon { width: 15px; height: 15px; }
.badge-paid { background: var(--color-success-bg); color: var(--color-success); }
.badge-unpaid { background: var(--color-danger-bg); color: var(--color-danger); }

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 40px 12px !important;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-outline { background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  color: var(--color-text-muted);
}
.icon-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.icon-btn.danger:hover { border-color: var(--color-danger); color: var(--color-danger); background: var(--color-danger-bg); }

.actions-cell { display: flex; gap: 8px; }

/* ---------- Admin bar ---------- */
.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-bar .actions { display: flex; gap: 10px; }

.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-subtitle { color: var(--color-text-muted); font-size: 14px; margin: 0; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
}
.form-control:focus { outline: none; border-color: var(--color-primary); }
.input-with-icon { position: relative; }
.input-with-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); }
.input-with-icon .form-control { padding-left: 38px; }
.input-with-icon .toggle-visibility { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--color-text-muted); display: flex; }

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  text-align: center;
}
.login-logo .icon-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo .icon-circle .icon { width: 24px; height: 24px; }
.login-logo h1 { font-size: 18px; margin: 0; }
.login-logo p { margin: 0; font-size: 13px; color: var(--color-text-muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 40, .45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-header h2 { font-size: 17px; margin: 0; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
}
.modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.modal-actions .btn { flex: 1; }

/* ---------- Member detail page ---------- */
.member-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
.member-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}
.member-header h1 { margin: 0; font-size: 19px; }
.member-header .member-mobile { font-size: 14px; }

.two-col {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 780px) {
  .two-col { grid-template-columns: 1fr; }
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2 { font-size: 15px; margin: 0 0 16px; }

.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.month-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: all .15s ease;
  background: var(--color-surface);
  text-align: left;
}
.month-card:hover { border-color: var(--color-primary); }
.month-card .month-name { font-weight: 600; font-size: 14px; margin-bottom: 6px; display: block; }
.month-card .month-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
}
.month-card.paid { border-color: var(--color-success); background: var(--color-success-bg); }
.month-card.paid .month-status { background: #fff; color: var(--color-success); }
.month-card.unpaid .month-status { background: var(--color-danger-bg); color: var(--color-danger); }
.month-card .month-status .icon { width: 12px; height: 12px; }

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-success);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 600;
  animation: toast-in .2s ease;
}
.toast.error { background: var(--color-danger); }
.toast .icon { width: 18px; height: 18px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 560px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .admin-bar { flex-direction: column; align-items: stretch; }
  .admin-bar .actions { justify-content: stretch; }
  .admin-bar .actions .btn { flex: 1; }
}

/* =========================================================
   Admin Dashboard - unique, mobile-first design system
   ========================================================= */

:root {
  --admin-navy: #10182b;
  --admin-navy-2: #1b2542;
  --admin-accent: #4f6df5;
  --admin-accent-2: #7c5cff;
  --admin-bg: #f2f4fb;
  --admin-surface: #ffffff;
  --admin-border: #e8eaf3;
  --admin-text: #171d33;
  --admin-text-muted: #767e97;
  --admin-green: #17a06b;
  --admin-green-bg: #e5f8ef;
  --admin-red: #e0475f;
  --admin-red-bg: #fdecef;
}

.admin-body {
  background: var(--admin-bg);
  color: var(--admin-text);
  margin: 0;
}

.admin-app { min-height: 100vh; padding-bottom: 40px; }

/* ---- Top bar ---- */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--admin-navy), var(--admin-navy-2));
  color: #fff;
  box-shadow: 0 4px 20px rgba(16, 24, 43, 0.18);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .01em;
}
.topbar-brand .icon { width: 22px; height: 22px; color: var(--admin-accent-2); }

.topbar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  flex-shrink: 0;
}
.topbar-logout:hover { background: rgba(255, 255, 255, 0.16); }
.topbar-logout .icon { width: 18px; height: 18px; }

/* ---- Main content ---- */
.admin-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 14px 0;
}

/* ---- Stat grid ---- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}

.stat-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(23, 29, 51, 0.04);
}

.stat-tile.stat-accent {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--admin-accent), var(--admin-accent-2));
  border: none;
  color: #fff;
}
.stat-tile.stat-accent .stat-icon { background: rgba(255, 255, 255, 0.18); color: #fff; }
.stat-tile.stat-accent .stat-label { color: rgba(255, 255, 255, 0.85); }

.stat-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--admin-bg);
  color: var(--admin-accent);
}
.stat-icon .icon { width: 18px; height: 18px; }

.stat-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: 12px; color: var(--admin-text-muted); white-space: nowrap; }
.stat-value { font-size: 19px; font-weight: 700; line-height: 1.1; }
.stat-accent .stat-value { font-size: 24px; }

/* ---- Section head ---- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.section-title { font-size: 17px; font-weight: 700; margin: 0; }

/* ---- Year switcher ---- */
.year-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 16px;
}
.year-switcher a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--admin-text-muted);
}
.year-switcher a:hover { background: var(--admin-bg); color: var(--admin-accent); }
.year-switcher-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 15px;
  min-width: 80px;
  justify-content: center;
}
.year-switcher-label .icon { width: 15px; height: 15px; color: var(--admin-text-muted); }

/* ---- Member cards ---- */
.member-list { display: flex; flex-direction: column; gap: 12px; }

.member-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(23, 29, 51, 0.04);
}

.member-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.member-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--admin-accent), var(--admin-accent-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.member-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.member-info .member-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-info .member-mobile {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--admin-text-muted);
}
.member-info .member-mobile .icon { width: 12px; height: 12px; }

.member-year-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--admin-accent);
  background: var(--admin-bg);
  padding: 4px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.member-card-actions { display: flex; gap: 6px; }
.member-card-actions .icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border-color: var(--admin-border);
}

.month-chip-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.month-chip {
  border: 1px solid var(--admin-border);
  background: var(--admin-bg);
  color: var(--admin-text-muted);
  border-radius: 8px;
  padding: 8px 0;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all .12s ease;
}
.month-chip:active { transform: scale(0.95); }
.month-chip.paid {
  background: var(--admin-green-bg);
  color: var(--admin-green);
  border-color: transparent;
}
.month-chip.unpaid {
  background: var(--admin-red-bg);
  color: var(--admin-red);
  border-color: transparent;
}

.empty-state-card {
  background: var(--admin-surface);
  border: 1px dashed var(--admin-border);
  border-radius: 16px;
  padding: 40px 20px;
  text-align: center;
  color: var(--admin-text-muted);
}
.empty-state-card .icon { width: 32px; height: 32px; margin-bottom: 10px; }
.empty-state-card p { margin: 0 0 16px; }

@media (min-width: 480px) {
  .month-chip-grid { grid-template-columns: repeat(6, 1fr); }
}
