/* Mobile-first, modern minimal UI */
:root {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --surface: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0284c7;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --bonus: #a78bfa;
  --base: #38bdf8;
  --penalty: #fb7185;
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --tap: 44px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(165deg, var(--bg) 0%, #0c1222 50%, #020617 100%);
  min-height: 100dvh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.app-shell {
  max-width: 42rem;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 1rem 1.5rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.75rem 0;
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.1);
  text-decoration: none;
}

.nav-user {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-content {
  flex: 1;
  padding-top: 1rem;
}

.footer {
  margin-top: auto;
  padding-top: 2rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  color: var(--muted);
}

.flash {
  margin: 0.75rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.flash--ok {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: var(--success);
}
.flash--err {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--danger);
}

.card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.1);
  box-shadow: var(--shadow);
}

.card--muted {
  opacity: 0.85;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface);
  background: #0f172a;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--tap);
  padding: 0 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:active {
  transform: scale(0.98);
}
.btn--primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #0f172a;
}
.btn--primary:hover {
  filter: brightness(1.08);
  text-decoration: none;
}
.btn--danger {
  background: rgba(248, 113, 113, 0.25);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.4);
}
.btn--ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.25);
}
.btn--ghost:hover {
  color: var(--text);
  text-decoration: none;
}
.btn--sm {
  min-height: 36px;
  padding: 0 0.65rem;
  font-size: 0.85rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.progress {
  height: 10px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
@media (min-width: 380px) {
  .score-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .score-grid--5 {
    grid-template-columns: repeat(5, 1fr);
  }
}
.score-pill--exc {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.score-pill {
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.75rem;
}
.score-pill strong {
  display: block;
  font-size: 1.15rem;
  margin-top: 0.15rem;
}
.score-pill--base {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.score-pill--bonus {
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.25);
}
.score-pill--penalty {
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.25);
}
.score-pill--net {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.3);
  grid-column: 1 / -1;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge--pending {
  background: rgba(251, 191, 36, 0.2);
  color: var(--warning);
}
.badge--ok {
  background: rgba(52, 211, 153, 0.2);
  color: var(--success);
}
.badge--bad {
  background: rgba(248, 113, 113, 0.2);
  color: var(--danger);
}
.badge--draft {
  background: rgba(148, 163, 184, 0.2);
  color: var(--muted);
}

.list-plain {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list-plain li {
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
.list-plain li:last-child {
  border-bottom: none;
}

.timer-display {
  font-variant-numeric: tabular-nums;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
  margin: 0.5rem 0;
  color: var(--accent);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}
.photo-grid img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.simple {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.simple th,
table.simple td {
  padding: 0.5rem 0.35rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
}
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.week-table th,
.week-table td {
  text-align: center;
  min-width: 3rem;
  font-size: 0.8rem;
}
.week-table td:first-child,
.week-table th:first-child {
  text-align: left;
}
.week-cell {
  position: relative;
}
.week-cell--done {
  background: rgba(52, 211, 153, 0.18);
}
.week-cell--partial {
  background: rgba(251, 191, 36, 0.18);
}
.week-cell--missed {
  background: rgba(248, 113, 113, 0.15);
}
.week-cell--future {
  background: rgba(148, 163, 184, 0.08);
}
.week-cell--extra {
  background: rgba(167, 139, 250, 0.12);
}
.week-today {
  border-left: 2px solid var(--accent) !important;
  border-right: 2px solid var(--accent) !important;
}
.week-done {
  font-weight: 700;
}
.week-plan {
  color: var(--muted);
  font-size: 0.75rem;
}
.week-legend {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 2px;
}
.week-legend--done { background: rgba(52, 211, 153, 0.5); }
.week-legend--partial { background: rgba(251, 191, 36, 0.5); }
.week-legend--missed { background: rgba(248, 113, 113, 0.4); }
.week-legend--extra { background: rgba(167, 139, 250, 0.4); }

.color-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.color-swatch {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
}
.color-swatch:hover {
  transform: scale(1.15);
}
.color-swatch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.color-swatch input:checked + * ,
.color-swatch:has(input:checked) {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor;
}
.color-swatch:has(input:checked) {
  border-color: #fff;
}

.user-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 3px;
}

.subject-color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: #0f172a;
  flex-shrink: 0;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
