:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #e7ebf3;
  --text: #111827;
  --muted: #6b7280;
  --sidebar-text: #d6dbe6;
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(255,255,255,0.08);
  --primary: #111827;
  --primary-2: #1f2937;
  --green: #22c55e;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --red: #ef4444;
  --card-shadow: 0 10px 30px rgba(17, 24, 39, 0.06);
  --soft-shadow: 0 4px 16px rgba(17, 24, 39, 0.04);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59,130,246,0.08), transparent 25%),
    radial-gradient(circle at top right, rgba(34,197,94,0.06), transparent 22%),
    var(--bg);
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #111827 0%, #1f2937 100%);
  color: white;
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  padding: 6px 8px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #111827;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(245, 158, 11, 0.28);
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item {
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  padding: 13px 14px;
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  font-size: 15px;
  transition: 0.2s ease;
}

.menu-item:hover {
  background: var(--sidebar-hover);
  color: white;
  transform: translateX(2px);
}

.menu-item.active {
  background: rgba(255,255,255,0.12);
  color: var(--sidebar-active);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.content {
  padding: 30px;
}

.view { display: none; }
.view.active { display: block; }

.header-block {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  display: inline-block;
  color: var(--blue);
  background: rgba(59,130,246,0.08);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

h1 {
  margin: 0;
  font-size: 38px;
  letter-spacing: -0.04em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card,
.panel,
.meeting-detail-card {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -20px -20px auto;
  width: 90px;
  height: 90px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(34,197,94,0.08));
}

.stat-title {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  margin: 10px 0 6px;
  letter-spacing: -0.04em;
}

.stat-sub {
  color: var(--muted);
  font-size: 14px;
}

.panel,
.meeting-detail-card {
  padding: 22px;
  margin-bottom: 22px;
}

.chart-panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,252,0.96));
}

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

.panel-header h3,
.meeting-title-row h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.form-grid,
.two-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

input, select, textarea, button {
  font: inherit;
}

input, select, textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .12s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(59,130,246,0.5);
  box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}

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

.span-2 { grid-column: span 2; }

.primary-btn, .ghost-btn, .danger-btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
}

.primary-btn:hover, .ghost-btn:hover, .danger-btn:hover { transform: translateY(-1px); }
.primary-btn:active, .ghost-btn:active, .danger-btn:active { transform: translateY(0); }

.primary-btn {
  background: linear-gradient(135deg, #111827, #374151);
  color: white;
  box-shadow: 0 10px 18px rgba(17,24,39,0.14);
}

.ghost-btn {
  background: #f3f6fb;
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-btn {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #ffe4e6;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th, td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbfc;
}

.meeting-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.meeting-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  cursor: pointer;
  transition: 0.18s ease;
  box-shadow: var(--soft-shadow);
}

.meeting-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 24px rgba(17,24,39,0.08);
  border-color: #dbe4f0;
}

.meeting-card h4 { margin: 0 0 10px; font-size: 18px; }
.meeting-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.meeting-meta, .muted {
  color: var(--muted);
  line-height: 1.5;
}

.meeting-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  margin: 22px 0 18px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.tab-btn.active {
  background: #f3f6fb;
  color: var(--text);
  border-color: var(--line);
}

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

.point-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.point-number {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e5eefc, #eef4ff);
  color: #1d4ed8;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex: 0 0 auto;
}

.attendance-bars {
  display: grid;
  gap: 16px;
}

.bar-item {
  display: grid;
  grid-template-columns: 170px 1fr 60px;
  align-items: center;
  gap: 12px;
}

.bar-item span {
  font-weight: 600;
}

.bar {
  height: 14px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  width: 0%;
  transition: width .35s ease;
}

.bar-fill.green { background: linear-gradient(90deg, #22c55e, #4ade80); }
.bar-fill.blue { background: linear-gradient(90deg, #3b82f6, #60a5fa); }

.badge {
  display: inline-flex;
  align-items: center;
  background: #f3f6fb;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  margin-right: 8px;
  margin-bottom: 8px;
}

.empty {
  color: var(--muted);
  padding: 12px 0;
}

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
  }
  .meeting-list,
  .form-grid,
  .two-col,
  .stats-grid,
  .stats-cards-row,
  .stats-charts-grid {
    grid-template-columns: 1fr;
  }
  .span-2 { grid-column: span 1; }
  .header-block,
  .meeting-title-row { flex-direction: column; align-items: flex-start; }
  .bar-item { grid-template-columns: 1fr; }
}

.jotform-style {
  max-width: 920px;
}

.meeting-record-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-block > span {
  font-weight: 700;
  font-size: 14px;
}

.full-width {
  grid-column: 1 / -1;
}

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

.meeting-record-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.meeting-record-section-head,
.meeting-leader-head,
.meeting-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.meeting-leader-block,
.meeting-summary-card,
.leader-summary-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 16px;
  box-shadow: var(--soft-shadow);
}

.meeting-leader-block {
  margin-top: 14px;
}

.leader-rank-label {
  margin-top: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.leader-points-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leader-point-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.meeting-summary-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.meeting-summary-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.leader-summary-card {
  margin-bottom: 12px;
}

.leader-summary-card h4,
.meeting-summary-card h4,
.meeting-leader-head h4 {
  margin: 0 0 8px;
}

.leader-summary-card ul {
  margin: 10px 0 0 18px;
  padding: 0;
}

.auth-screen {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--card-shadow);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.secondary-auth {
  margin-top: 22px;
}

.auth-logo {
  margin-bottom: 12px;
}

/* Configuration sub-tabs */
.config-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
}

.config-tab-btn {
  border: 1px solid var(--line);
  background: #f3f6fb;
  color: var(--muted);
  padding: 11px 22px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.config-tab-btn:hover {
  background: #e8edf5;
  color: var(--text);
  transform: translateY(-1px);
}

.config-tab-btn.active {
  background: linear-gradient(135deg, #111827, #374151);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.18);
}

.config-tab-panel {
  display: none;
}

.config-tab-panel.active {
  display: block;
  animation: configFadeIn 0.25s ease;
}

/* Statistics section styles */
.stats-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.stats-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}

.chart-card {
  padding: 22px;
}

.chart-container {
  position: relative;
  height: 260px;
  width: 100%;
}

/* ===== Units page ===== */
.units-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.unit-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  transition: 0.18s ease;
  box-shadow: var(--soft-shadow);
}
.unit-tab:hover {
  transform: translateY(-1px);
  border-color: #c7d2fe;
}
.unit-tab.active {
  background: linear-gradient(135deg, #111827, #374151);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(17,24,39,0.22);
}
.unit-tab-icon {
  font-size: 18px;
  line-height: 1;
}
.unit-tab-count {
  background: rgba(0,0,0,0.08);
  color: inherit;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 800;
}
.unit-tab.active .unit-tab-count {
  background: rgba(255,255,255,0.18);
}

.unit-summary {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--card-shadow);
}
.unit-summary h2 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: -0.02em;
}
.unit-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.unit-summary-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f3f6fb;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 16px;
  min-width: 80px;
}
.stat-pill span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-pill strong {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.unit-members-table .next-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}
.unit-members-table .next-cell.next-critical strong { color: #b91c1c; }
.unit-members-table .next-cell.next-warning  strong { color: #b45309; }
.unit-members-table .next-cell.next-info     strong { color: #1d4ed8; }
.unit-members-table .next-eligible {
  color: #15803d;
  font-weight: 700;
}

/* Members import/export toolbar */
.members-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.members-toolbar .primary-btn,
.members-toolbar .ghost-btn {
  padding: 9px 14px;
  font-size: 14px;
}

/* Upcoming unit transitions */
.transitions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transition-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.transition-row .transition-name {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.transition-row .transition-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.transition-row .transition-detail {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 4px;
}

.transition-row .transition-days {
  font-weight: 800;
  font-size: 15px;
}

.transition-row .transition-sub {
  color: var(--muted);
  font-size: 12px;
}

.transition-row.urgency-overdue  { border-left-color: #7c3aed; background: #f5f3ff; }
.transition-row.urgency-overdue  .transition-days { color: #6d28d9; }

.transition-row.urgency-critical { border-left-color: #ef4444; background: #fff5f5; }
.transition-row.urgency-critical .transition-days { color: #b91c1c; }

.transition-row.urgency-warning  { border-left-color: #f59e0b; background: #fffaf0; }
.transition-row.urgency-warning  .transition-days { color: #b45309; }

.transition-row.urgency-info     { border-left-color: #3b82f6; background: #f5f9ff; }
.transition-row.urgency-info     .transition-days { color: #1d4ed8; }

@media (max-width: 640px) {
  .transition-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .transition-row .transition-detail {
    align-items: flex-start;
    text-align: left;
  }
}


@media (max-width: 640px) {
  .content { padding: 18px; }
  h1 { font-size: 30px; }
  .panel, .meeting-detail-card, .stat-card { padding: 16px; }
  .meeting-record-form,
  .inline-time-grid,
  .leader-point-row,
  .meeting-summary-card { grid-template-columns: 1fr; display: grid; }
  .meeting-summary-card,
  .meeting-record-section-head,
  .meeting-leader-head,
  .meeting-actions-row { align-items: flex-start; }
}
