:root {
  /* Modern Color Palette - Elegant & Simple (Su Ya) */
  --primary: #4f46e5;
  /* Indigo 600 */
  --primary-hover: #4338ca;
  /* Indigo 700 */
  --bg: #f8fafc;
  /* Slate 50 */
  --surface: #ffffff;
  /* White */
  --text-main: #334155;
  /* Slate 700 */
  --text-muted: #64748b;
  /* Slate 500 */
  --border: #e2e8f0;
  /* Slate 200 */
  --danger: #ef4444;
  /* Red 500 */
  --success: #10b981;
  /* Emerald 500 */

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.025em;
}

.app-header nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.app-header nav a,
.app-header nav button {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.app-header nav a:hover,
.app-header nav button:hover {
  color: var(--primary);
}

.app-header nav button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* Layout */
.container {
  width: min(1200px, 92vw);
  margin: 0 auto;
}

main.container {
  padding: 2.5rem 0;
  min-height: 80vh;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card.narrow {
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.card h2 {
  margin-top: 0;
  font-size: 1.5rem;
  color: var(--text-main);
  margin-bottom: 1.5rem;
}

/* Grid */
.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input,
select,
textarea {
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: #fff;
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
}

/* Buttons */
button,
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  line-height: 1;
}

button {
  background: var(--primary);
  color: #fff;
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #cbd5f5;
  color: var(--text-main);
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  text-align: left;
  padding: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.95rem;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: #f8fafc;
}

/* Utilities */
.muted {
  color: var(--text-muted);
}

.message {
  margin-top: 1rem;
  padding: 1rem;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: var(--radius-md);
  color: #1e40af;
  display: none;
  font-size: 0.95rem;
}

.message.show {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

.link-btn {
  font-size: 0.9rem;
  color: var(--primary);
  background: none;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
  background: none;
  transform: none;
}

.list {
  list-style: none;
  padding-left: 0;
}

.list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.list li:last-child {
  border-bottom: none;
}

/* Toolbar & Logs */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.toolbar select {
  min-width: 200px;
}

.log-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
}

pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: 'Fira Code', Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  border: 1px solid #334155;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
}

.modal.open {
  display: flex;
  opacity: 1;
}

.modal-dialog {
  width: min(800px, 95vw);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal.open .modal-dialog {
  transform: scale(1);
}

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

.modal-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  padding: 0.5rem;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: #f1f5f9;
  color: var(--text-main);
  transform: none;
}

/* Tokens */
.token-field {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  background: #f8fafc;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.token-field .mono {
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 500;
}

.copy-token {
  background: #e0e7ff;
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.copy-token:hover {
  background: #c7d2fe;
}

.stage-section {
  margin-bottom: 1.5rem;
}

.stage-section h4 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
}

.stage-progress {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stage-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: #f8fafc;
}

.stage-item .stage-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.stage-item .stage-counts {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.stage-bar {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.stage-bar span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.candidate-table {
  margin-top: 0.5rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* Auth Pages */
.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h2 {
  font-size: 1.75rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.auth-links {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-links a:hover {
  text-decoration: underline;
}

/* Dashboard Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.stat-item {
  background: #f8fafc;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  text-align: center;
}

.stat-item .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: block;
}

.stat-item .value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
  display: block;
}

.text-xl {
  font-size: 1.25rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.text-3xl {
  font-size: 1.875rem;
}

.font-bold {
  font-weight: 700;
}

.text-primary {
  color: var(--primary);
}
