:root {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --success-bg: #064e3b;
  --success-text: #a7f3d0;
  --error-bg: #450a0a;
  --error-text: #fecaca;
  --error-border: #ef4444;
  --warning-bg: #451a03;
  --warning-text: #fde68a;
  --warning-border: #f59e0b;
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header bar */
.app-header {
  border-bottom: 1px solid var(--border);
  background: #111827;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.workspace-switcher-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-switcher-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

select.workspace-select {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.95rem;
  cursor: pointer;
}

select.workspace-select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Links & Accessibility Contrast */
a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:visited {
  color: #7dd3fc;
}

a:hover {
  color: #bae6fd;
}

a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.nav-menu {
  display: flex;
  gap: 16px;
  align-items: center;
}

.nav-menu a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-menu a:visited {
  color: var(--text-muted);
}

.nav-menu a:hover, .nav-menu a:focus-visible {
  color: var(--text);
  text-decoration: underline;
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Main Container */
.main-wrapper {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 32px auto;
  padding: 0 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 24px;
}

h1 {
  font-size: 1.8rem;
  margin-top: 0;
  margin-bottom: 16px;
  color: var(--text);
}

h2 {
  font-size: 1.35rem;
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--primary);
}

h3 {
  font-size: 1.1rem;
  margin-top: 16px;
  margin-bottom: 8px;
  color: #e2e8f0;
}

p {
  margin: 0 0 16px;
  color: #cbd5e1;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.radio-card {
  background: #182234;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.radio-card:hover {
  border-color: var(--primary);
}

.radio-card input[type="radio"] {
  margin-top: 4px;
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.radio-label-content {
  flex: 1;
}

.radio-title {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.radio-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

input[type="text"], input[type="email"] {
  width: 100%;
  max-width: 440px;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 1rem;
  color: var(--text);
}

input[type="text"]:focus-visible, input[type="email"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 24px 0;
  background: #182234;
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 8px;
}

.checkbox-group input[type="checkbox"] {
  margin-top: 4px;
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.checkbox-group label {
  font-size: 0.95rem;
  color: #e2e8f0;
  cursor: pointer;
  margin-bottom: 0;
}

.btn-primary {
  background: var(--primary);
  color: #0f172a;
  border: none;
  border-radius: 6px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-primary:visited {
  color: #0f172a;
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #0f172a;
  text-decoration: none;
}

.btn-primary:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* Alerts and Notices */
.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  font-weight: 600;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid #10b981;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  font-weight: 600;
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #334155;
  color: #f1f5f9;
}

.badge.org {
  background: #0369a1;
  color: #e0f2fe;
}

.badge.personal {
  background: #15803d;
  color: #dcfce7;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  background: #090d16;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

footer a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin: 0 8px;
}

footer a:visited {
  color: #7dd3fc;
}

footer a:hover, footer a:focus-visible {
  color: #bae6fd;
  text-decoration: underline;
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Sign-in and OAuth buttons */
.btn-secondary {
  background: #1e293b;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
  width: 100%;
  max-width: 440px;
}

.btn-secondary:hover {
  background: #334155;
  border-color: var(--primary);
}

.btn-secondary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.btn-signout {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-signout:hover, .btn-signout:focus-visible {
  color: var(--text);
  border-color: var(--primary);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 28px 0;
  max-width: 440px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider:not(:empty)::before {
  margin-right: 12px;
}

.auth-divider:not(:empty)::after {
  margin-left: 12px;
}

.oauth-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 440px;
}

/* Scholarship Tracker Styles */
.tracker-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.tracker-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.tracker-table-container {
  overflow-x: auto;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tracker-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

.tracker-table caption {
  text-align: left;
  font-weight: 700;
  padding: 12px;
  background: #111827;
  color: var(--text-muted);
}

.tracker-table th, .tracker-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.tracker-table th {
  background: #1e293b;
  color: #e2e8f0;
  font-weight: 600;
}

.tracker-table tr:hover {
  background: #182234;
}

.badge.status-saved { background: #334155; color: #f1f5f9; }
.badge.status-preparing { background: #0369a1; color: #e0f2fe; }
.badge.status-submitted { background: #6d28d9; color: #ede9fe; }
.badge.status-awarded { background: #065f46; color: #d1fae5; }
.badge.status-declined { background: #7f1d1d; color: #fee2e2; }
.badge.status-closed { background: #374151; color: #9ca3af; }

.badge.overdue {
  background: #991b1b;
  color: #fef2f2;
}

.badge.due-soon {
  background: #9a3412;
  color: #ffedd5;
}

.badge.shared {
  background: #1e40af;
  color: #dbeafe;
}

.badge.private {
  background: #374151;
  color: #d1d5db;
}

.notice-box {
  background: #1e293b;
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  color: #e2e8f0;
}

.warning-box {
  background: var(--warning-bg);
  border-left: 4px solid var(--warning-border);
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--warning-text);
}

/* Modal Dialog */
dialog.avl-dialog {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  max-width: 640px;
  width: 90%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

dialog.avl-dialog::backdrop {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-close:hover, .btn-close:focus-visible {
  color: var(--text);
  outline: 2px solid var(--primary);
  border-radius: 4px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.btn-delete {
  background: #7f1d1d;
  color: #fef2f2;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-delete:hover, .btn-delete:focus-visible {
  background: #991b1b;
  outline: 2px solid #ef4444;
}

.btn-secondary-action {
  background: #334155;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary-action:hover, .btn-secondary-action:focus-visible {
  background: #475569;
  outline: 2px solid var(--primary);
}

/* Home Page Due Soon Panel */
.due-panel {
  background: #182234;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-top: 24px;
}

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

.due-summary-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat-chip {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
}

.deadline-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
  gap: 12px;
  flex-wrap: wrap;
}

.deadline-item a {
  font-weight: 600;
  font-size: 1rem;
}

.deadline-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* Live region styling for tracker and deadline announcements */
.tracker-message-region {
  transition: all 0.2s ease;
}

.tracker-message-region:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tracker-message-region:not(:empty) {
  position: static;
  width: auto;
  height: auto;
  clip: auto;
  overflow: visible;
  white-space: normal;
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: 6px;
  background-color: #064e3b;
  color: #a7f3d0;
  border: 1px solid #059669;
  font-weight: 500;
  font-size: 0.95rem;
}

.tracker-message-region.error:not(:empty),
.tracker-message-region.alert-error:not(:empty) {
  background-color: #7f1d1d;
  color: #fef2f2;
  border-color: #ef4444;
}

.form-help-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}
