:root {
  --bg-primary: #0b0f19;
  --bg-card: #131b2e;
  --bg-input: #1a243b;
  --border-color: #23314f;
  --border-focus: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-blue: #2563eb;
  --accent-amber: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --transition: all 0.2s ease-in-out;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }

html, body { width: 100%; max-width: 100%; overflow-x: hidden; }

body {
  background: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
}

.container { max-width: 920px; margin: 0 auto; padding: 10px 8px; width: 100%; }
.container-narrow { max-width: 420px; }

.page-logo { width: 72px; height: 72px; margin: 6px auto 10px; display: block; object-fit: contain; }

.page-title { font-size: 20px; font-weight: 700; text-align: center; }
.page-sub { color: var(--text-muted); font-size: 12px; text-align: center; margin: 4px 0 12px; }

.compact-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #93c5fd;
  margin-bottom: 8px;
}

.grid-2, .grid-3 { display: grid; gap: 8px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-input, .form-select {
  width: 100%;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 14px;
  outline: none;
}

.form-input.is-missing {
  border-color: rgba(239, 68, 68, 0.7);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

.form-select:focus {
  background-color: #1e3a5f;
}

.form-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #94a3b8 50%), linear-gradient(135deg, #94a3b8 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; text-decoration: none; transition: var(--transition);
}
.btn-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; width: 100%; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-input); border: 1px solid var(--border-color); color: #cbd5e1; }
.btn-sm { padding: 7px 12px; font-size: 13px; width: auto; }
.btn-danger { background: rgba(239, 68, 68, 0.16); border: 1px solid rgba(239, 68, 68, 0.45); color: #f87171; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.28); }

.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.admin-save-row { margin-top: 14px; }
.admin-save-row .btn-primary { width: auto; min-width: 180px; }

.alert { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.alert-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); color: #f87171; }
.alert-ok { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.35); color: #34d399; }

.roster-wrap { overflow-x: auto; }
.roster {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
.roster th, .roster td { padding: 6px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.roster th { font-size: 11px; color: var(--text-muted); text-align: left; font-weight: 600; }
.roster .col-num { width: 72px; }
.roster .col-role { width: 88px; }
.roster .col-pos { width: 140px; }
.roster .col-del { width: 42px; }

.role-btn {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #94a3b8;
  border-radius: 6px;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.role-btn.active-c { background: rgba(245,158,11,.18); border-color: var(--accent-amber); color: #fbbf24; }
.role-btn.active-a { background: rgba(59,130,246,.18); border-color: #3b82f6; color: #93c5fd; }

.mini-del {
  background: transparent; border: none; color: #94a3b8; cursor: pointer; font-size: 16px; padding: 4px 8px;
}
.mini-del:hover { color: var(--accent-red); }

.hint { font-size: 12px; color: var(--text-muted); margin: 8px 0 0; }
.header-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }

.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  width: 100%;
}
.admin-card:hover { border-color: #3b82f6; }
.admin-card h3 { font-size: 16px; }
.admin-card p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #1e293b; color: #93c5fd; }

.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-bottom: 14px; font-size: 14px; }
.detail-meta span { color: var(--text-muted); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.role-pill { font-size: 11px; font-weight: 700; margin-left: 6px; color: #fbbf24; }

.nav-links { display: flex; gap: 8px; justify-content: flex-end; margin: 8px 0 12px; }

.edit-link-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}
.edit-link-box .form-input { font-size: 12px; }

@media (max-width: 720px) {
  .grid-2, .grid-3, .detail-meta { grid-template-columns: 1fr; }
  .page-logo { width: 56px; height: 56px; }
  .container { padding: 10px 8px; }
  .roster-wrap { overflow: visible; }
  .roster {
    min-width: 0;
    display: block;
  }
  .roster thead { display: none; }
  .roster tbody { display: block; }
  .roster tr {
    display: grid;
    grid-template-columns: 48px repeat(10, minmax(0, 1fr)) 40px;
    gap: 8px;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
  }
  .roster td {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border: none;
    padding: 0;
    width: auto;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }
  .roster td::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 3px;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .roster td.col-num { grid-column: 1; grid-row: 1; }
  .roster td:nth-child(2) { grid-column: 2 / 7; grid-row: 1; }
  .roster td:nth-child(3) { grid-column: 7 / 13; grid-row: 1; }
  .roster td:nth-child(4) { grid-column: 1 / 6; grid-row: 2; }
  .roster td.col-pos { grid-column: 6 / 10; grid-row: 2; }
  .roster td.col-role { grid-column: 10 / 12; grid-row: 2; }
  .roster td.col-del {
    grid-column: 12;
    grid-row: 2;
    align-self: end;
    justify-content: center;
    overflow: visible;
  }
  .roster td.col-del::before { content: none; display: none; }
  .roster .form-input,
  .roster .form-select,
  .roster .role-btn {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 7px 9px;
    font-size: 14px;
    box-sizing: border-box;
  }
  .roster .col-num .form-input {
    padding-left: 4px;
    padding-right: 4px;
    text-align: center;
  }
  .roster .mini-del {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
  }
}
