/* ============================================================================
   RUCK — Design System
   Revolut-style fintech UX, themed with Escola Rugby do Porto brand colors.
   ========================================================================== */

:root {
  /* Brand colors (from escolarugbyporto.pt) */
  --brand-red: #e84545;
  --brand-red-dark: #c93636;
  --brand-red-light: #ff6b6b;
  --brand-navy: #32353a;
  --brand-navy-dark: #212226;

  /* Neutral scale */
  --n-0: #ffffff;
  --n-25: #fbfbfc;
  --n-50: #f5f6f8;
  --n-100: #eceef2;
  --n-200: #dfe2e8;
  --n-300: #c6cbd4;
  --n-400: #9aa1b0;
  --n-500: #6b7280;
  --n-600: #4b5160;
  --n-700: #363a45;
  --n-800: #24262e;
  --n-900: #16171c;

  /* Semantic */
  --success: #1fb178;
  --success-bg: #e7f9f2;
  --warning: #f5a623;
  --warning-bg: #fef4e2;
  --danger: #e8455a;
  --danger-bg: #fdeaec;
  --info: #3d8bfd;
  --info-bg: #eaf2ff;

  /* Surfaces */
  --bg-app: var(--n-50);
  --bg-card: var(--n-0);
  --bg-elevated: var(--n-0);
  --text-primary: var(--brand-navy-dark);
  --text-secondary: var(--n-500);
  --text-tertiary: var(--n-400);
  --border-subtle: var(--n-100);
  --border-default: var(--n-200);

  /* Radius */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* Shadows — soft, layered, Revolut-like */
  --shadow-xs: 0 1px 2px rgba(22, 23, 28, 0.04);
  --shadow-sm: 0 2px 8px rgba(22, 23, 28, 0.06);
  --shadow-md: 0 8px 24px rgba(22, 23, 28, 0.08);
  --shadow-lg: 0 16px 40px rgba(22, 23, 28, 0.12);
  --shadow-red: 0 8px 20px rgba(232, 69, 69, 0.28);

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 0.15s;
  --t-med: 0.25s;
  --t-slow: 0.4s;

  /* Layout */
  --sidebar-w: 264px;
  --topbar-h: 68px;
  --bottomnav-h: 68px;
  --content-max: 1180px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg-app: #0f1014;
  --bg-card: #1a1c22;
  --bg-elevated: #21232b;
  --text-primary: #f4f5f7;
  --text-secondary: #a3a8b5;
  --text-tertiary: #6b7280;
  --border-subtle: #24262e;
  --border-default: #2e313b;
  --n-50: #17181e;
  --n-100: #1f212a;
  color-scheme: dark;
}

/* -------------------------------------------------------------------------
   Reset & base
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease);
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; }
::selection { background: rgba(232, 69, 69, 0.2); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--n-300); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--n-400); }

/* -------------------------------------------------------------------------
   Typography utilities
   ------------------------------------------------------------------------- */
.text-hero { font-size: 34px; font-weight: 800; line-height: 1.1; letter-spacing: -0.03em; }
.text-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.text-subtitle { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.text-body { font-size: 15px; font-weight: 400; color: var(--text-primary); }
.text-caption { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.text-micro { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; }
.text-mono-lg { font-family: 'Inter', sans-serif; font-size: 32px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-brand { color: var(--brand-red) !important; }

/* -------------------------------------------------------------------------
   App Shell Layout
   ------------------------------------------------------------------------- */
#app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 28px;
}
.sidebar-logo .mark {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow-red);
  flex-shrink: 0;
}
.sidebar-logo .name { font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.sidebar-logo .name span { color: var(--brand-red); }

.nav-group { margin-bottom: 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  margin-bottom: 2px;
  position: relative;
}
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover { background: var(--n-50); color: var(--text-primary); }
.nav-item.active { background: var(--brand-red); color: #fff; box-shadow: var(--shadow-red); }
[data-theme="dark"] .nav-item:hover { background: var(--n-100); }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border-subtle); }

.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  background: rgba(245, 246, 248, 0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  z-index: 50;
  border-bottom: 1px solid var(--border-subtle);
}
[data-theme="dark"] .topbar { background: rgba(15, 16, 20, 0.85); }

.content {
  padding: 24px 28px 48px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* Bottom nav — mobile only */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border-subtle);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
[data-theme="dark"] .bottom-nav { background: rgba(26,28,34,0.92); }
.bottom-nav-inner { display: flex; height: var(--bottomnav-h); }
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-tertiary);
  font-size: 10.5px;
  font-weight: 600;
  transition: color var(--t-fast) var(--ease);
  position: relative;
}
.bottom-nav-item i { font-size: 19px; transition: transform var(--t-fast) var(--ease-spring); }
.bottom-nav-item.active { color: var(--brand-red); }
.bottom-nav-item.active i { transform: translateY(-2px) scale(1.05); }
.bottom-nav-item .fab-more {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
  display: flex; align-items: center; justify-content: center;
  color: white; margin-top: -22px;
  box-shadow: var(--shadow-red);
}

@media (max-width: 980px) {
  .sidebar { display: none; }
  .main-area { margin-left: 0; }
  .bottom-nav { display: block; }
  .content { padding: 16px 16px calc(var(--bottomnav-h) + 24px); }
  .topbar { padding: 0 16px; }
}

/* -------------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  transition: box-shadow var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-flat { box-shadow: none; }
.card-pad-lg { padding: 28px; }

.hero-card {
  border-radius: var(--r-xl);
  background: linear-gradient(135deg, var(--brand-navy-dark) 0%, var(--brand-navy) 55%, #46323a 100%);
  color: #fff;
  padding: 28px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.hero-card::after {
  content: '';
  position: absolute;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(232,69,69,0.35), transparent 70%);
  top: -100px; right: -80px;
  border-radius: 50%;
  pointer-events: none;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-card .icon-badge { width: 40px; height: 40px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; margin-bottom: 8px; font-size: 17px; }

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 22px;
  border-radius: var(--r-full);
  font-weight: 700;
  font-size: 14.5px;
  border: none;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand-red); color: #fff; box-shadow: var(--shadow-red); }
.btn-primary:hover { background: var(--brand-red-dark); }
.btn-dark { background: var(--brand-navy-dark); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-secondary { background: var(--n-100); color: var(--text-primary); }
.btn-secondary:hover { background: var(--n-200); }
.btn-ghost { background: transparent; color: var(--text-primary); }
.btn-ghost:hover { background: var(--n-50); }
.btn-outline { background: transparent; border: 1.5px solid var(--border-default); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--brand-red); color: var(--brand-red); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success-bg); color: var(--success); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-sm { height: 36px; padding: 0 16px; font-size: 13px; border-radius: var(--r-full); }
.btn-lg { height: 54px; padding: 0 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.fab {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + 20px);
  right: 20px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-red);
  z-index: 150;
  border: none;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-spring);
}
.fab:active { transform: scale(0.92); }
@media (min-width: 981px) {
  .fab { bottom: 32px; right: 32px; }
}

/* -------------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.field-hint { font-size: 12px; color: var(--text-tertiary); }
.input, .select, textarea.input {
  height: 48px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border-default);
  background: var(--bg-card);
  padding: 0 16px;
  font-size: 15px;
  color: var(--text-primary);
  width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
textarea.input { height: auto; padding: 12px 16px; min-height: 90px; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 4px rgba(232, 69, 69, 0.12);
}
.input::placeholder { color: var(--text-tertiary); }
.select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa1b0' stroke-width='1.6' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 36px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.search-box { position: relative; }
.search-box i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }
.search-box .input { padding-left: 44px; }

/* -------------------------------------------------------------------------
   Badges / Pills / Avatars
   ------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--n-100); color: var(--text-secondary); }

.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  background: linear-gradient(135deg, var(--brand-navy), var(--brand-navy-dark));
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 44px; height: 44px; font-size: 15px; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }
.avatar-xl { width: 96px; height: 96px; font-size: 28px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r-full);
  background: var(--n-100); color: var(--text-primary);
  font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: all var(--t-fast) var(--ease); border: 1.5px solid transparent;
  white-space: nowrap;
}
.chip.active { background: var(--brand-navy-dark); color: #fff; }
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }

/* -------------------------------------------------------------------------
   Lists / rows
   ------------------------------------------------------------------------- */
.list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  transition: background var(--t-fast) var(--ease);
  cursor: pointer;
}
.list-row:hover { background: var(--n-50); }
.list-row + .list-row { margin-top: 2px; }
.list-row-content { flex: 1; min-width: 0; }
.list-row-title { font-weight: 700; font-size: 14.5px; }
.list-row-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.list-row-end { text-align: right; flex-shrink: 0; }
.list-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }

/* -------------------------------------------------------------------------
   Modals / Sheets
   ------------------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(16, 17, 20, 0.55);
  backdrop-filter: blur(4px);
  z-index: 900;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med) var(--ease);
}
.overlay.open { opacity: 1; pointer-events: auto; }
@media (min-width: 720px) {
  .overlay { align-items: center; }
}
.sheet {
  background: var(--bg-card);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 8px 24px 24px;
  overflow-y: auto;
  transform: translateY(40px);
  transition: transform var(--t-med) var(--ease-spring);
  box-shadow: var(--shadow-lg);
}
.overlay.open .sheet { transform: translateY(0); }
@media (min-width: 720px) {
  .sheet { border-radius: var(--r-xl); margin: 20px; }
}
.sheet-handle { width: 40px; height: 4px; background: var(--n-200); border-radius: var(--r-full); margin: 10px auto 18px; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.sheet-close { width: 34px; height: 34px; border-radius: 50%; background: var(--n-100); display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; color: var(--text-secondary); }

/* -------------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------------- */
.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; width: 100%; padding: 0 16px; pointer-events: none; }
.toast {
  background: var(--brand-navy-dark); color: #fff;
  padding: 13px 20px; border-radius: var(--r-full);
  font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-16px);
  transition: all var(--t-med) var(--ease-spring);
  max-width: 420px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--brand-red-light); }

/* -------------------------------------------------------------------------
   Skeleton loaders
   ------------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--n-100) 25%, var(--n-200) 37%, var(--n-100) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* -------------------------------------------------------------------------
   Tables (desktop)
   ------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.data-table td { padding: 14px; border-bottom: 1px solid var(--border-subtle); font-size: 14px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr { transition: background var(--t-fast) var(--ease); }
.data-table tbody tr:hover { background: var(--n-50); }

/* -------------------------------------------------------------------------
   Misc utilities
   ------------------------------------------------------------------------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; } .mb-32 { margin-bottom: 32px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.w-full { width: 100%; }
.rounded-full { border-radius: var(--r-full); }
.relative { position: relative; }
.text-center { text-align: center; }
.pointer { cursor: pointer; }
.divider { height: 1px; background: var(--border-subtle); margin: 20px 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state i { font-size: 40px; color: var(--n-300); margin-bottom: 16px; display: block; }

.fade-in { animation: fadeIn var(--t-med) var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.3); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.spinner-dark { border: 3px solid var(--n-200); border-top-color: var(--brand-red); }
@keyframes spin { to { transform: rotate(360deg); } }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }
.section-label { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 14px; }
