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

:root {
  --bg: #0b0d10;
  --bg-elevated: #12161b;
  --bg-card: #161b22;
  --bg-input: #1c222b;
  --bg-hover: #1f262f;
  --text: #e6e9ed;
  --text-muted: #8b939c;
  --text-subtle: #6b7380;
  --primary: #14b8a6;
  --primary-hover: #0d9488;
  --primary-soft: rgba(20, 184, 166, 0.12);
  --accent: #929695;
  --border: #242a33;
  --border-strong: #2e3540;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 4px 16px rgba(0,0,0,0.25);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.35);
  --ring: 0 0 0 3px rgba(20, 184, 166, 0.2);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f0f3f7;
  --text: #1a1f26;
  --text-muted: #5a6472;
  --text-subtle: #8b939c;
  --border: #e2e6ec;
  --border-strong: #ccd2db;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
}

html { font-size: 16px; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

a { color: var(--primary); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }

.container { max-width: 1080px; margin: 0 auto; padding: 2.5rem 2rem; }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; letter-spacing: -0.015em; }
h1 { font-size: 2rem; margin-bottom: 1.25rem; }
h2 { font-size: 1.375rem; margin-bottom: 1rem; }
h3 { font-size: 1.05rem; margin-bottom: 0.75rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.7rem 1.35rem; border: 1px solid transparent; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 500; cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
              color 0.15s var(--ease), transform 0.05s var(--ease), box-shadow 0.15s var(--ease);
  text-decoration: none; line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #06201d; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; color: #04120f; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #f59e0b; color: #1a1202; }
.btn-warning:hover { background: #d97706; }
.btn-success { background: #10b981; color: #042f22; }
.btn-success:hover { background: #059669; }
.btn-ghost {
  background: transparent; color: var(--text); border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-sm { padding: 0.45rem 0.95rem; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 0.9rem 1.75rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Forms — global input styling so every form in the app inherits the airy look,
   regardless of whether its wrapper is .form-group, .field-row, or nothing. */
.form-group { margin-bottom: 1.5rem; }
label {
  display: block; margin-bottom: 0.45rem;
  font-weight: 500; font-size: 0.875rem;
  color: var(--text); letter-spacing: 0;
}
.hint, .help-text {
  display: block; margin-top: 0.4rem;
  font-size: 0.8rem; color: var(--text-muted); line-height: 1.5;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  min-height: 44px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.95rem; font-family: inherit; line-height: 1.5;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 96px; resize: vertical; }
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%238b939c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

input:hover:not(:focus):not(:disabled):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
select:hover:not(:focus):not(:disabled),
textarea:hover:not(:focus):not(:disabled) {
  border-color: var(--border-strong);
}
input:focus:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }

/* Suppress Chrome's white autofill bleed */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 40px var(--bg-input) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

input[type="file"] {
  font-size: 0.9rem; color: var(--text-muted);
  padding: 0.4rem 0;
}
input[type="file"]::file-selector-button {
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem; font-size: 0.85rem; font-weight: 500;
  margin-right: 0.75rem; cursor: pointer;
  transition: all 0.15s var(--ease);
}
input[type="file"]::file-selector-button:hover {
  border-color: var(--primary); color: var(--primary);
}

/* Modals — dialog never exceeds viewport; only .modal-body scrolls so header
   and footer (actions) always remain visible. */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 8, 12, 0.65);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  align-items: center; justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  animation: modal-overlay-in 0.15s var(--ease, ease) both;
}
.modal-overlay.open, .modal-overlay[data-open="true"] { display: flex; }
@keyframes modal-overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal-dialog {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,0.35));
  width: 100%; max-width: 480px;
  max-height: calc(100vh - 2rem);
  margin: auto;
  display: flex; flex-direction: column;
  overflow: hidden; /* rounded corners clip */
  animation: modal-dialog-in 0.15s var(--ease, ease) both;
}
.modal-dialog.sm { max-width: 380px; }
.modal-dialog.lg { max-width: 720px; }
.modal-dialog.xl { max-width: 960px; }
@keyframes modal-dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--primary); }
.modal-close {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-muted);
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 1.5rem; line-height: 1;
  transition: color 0.12s, background 0.12s;
}
.modal-close:hover { color: var(--text); background: var(--bg-hover, rgba(255,255,255,0.05)); }

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem;
}
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-strong, var(--border)); border-radius: 4px; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated, var(--bg-card));
  flex-shrink: 0;
}
.modal-footer.space-between { justify-content: space-between; }

/* When modal is open, prevent the background page from scrolling behind it. */
body.modal-open { overflow: hidden; }

/* Cards */
.card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card-interactive:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }

/* Navbar */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.75rem; background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.navbar .logo { font-size: 1.3rem; font-weight: 700; color: var(--primary); letter-spacing: -0.02em; }
.navbar nav { display: flex; gap: 1rem; align-items: center; }

/* Footer */
.footer {
  text-align: center; padding: 2rem 1.5rem; color: var(--text-muted);
  font-size: 0.85rem; border-top: 1px solid var(--border);
  margin-top: 3rem;
}
.lang-switch { display: inline-flex; gap: 0.4rem; margin-top: 0.5rem; }
.lang-switch button {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  padding: 0.3rem 0.7rem; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 0.8rem; font-weight: 500;
  transition: all 0.15s var(--ease);
}
.lang-switch button:hover { border-color: var(--border-strong); color: var(--text); }
.lang-switch button.active { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

/* Messages */
.alert {
  padding: 0.9rem 1.1rem; border-radius: var(--radius);
  margin-bottom: 1.25rem; font-size: 0.9rem;
  border: 1px solid transparent; line-height: 1.5;
}
.alert-error { background: rgba(220, 38, 38, 0.08); color: #f87171; border-color: rgba(220, 38, 38, 0.25); }
.alert-success { background: var(--primary-soft); color: var(--primary); border-color: rgba(20, 184, 166, 0.3); }
.alert-warning { background: rgba(245, 158, 11, 0.08); color: #fbbf24; border-color: rgba(245, 158, 11, 0.25); }
.alert-info { background: rgba(59, 130, 246, 0.08); color: #60a5fa; border-color: rgba(59, 130, 246, 0.25); }

/* Loader */
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 2.5rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 1.5rem 1rem; }
  h1 { font-size: 1.625rem; }
  h2 { font-size: 1.2rem; }
}
@media (max-width: 600px) {
  html { font-size: 15px; }
  .container { padding: 1.25rem 0.9rem; }
  .card { padding: 1.25rem; }
}

/* Utility */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }

/* === WCAG AA: Focus, Skip-to-content, Screen Reader === */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-to-content {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 10000;
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  border-radius: 0 0 var(--radius) 0;
  text-decoration: none;
}
.skip-to-content:focus {
  position: fixed;
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
