/* ===========================================================
   IRONLOG design system
   Palette is drawn from real weight-plate colors (IPF/IWF
   convention): 25kg=red, 20kg=blue, 15kg=yellow, 10kg=green.
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Surfaces - warm graphite, like rubber gym flooring, not pure black */
  --bg: #15181B;
  --bg-elevated: #1E2227;
  --bg-elevated-2: #272C32;
  --bg-input: #1A1E22;
  --border: rgba(242, 240, 234, 0.09);
  --border-strong: rgba(242, 240, 234, 0.18);

  /* Text - chalk white down to muted grey-blue */
  --text-primary: #F2F0EA;
  --text-secondary: #9CA5AC;
  --text-tertiary: #6B7480;

  /* Plate-derived accents */
  --plate-red: #E2402D;      /* 25kg / primary accent, CTAs */
  --plate-red-dim: #5C2620;
  --plate-blue: #3E7CB1;     /* 20kg / secondary data series */
  --plate-yellow: #D4A33B;   /* 15kg / PR gold, highlights */
  --plate-green: #4F9D69;    /* 10kg / positive deltas, gains */
  --plate-white: #C9CCD1;    /* 5kg / neutral data series */

  --negative: #C9594A;

  /* Type */
  --font-display: 'Oswald', sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout */
  --sidebar-width: 232px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(226,64,45,0.06), transparent 40%),
    radial-gradient(circle at 85% 100%, rgba(62,124,177,0.05), transparent 40%);
  background-attachment: fixed;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.01em; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--plate-red); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated-2); border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------- Layout shell ---------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.3s ease;
}

.sidebar-toggle-btn {
  position: absolute;
  top: 24px;
  right: -14px;
  width: 28px;
  height: 28px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  color: var(--text-secondary);
  transition: color 0.15s, transform 0.3s ease;
}
.sidebar-toggle-btn:hover { color: var(--text-primary); }
.sidebar-toggle-btn svg { width: 16px; height: 16px; }

.app-shell.sidebar-collapsed .sidebar {
  width: 70px;
}
.app-shell.sidebar-collapsed .sidebar-toggle-btn {
  transform: rotate(180deg);
}
.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-link span {
  display: none;
}
.app-shell.sidebar-collapsed .brand {
  padding: 4px 0 24px;
  justify-content: center;
}
.app-shell.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 10px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 24px;
}

.brand-mark {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--plate-red);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--font-display); font-size: 17px; letter-spacing: 0.04em; }
.brand-text span { font-size: 10.5px; color: var(--text-tertiary); letter-spacing: 0.06em; text-transform: uppercase; }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-link:hover { background: var(--bg-elevated-2); color: var(--text-primary); }
.nav-link.active { background: var(--plate-red-dim); color: #F2B6AC; }
.nav-link.active svg { opacity: 1; }
.nav-link-logout { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; margin-bottom: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

.main-content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 64px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 28px; }
.page-header .subtitle { color: var(--text-secondary); font-size: 13.5px; margin-top: 4px; }

/* Mobile nav toggle */
.mobile-topbar { display: none; }

@media (max-width: 880px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: fixed; inset: 0 0 auto 0; height: auto; width: 100%;
    flex-direction: row; align-items: center; justify-content: space-between;
    padding: 12px 16px; z-index: 50; border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { padding: 0; }
  .nav-list { display: none; position: fixed; top: 60px; left: 0; right: 0; bottom: 0;
    background: var(--bg-elevated); flex-direction: column; padding: 12px; overflow-y: auto; z-index: 49; }
  .nav-list.open { display: flex; }
  .nav-link-logout { margin-top: 12px; }
  .sidebar-toggle-btn { display: none; }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px;
    border-radius: var(--radius-sm); background: var(--bg-elevated-2); border: none; color: var(--text-primary); cursor: pointer; }
  .main-content { padding: 84px 18px 48px; max-width: 100%; }
}

/* ---------------- Components ---------------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-weight: 600;
  margin-bottom: 14px;
}

.grid { display: grid; gap: 18px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: 1.3fr 1fr; }
.grid-2-even { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid-2, .grid-2-even { grid-template-columns: 1fr; } }

.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-tertiary); font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 32px; font-weight: 600; line-height: 1; display: flex; align-items: baseline; gap: 6px; }
.stat-value .unit { font-family: var(--font-body); font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.stat-delta { font-size: 12.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; width: fit-content; }
.stat-delta.positive { color: var(--plate-green); }
.stat-delta.negative { color: var(--negative); }
.stat-delta.neutral { color: var(--text-tertiary); }

/* Barbell-sleeve divider - the signature motif */
.bar-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 28px 0 18px;
}
.bar-divider .collar { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.bar-divider .rail { flex: 1; height: 1px; background: var(--border); }
.bar-divider .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-tertiary); font-weight: 600; white-space: nowrap; }

/* Plate-loading progress bar (signature element) */
.plate-progress { display: flex; align-items: center; gap: 14px; }
.plate-rack { flex: 1; height: 10px; background: var(--bg-input); border-radius: 6px; overflow: hidden; position: relative; border: 1px solid var(--border); }
.plate-rack-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--plate-blue), var(--plate-red)); transition: width 0.5s ease; }
.plate-progress .pct { font-family: var(--font-mono); font-size: 13px; color: var(--text-secondary); flex-shrink: 0; min-width: 42px; text-align: right; }

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--plate-red); color: #fff; }
.btn-primary:hover { background: #f04a35; }
.btn-secondary { background: var(--bg-elevated-2); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: #313740; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); }
.btn-danger { background: transparent; color: var(--negative); border-color: rgba(201,89,74,0.35); }
.btn-danger:hover { background: rgba(201,89,74,0.1); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.field .hint { font-size: 11.5px; color: var(--text-tertiary); }
input, select, textarea {
  font-family: var(--font-body);
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--plate-red); box-shadow: 0 0 0 3px rgba(226,64,45,0.15); }
input::placeholder { color: var(--text-tertiary); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); font-weight: 600; padding: 0 10px 10px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 13px; }
.data-table td.label-cell { font-family: var(--font-body); font-weight: 500; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.015); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { background: transparent; border: none; color: var(--text-tertiary); cursor: pointer; padding: 4px; border-radius: 4px; display: inline-flex; }
.icon-btn:hover { color: var(--negative); background: rgba(201,89,74,0.1); }
.icon-btn svg { width: 15px; height: 15px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-gold { background: rgba(212,163,59,0.15); color: var(--plate-yellow); }
.badge-green { background: rgba(79,157,105,0.15); color: var(--plate-green); }
.badge-blue { background: rgba(62,124,177,0.15); color: var(--plate-blue); }
.badge-grey { background: var(--bg-elevated-2); color: var(--text-secondary); }

/* Insight list */
.insight-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.insight-item { display: flex; align-items: flex-start; gap: 11px; padding: 12px 4px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.insight-item:last-child { border-bottom: none; }
.insight-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--plate-red); margin-top: 6px; flex-shrink: 0; }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-tertiary); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 14px; opacity: 0.4; }
.empty-state p { font-size: 13.5px; max-width: 320px; margin: 0 auto; }

/* Toast / alert */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 9px; }
.alert-error { background: rgba(201,89,74,0.12); color: #E89488; border: 1px solid rgba(201,89,74,0.25); }
.alert-success { background: rgba(79,157,105,0.12); color: #8FCBA3; border: 1px solid rgba(79,157,105,0.25); }

.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg-elevated-2); border: 1px solid var(--border-strong); color: var(--text-primary); padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-card); animation: toast-in 0.2s ease; max-width: 320px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Tabs */
.tabs { display: flex; gap: 2px; background: var(--bg-input); border-radius: var(--radius-sm); padding: 3px; width: fit-content; margin-bottom: 18px; }
.tab { padding: 7px 16px; font-size: 13px; font-weight: 600; border-radius: 5px; cursor: pointer; color: var(--text-secondary); }
.tab.active { background: var(--bg-elevated-2); color: var(--text-primary); }

/* Utility */
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--plate-red); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block { display: flex; align-items: center; justify-content: center; padding: 48px; color: var(--text-tertiary); gap: 10px; font-size: 13px; }

/* ---------------- Auth page ---------------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}

.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 28px; text-align: center; }
.auth-brand .brand-mark { width: 44px; height: 44px; font-size: 18px; }
.auth-brand h1 { font-size: 22px; letter-spacing: 0.03em; }
.auth-brand p { font-size: 12.5px; color: var(--text-tertiary); margin-top: 2px; }

.auth-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-secondary); }
.auth-switch a { color: var(--plate-red); font-weight: 600; cursor: pointer; }
