:root {
  color-scheme: dark;
  --bg: #0b0d0f;
  --panel: #13171b;
  --panel-2: #1a1f24;
  --panel-3: #22282f;
  --line: #2b333b;
  --text: #f3f6f8;
  --muted: #98a3ad;
  --lime: #b6ff4a;
  --lime-dark: #183000;
  --blue: #6cb8ff;
  --orange: #ffad5b;
  --danger: #ff6b6b;
  --radius: 18px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 15%, rgba(182, 255, 74, .12), transparent 28%),
    radial-gradient(circle at 90% 85%, rgba(108, 184, 255, .09), transparent 30%),
    var(--bg);
}

.login-card {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 38px;
  background: rgba(19, 23, 27, .92);
  box-shadow: var(--shadow);
}

.login-card h1 { font-size: clamp(38px, 10vw, 60px); letter-spacing: -.055em; margin: 10px 0 12px; line-height: .95; }
.login-card .field { margin: 28px 0 12px; }
.android-link { display: block; text-align: center; color: var(--muted); margin-top: 20px; font-size: 14px; }
.form-error { min-height: 22px; color: var(--danger); margin: 5px 0 10px; }

.brand-mark {
  width: 64px;
  height: 64px;
  display: inline-grid;
  place-items: center;
  border-radius: 19px;
  color: #0b0d0f;
  background: var(--lime);
  font-size: 24px;
  font-weight: 950;
  letter-spacing: -.06em;
  box-shadow: 0 10px 32px rgba(182, 255, 74, .2);
}
.brand-mark.small { width: 44px; height: 44px; border-radius: 13px; font-size: 17px; }
.eyebrow { margin: 0; color: var(--lime); font-size: 12px; font-weight: 850; letter-spacing: .16em; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #0e1114;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; text-decoration: none; }
.brand strong { display: block; font-size: 20px; letter-spacing: -.03em; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.main-nav { display: grid; gap: 6px; }
.main-nav button, .mobile-nav button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.main-nav button {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  border-radius: 13px;
  padding: 13px 14px;
  text-align: left;
  font-weight: 700;
}
.main-nav button:hover { color: var(--text); background: var(--panel); }
.main-nav button.active { color: var(--lime); background: var(--lime-dark); }
.main-nav button[data-view="running"].active { color: var(--blue); background: rgba(108,184,255,.1); }
.nav-icon { width: 24px; text-align: center; font-size: 20px; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 8px; }

.main-content { width: min(100%, 1500px); margin: 0 auto; padding: 38px clamp(22px, 4vw, 64px) 80px; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-header h1 { font-size: clamp(36px, 5vw, 58px); letter-spacing: -.055em; margin: 5px 0 0; line-height: 1; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.view-root { min-height: 500px; }
.sync-banner { padding: 12px 15px; margin: -10px 0 20px; border: 1px solid rgba(255, 173, 91, .35); border-radius: 12px; color: var(--orange); background: rgba(255, 173, 91, .08); }

.button {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 16px;
  color: var(--text);
  background: var(--panel-3);
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); border-color: #46515d; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.button.primary { background: var(--lime); color: #0a0c0e; }
.button.primary:hover { background: #c3ff6b; border-color: var(--lime); }
.button.run-primary { color: #07111a; background: var(--blue); }
.button.run-primary:hover { border-color: var(--blue); background: #8ac8ff; }
.button.ghost { border-color: var(--line); background: transparent; }
.button.subtle { color: var(--muted); background: transparent; }
.button.danger { color: var(--danger); border-color: rgba(255,107,107,.3); background: rgba(255,107,107,.08); }
.button.wide { width: 100%; display: block; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--muted); background: var(--panel-2); cursor: pointer; font-size: 25px; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 18px; margin-bottom: 18px; }
.hero-card, .card, .stat-card, .detail-card, .chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.hero-card { min-height: 250px; padding: 28px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; }
.hero-card::after { content: ""; position: absolute; width: 300px; height: 300px; right: -100px; bottom: -180px; border-radius: 50%; background: var(--lime); filter: blur(1px); opacity: .12; }
.hero-card h2 { font-size: clamp(30px, 4vw, 48px); letter-spacing: -.045em; margin: 10px 0; }
.timer { font-variant-numeric: tabular-nums; font-size: clamp(44px, 7vw, 82px); font-weight: 950; letter-spacing: -.06em; line-height: .9; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; position: relative; z-index: 1; }
.quick-card { padding: 24px; display: flex; flex-direction: column; justify-content: space-between; }
.quick-card h3 { font-size: 24px; margin: 5px 0 8px; }

.running-section { --run: var(--blue); }
.run-eyebrow { color: var(--blue); }
.run-hero {
  min-height: 240px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(270px, .75fr);
  align-items: end;
  gap: 24px;
  overflow: hidden;
  position: relative;
  padding: 30px;
  border: 1px solid rgba(108, 184, 255, .3);
  border-radius: 24px;
  background:
    radial-gradient(circle at 90% 20%, rgba(108, 184, 255, .24), transparent 34%),
    linear-gradient(135deg, #111b24, var(--panel));
}
.run-hero h2 { max-width: 780px; margin: 8px 0; font-size: clamp(34px, 5vw, 62px); line-height: .95; letter-spacing: -.055em; }
.run-hero p:not(.eyebrow) { max-width: 660px; margin: 8px 0 0; color: #afbbc6; }
.run-hero .timer { color: var(--blue); font-size: clamp(42px, 6vw, 72px); }
.run-mark { justify-self: end; color: rgba(108, 184, 255, .13); font-size: clamp(74px, 12vw, 150px); font-weight: 950; font-style: italic; line-height: .7; letter-spacing: -.09em; transform: translate(5px, 12px); }
.running-stats .stat-card { border-color: rgba(108, 184, 255, .2); }
.running-stats .stat-card strong { color: var(--blue); }
.run-charts .chart-card { border-color: rgba(108, 184, 255, .2); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.stat-card { padding: 19px; }
.stat-card strong { display: block; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.04em; }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: .08em; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin: 34px 0 14px; }
.section-head h2 { font-size: 25px; margin: 0; letter-spacing: -.035em; }
.section-head p { margin: 4px 0 0; color: var(--muted); }

.list { display: grid; gap: 10px; }
.list-card { width: 100%; border: 1px solid var(--line); border-radius: 15px; padding: 16px; color: var(--text); background: var(--panel); display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer; }
.list-card:hover { border-color: #46515d; background: var(--panel-2); }
.list-card-main { flex: 1; min-width: 0; }
.list-card h3 { margin: 0; font-size: 18px; }
.list-card p { margin: 4px 0 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-card .right { text-align: right; }
.list-card .right strong { display: block; color: var(--lime); }
.activity-icon { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; border-radius: 14px; color: var(--lime); background: var(--lime-dark); font-size: 21px; font-weight: 900; }
.activity-icon.run { color: var(--blue); background: rgba(108,184,255,.12); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; color: var(--muted); background: var(--panel-3); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.pill.active { color: var(--lime); background: var(--lime-dark); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.search { flex: 1; min-width: 220px; }
.search input { width: 100%; }

.split-layout { display: grid; grid-template-columns: minmax(290px, .75fr) minmax(0, 1.4fr); gap: 18px; align-items: start; }
.split-list { display: grid; gap: 9px; max-height: calc(100vh - 210px); overflow-y: auto; padding-right: 4px; }
.detail-card { padding: 24px; min-width: 0; }
.detail-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.detail-head h2 { margin: 4px 0 5px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.045em; }
.detail-head p { margin: 0; color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 18px 0; }
.metric { border-radius: 12px; padding: 13px; background: var(--panel-2); }
.metric strong { display: block; font-size: 22px; }
.metric span { color: var(--muted); font-size: 10px; letter-spacing: .08em; font-weight: 800; }
.description-box { padding: 16px; border-left: 3px solid var(--lime); border-radius: 0 12px 12px 0; background: var(--panel-2); white-space: pre-wrap; color: #cbd2d8; }

.sets-table { width: 100%; border-collapse: collapse; }
.sets-table th { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-align: left; padding: 9px; }
.sets-table td { border-top: 1px solid var(--line); padding: 11px 9px; }
.sets-table tr[data-set-id] { cursor: pointer; }
.sets-table tr[data-set-id]:hover td { background: var(--panel-2); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); }
.photo img { display: block; width: 100%; height: 130px; object-fit: cover; }
.photo p { margin: 0; padding: 10px; color: var(--muted); font-size: 13px; }

.machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 13px; }
.machine-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 19px; background: var(--panel); cursor: pointer; }
.machine-card:hover { border-color: #46515d; transform: translateY(-1px); }
.machine-card h3 { margin: 10px 0 5px; font-size: 21px; }
.machine-card p { height: 42px; margin: 0; color: var(--muted); overflow: hidden; }
.machine-card .machine-stats { margin-top: 16px; display: flex; gap: 14px; color: var(--lime); font-size: 13px; font-weight: 800; }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-top: 14px; }
.chart-card { padding: 17px; overflow: hidden; }
.chart-card h3 { margin: 0; font-size: 18px; }
.chart-card p { margin: 4px 0 14px; color: var(--muted); font-size: 13px; }
.chart { width: 100%; height: 220px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { stroke: var(--lime); stroke-width: 4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: url(#chartGradient); opacity: .3; }
.chart .point { fill: var(--lime); stroke: var(--panel); stroke-width: 3; }
.chart-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.chart-range { color: var(--muted); font-size: 12px; margin-top: 8px; }

.weight-hero { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.current-weight { display: flex; flex-direction: column; justify-content: center; padding: 26px; }
.current-weight strong { font-size: clamp(50px, 7vw, 82px); line-height: .9; letter-spacing: -.06em; }
.current-weight .weight-unit { margin-left: 8px; font-size: 18px; letter-spacing: 0; }
.trend.up { color: var(--orange); }
.trend.down { color: var(--lime); }

.empty { border: 1px dashed #39434d; border-radius: var(--radius); padding: 34px; text-align: center; color: var(--muted); background: rgba(19,23,27,.5); }
.empty strong { display: block; color: var(--text); font-size: 20px; margin-bottom: 6px; }

.modal { width: min(92vw, 840px); max-height: 90vh; overflow: auto; border: 1px solid var(--line); border-radius: 22px; padding: 0; color: var(--text); background: var(--panel); box-shadow: var(--shadow); }
.modal.compact { width: min(92vw, 570px); }
.modal::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(5px); }
.modal form { display: grid; gap: 16px; padding: 25px; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 15px; }
.modal-head h2 { margin: 4px 0 0; font-size: 30px; letter-spacing: -.04em; }
.modal-actions { display: flex; align-items: center; gap: 9px; margin-top: 5px; }
.form-grid { display: grid; gap: 13px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; }
.field > span { font-size: 12px; color: #bdc6ce; font-weight: 800; letter-spacing: .04em; }
.field small { color: var(--muted); font-size: 11px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #35404a;
  border-radius: 11px;
  padding: 12px 13px;
  color: var(--text);
  background: #0d1013;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--lime); box-shadow: 0 0 0 3px rgba(182,255,74,.08); }
textarea { resize: vertical; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: 380px; padding: 13px 17px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--panel-3); box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,107,107,.45); color: #ffc0c0; }
.mobile-nav { display: none; }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid.four { grid-template-columns: repeat(2, 1fr); }
  .split-layout { grid-template-columns: 1fr; }
  .split-list { max-height: 380px; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main-content { padding: 24px 16px 105px; }
  .page-header { align-items: start; }
  .page-header h1 { font-size: 38px; }
  .header-actions .button span.optional { display: none; }
  .mobile-nav { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; height: 76px; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(14,17,20,.94); border-top: 1px solid var(--line); backdrop-filter: blur(15px); }
  .mobile-nav button { display: grid; place-items: center; align-content: center; gap: 2px; font-size: 10px; font-weight: 750; }
  .mobile-nav button span { font-size: 21px; }
  .mobile-nav button.active { color: var(--lime); }
  .mobile-nav button[data-view="running"].active { color: var(--blue); }
  .hero-grid, .weight-hero, .charts, .run-hero { grid-template-columns: 1fr; }
  .hero-card { min-height: 280px; }
  .run-hero { min-height: 270px; padding: 24px 20px; }
  .run-mark { display: none; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .detail-card { padding: 17px; }
  .detail-head { display: block; }
  .detail-actions { margin-top: 14px; }
  .form-grid.two, .form-grid.four { grid-template-columns: 1fr; }
  .modal form { padding: 19px; }
  .modal-actions { flex-wrap: wrap; }
  .sets-table th:nth-child(4), .sets-table td:nth-child(4) { display: none; }
  .login-card { padding: 28px 22px; }
  .toast { left: 16px; right: 16px; bottom: 92px; }
}
