:root {
  /* Authentic Toastmasters Brand Palette */
  --tm-maroon: #772432;
  --tm-maroon-dark: #5a1b26;
  --tm-blue: #004165;
  --tm-blue-dark: #002b44;
  --tm-gold: #F2DF74;
  --tm-gold-dark: #d4c052;
  
  /* UI Colors */
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text-main: #22262a;
  --text-muted: #555f6d;
  --border: #e0e4e8;
  --border-focus: var(--tm-blue);
  
  /* Status Colors */
  --green-text: #1e8a4c;
  --green-bg: #e5f6ec;
  --yellow-text: #b7891e;
  --yellow-bg: #fdf3e0;
  --red-text: #c23b3b;
  --red-bg: #fbe9e9;
  --gray-text: #667085;
  --gray-bg: #f0f1f3;
  
  /* Typography & Layout */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { 
  color: var(--tm-blue); 
  text-decoration: none; 
  transition: var(--transition);
}
a:hover { 
  color: var(--tm-maroon);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ---- Nav ---- */
.topnav {
  background: var(--tm-maroon);
  border-bottom: 3px solid var(--tm-gold);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.brand {
  color: #ffffff !important;
  font-weight: 700;
  font-size: 1.25rem;
  padding: 16px 0;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 8px;
}
.nav-links { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.nav-links a:not(.btn) {
  color: rgba(255,255,255,0.85) !important;
  text-decoration: none;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.nav-links a:not(.btn):hover { 
  color: #ffffff !important; 
  background: rgba(255,255,255,0.1);
}
.nav-links a.active:not(.btn) {
  color: var(--tm-maroon) !important;
  background: var(--tm-gold);
}
@media (max-width: 780px) {
  .nav-toggle { display: block; }
  .nav-links { display: none; width: 100%; flex-direction: column; gap: 4px; padding-bottom: 16px; align-items: flex-start; }
  .nav-links.open { display: flex; }
  .nav-links a { width: 100%; }
}

/* ---- Layout helpers ---- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
}
.page-header h1 { 
  margin: 0; 
  font-size: 1.875rem; 
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--tm-blue);
}
.subtitle { 
  color: var(--text-muted); 
  margin: 4px 0 0 0; 
  font-size: 1.05rem;
}

.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--tm-blue);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card h2, .card h3 { 
  margin-top: 0; 
  font-weight: 600;
  color: var(--tm-blue);
  letter-spacing: -0.01em;
}

.stat {
  text-align: center;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.stat .number { 
  font-size: 2.5rem; 
  font-weight: 800; 
  color: var(--tm-maroon); 
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat .label { 
  color: var(--text-muted); 
  font-size: 0.85rem; 
  font-weight: 600;
  text-transform: uppercase; 
  letter-spacing: 0.05em; 
  margin-top: 8px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--tm-maroon);
  color: #ffffff !important;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.btn:hover { 
  background: var(--tm-maroon-dark); 
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}
.btn-secondary {
  background: #ffffff;
  color: var(--tm-blue) !important;
  border-color: var(--border);
}
.btn-secondary:hover { 
  background: var(--gray-bg); 
}
.btn-outline {
  background: transparent;
  color: var(--tm-blue) !important;
  border-color: var(--tm-blue);
  box-shadow: none;
}
.btn-outline:hover { 
  background: var(--tm-blue); 
  color: #ffffff !important;
}
.btn-danger {
  background: #ffffff;
  border-color: var(--border);
  color: var(--red-text) !important;
}
.btn-danger:hover { 
  background: var(--red-bg); 
  border-color: var(--red-text);
}
.btn-sm { 
  padding: 6px 12px; 
  font-size: 0.85rem; 
}

/* Override nav buttons to fit new style */
.nav-links .btn {
  background: transparent;
  box-shadow: none;
  color: rgba(255,255,255,0.85) !important;
  border-color: rgba(255,255,255,0.5);
}
.nav-links .btn:hover {
  background: rgba(255,255,255,0.15);
  color: #ffffff !important;
  border-color: #ffffff;
  transform: none;
}

/* ---- Drag-and-drop row reordering ---- */
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
  user-select: none;
  padding: 4px 6px;
  transition: var(--transition);
}
.drag-handle:hover { color: var(--text-main); }
.drag-handle:active { cursor: grabbing; }
tr.dragging { opacity: 0.4; background: var(--bg); }
@keyframes auto-assign-flash { from { background: var(--yellow-bg); } to { background: transparent; } }
tr.auto-assigned { animation: auto-assign-flash 1.2s ease-out; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---- Forms ---- */
label { 
  display: block; 
  font-weight: 600; 
  font-size: 0.875rem; 
  margin-bottom: 6px; 
  margin-top: 16px; 
  color: var(--text-main);
}
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: #ffffff;
  color: var(--text-main);
  transition: var(--transition);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px hsl(221, 83%, 90%);
}
textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 20px; }
.form-actions { margin-top: 28px; display: flex; gap: 12px; align-items: center; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin-top: 6px; }
.error-banner {
  background: var(--red-bg);
  border-left: 4px solid var(--red-text);
  color: var(--red-text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-weight: 500;
}

/* ---- Tables ---- */
.table-wrap { 
  overflow-x: auto; 
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
table { 
  width: 100%; 
  border-collapse: collapse; 
  background: #ffffff;
}
th, td { 
  text-align: left; 
  padding: 14px 16px; 
  border-bottom: 1px solid var(--border); 
  font-size: 0.95rem; 
  vertical-align: middle; 
}
th { 
  color: var(--text-muted); 
  font-weight: 600; 
  font-size: 0.8rem; 
  text-transform: uppercase; 
  letter-spacing: 0.05em; 
  background: var(--bg);
}
tr:last-child td { border-bottom: none; }
tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg); }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow-text); }
.badge-red { background: var(--red-bg); color: var(--red-text); }
.badge-gray { background: var(--gray-bg); color: var(--gray-text); }

/* ---- Agenda role table ---- */
.role-table td.role-name { font-weight: 600; color: var(--text-main); }
.role-table .unfilled { color: var(--red-text); font-style: italic; }
.agenda-item-num { color: var(--text-muted); font-weight: 500; width: 32px; }

/* ---- Guidelines page ---- */
.guide-section { margin-bottom: 40px; }
.guide-section h2 { 
  border-bottom: 2px solid var(--border); 
  padding-bottom: 12px; 
  margin-bottom: 24px;
}
.role-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.role-card { 
  background: var(--card-bg); 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  padding: 20px; 
  transition: var(--transition);
}
.role-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.role-card h4 { margin: 0 0 8px; color: var(--tm-maroon); font-size: 1.1rem; }
.role-card p { margin: 0; font-size: 0.95rem; color: var(--text-muted); line-height: 1.5; }
.role-card .timing { 
  display: inline-block; 
  margin-top: 12px; 
  font-size: 0.8rem; 
  font-weight: 600;
  color: var(--text-muted); 
  background: var(--bg);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.timeline { 
  border-left: 2px solid var(--border); 
  padding-left: 24px; 
  margin-left: 12px; 
}
.timeline-item { margin-bottom: 24px; position: relative; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -29px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tm-maroon);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px var(--border);
}
.timeline-item h4 { margin: 0 0 4px; font-size: 1.05rem; }
.timeline-item p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

/* ---- Utility ---- */
.muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.empty-state { 
  text-align: center; 
  padding: 60px 20px; 
  color: var(--text-muted); 
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}
.tag-list { display: flex; gap: 8px; flex-wrap: wrap; }

.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 40px 20px;
  margin-top: 40px;
  border-top: 1px solid var(--border);
}

/* ---- Print ---- */
@media print {
  .topnav, .site-footer, .no-print { display: none !important; }
  body { background: white; color: black; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .container { padding: 0; max-width: none; }
}

/* ---- Readonly Mode for Regular Members ---- */
.readonly-mode form:not([method="GET"]):not([action="/logout"]):not([action="/profile/change-password"]):not([action="/profile/delete"]) {
  display: none !important;
}
.readonly-mode a[href$="/new"],
.readonly-mode a[href$="/edit"],
.readonly-mode a[href*="/edit?"],
.readonly-mode .drag-handle {
  display: none !important;
}
