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

:root {
  --primary: #c0392b;
  --primary-dark: #96281b;
  --bg: #f5f5f5;
  --card: #ffffff;
  --border: #e0e0e0;
  --text: #222;
  --muted: #666;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}

body { font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }

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

header {
  background: var(--primary);
  color: #fff;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 52px;
}
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; }
header nav { display: flex; gap: 1rem; }
header nav a { color: rgba(255,255,255,.85); font-size: .9rem; }
header nav a:hover { color: #fff; text-decoration: none; }

main { max-width: 900px; margin: 1.5rem auto; padding: 0 1rem 2rem; }

h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; color: var(--primary-dark); }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; margin-bottom: 1rem; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: .75rem; font-weight: 600; }
.badge-active { background: #d4edda; color: #155724; }
.badge-locked { background: #f8d7da; color: #721c24; }
.badge-muzi { background: #dbeafe; color: #1e40af; }
.badge-zeny { background: #fce7f3; color: #9d174d; }
.badge-dorastenci { background: #dcfce7; color: #166534; }
.badge-dorastenky { background: #fef3c7; color: #92400e; }
.badge-D { background: #fee2e2; color: #991b1b; }
.badge-N { background: #f3f4f6; color: #374151; }
.badge-saved { background: #d1fae5; color: #065f46; }

/* Buttons */
.btn { display: inline-block; padding: .45rem .9rem; border-radius: var(--radius); border: none; cursor: pointer; font-size: .9rem; font-weight: 500; transition: opacity .15s; }
.btn:hover { opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #6b7280; color: #fff; }
.btn-sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* Forms */
.form-group { margin-bottom: .85rem; }
label { display: block; font-size: .88rem; font-weight: 500; margin-bottom: .3rem; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=decimal], select, textarea {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 100px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { background: #f9fafb; font-weight: 600; text-align: left; padding: .55rem .75rem; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.rank-cell { font-weight: 700; width: 2.5rem; color: var(--muted); }

/* Season filter */
.season-filter { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.season-btn { padding: .35rem .85rem; border-radius: 20px; border: 1px solid var(--border); background: var(--card); cursor: pointer; font-size: .88rem; }
.season-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Competition list */
.comp-list { display: grid; gap: .75rem; }
.comp-card { display: flex; align-items: center; gap: 1rem; padding: .85rem 1rem; }
.comp-card .comp-info { flex: 1; min-width: 0; }
.comp-card .comp-name { font-weight: 600; }
.comp-card .comp-meta { font-size: .85rem; color: var(--muted); }
.comp-card .comp-actions { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }

/* Admin */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.25rem; }
.tab-btn { padding: .6rem 1.1rem; border: none; background: none; cursor: pointer; font-size: .95rem; border-bottom: 3px solid transparent; margin-bottom: -2px; color: var(--muted); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Sortable list */
.sortable-list { list-style: none; }
.sortable-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .85rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .4rem; cursor: grab; }
.sortable-item:active { cursor: grabbing; }
.drag-handle { color: #aaa; font-size: 1.1rem; flex-shrink: 0; }
.sortable-item .item-name { flex: 1; font-weight: 500; }

/* Results entry */
.entry-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.entry-row:last-child { border-bottom: none; }
.entry-row .entry-num { width: 2rem; color: var(--muted); font-size: .85rem; text-align: right; flex-shrink: 0; }
.entry-row .entry-name { flex: 1; min-width: 120px; font-weight: 500; }
.entry-row .time-inputs { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.entry-row .time-inputs input { width: 90px; }
.entry-result-display { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* Login */
.login-box { max-width: 360px; margin: 3rem auto; }

/* Alert */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* Refresh info */
.refresh-info { font-size: .82rem; color: var(--muted); margin-bottom: 1rem; }

/* Copy btn */
.copy-btn { font-size: .78rem; padding: .2rem .5rem; }

/* Startlist (public) */
.startlist-section { margin-bottom: 1.5rem; }

/* Grid helpers */
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--muted); }
.text-sm { font-size: .85rem; }
.fw-bold { font-weight: 700; }

@media (max-width: 600px) {
  h1 { font-size: 1.25rem; }
  .comp-card { flex-direction: column; align-items: flex-start; }
  .entry-row .time-inputs input { width: 80px; }
}
