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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
}

.screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.hidden {
  display: none !important;
}

.login-box {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.login-box h1 {
  margin-bottom: 16px;
  font-size: 24px;
}

.login-box p {
  margin-bottom: 20px;
  color: #8b949e;
}

.login-box input {
  width: 100%;
  padding: 12px;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #0d1117;
  color: #c9d1d9;
  font-size: 16px;
  margin-bottom: 12px;
}

.login-box input:focus {
  outline: none;
  border-color: #58a6ff;
}

.login-box button {
  width: 100%;
  padding: 12px;
  background: #238636;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}

.login-box button:hover {
  background: #2ea043;
}

.hint {
  font-size: 13px;
  color: #8b949e;
  margin-top: 16px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

header h1 {
  font-size: 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.btn-small {
  padding: 6px 12px;
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.btn-small:hover {
  background: #30363d;
}

.toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar button {
  padding: 8px 16px;
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.toolbar button:hover {
  background: #30363d;
}

.toolbar button.active {
  background: #1f6feb;
  border-color: #1f6feb;
  color: white;
}

.toolbar a {
  text-decoration: none;
}

.color-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.color-label {
  font-size: 12px;
  color: #8b949e;
  white-space: nowrap;
}
.color-cb {
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  font-size: 12px;
  color: #c9d1d9;
}
.color-cb input {
  cursor: pointer;
}
.color-mode-select {
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid #30363d;
  border-radius: 4px;
  background: #0d1117;
  color: #c9d1d9;
  cursor: pointer;
}

.error-msg {
  background: #3d1414;
  border: 1px solid #da3633;
  color: #ff7b72;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.success-msg {
  background: #143d1a;
  border: 1px solid #238636;
  color: #7ee787;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: #8b949e;
  padding: 40px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 20px 24px;
  flex-wrap: wrap;
}

.page-btn {
  padding: 6px 12px;
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.page-btn:hover {
  background: #30363d;
}

.page-btn.active {
  background: #1f6feb;
  border-color: #1f6feb;
  color: white;
}

.page-info {
  font-size: 13px;
  color: #8b949e;
  margin-left: 8px;
}

.toolbar-form {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  flex: 1;
  min-width: 280px;
}

.toolbar-form select {
  flex: 0 1 auto;
  min-width: 65px;
  padding: 5px 6px;
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  font-size: 12px;
}

.toolbar-form input[type="text"] {
  padding: 6px 10px;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #0d1117;
  color: #c9d1d9;
  font-size: 13px;
  min-width: 60px;
  flex: 1;
}

.toolbar-form input[type="text"]:focus {
  outline: none;
  border-color: #58a6ff;
}

.toolbar-form input[name="type"],
.toolbar-form input[name="keyword"] {
  max-width: 110px;
}

.toolbar-form input[name="search"] {
  max-width: 150px;
}

#import-section {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  margin: 16px 24px;
  padding: 20px;
}

#import-section h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

#import-section p {
  font-size: 13px;
  color: #8b949e;
  margin-bottom: 12px;
}

#import-section input[type="file"] {
  margin-bottom: 12px;
}

#import-section button {
  padding: 8px 16px;
  background: #238636;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  margin-right: 8px;
}

#import-section button:hover {
  background: #2ea043;
}

#import-status {
  margin-top: 12px;
  font-size: 13px;
}

#stats-bar {
  padding: 10px 24px;
  font-size: 13px;
  color: #8b949e;
  border-bottom: 1px solid #21262d;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 250px));
  gap: 16px;
  padding: 24px;
}

.card-item {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
  position: relative;
  display: flex;
  flex-direction: column;
}

.card-item:hover {
  border-color: #58a6ff;
}

.card-item.claimed {
  border-color: #d29922;
}

.card-item.claimed-by-me {
  border-color: #238636;
}

.card-image {
  width: 100%;
  aspect-ratio: 2.5 / 3.5;
  object-fit: cover;
  display: block;
  background: #0d1117;
}

.card-image-placeholder {
  width: 100%;
  aspect-ratio: 2.5 / 3.5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1117;
  color: #8b949e;
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

.card-info {
  padding: 10px 12px 4px;
  flex: 1;
}

.card-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-details {
  font-size: 12px;
  color: #8b949e;
  margin-bottom: 4px;
}

.card-rarity {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.card-rarity:empty { display: none; }
.card-rarity[data-rarity="common"] { color: #8b949e; }
.card-rarity[data-rarity="uncommon"] { color: #58a6ff; }
.card-rarity[data-rarity="rare"] { color: #d29922; }
.card-rarity[data-rarity="mythic"] { color: #f78166; }

.card-box-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #d2992244;
  color: #d29922;
  border: 1px solid #d2992266;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-box {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 5px;
  background: #d2992244;
  color: #d29922;
  border: 1px solid #d2992266;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-qty {
  font-size: 13px;
  margin-top: 4px;
}

.qty-total { font-weight: 600; color: #c9d1d9; }
.qty-claimed { color: #d29922; }
.qty-avail { color: #58a6ff; }

.card-claimed-by {
  font-size: 12px;
  color: #d29922;
  margin-top: 4px;
}

.card-claimed-by.me {
  color: #238636;
}

.card-claimers {
  padding: 0 12px 4px;
  font-size: 12px;
  min-height: 4em;
  overflow-y: auto;
  flex: 1;
}

.claimer {
  color: #8b949e;
  margin-top: 2px;
}

.claimer.me {
  color: #238636;
  font-weight: 600;
}

.card-actions {
  padding: 0 12px 10px;
  display: flex;
  gap: 4px;
  min-height: 32px;
  margin-top: auto;
}

.card-actions button {
  flex: 1;
  padding: 6px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

#batch-bar {
  position: sticky;
  bottom: 0;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #c9d1d9;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  z-index: 10;
  border-top: 1px solid #30363d;
}

#batch-bar.hidden {
  display: none;
}

.batch-info {
  font-weight: 600;
  font-size: 15px;
}

.batch-info #selected-count {
  font-size: 18px;
  background: #1f6feb;
  color: white;
  padding: 2px 10px;
  border-radius: 6px;
  margin-right: 4px;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#batch-bar .btn-small {
  padding: 7px 16px;
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

#batch-bar .btn-small:hover {
  background: #30363d;
}

.batch-delete-btn {
  padding: 7px 16px;
  background: #da3633;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.batch-delete-btn:hover {
  background: #f85149;
}

.card-checkbox {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  background: rgba(13, 17, 23, 0.7);
  border-radius: 4px;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.card-item:hover .card-checkbox,
.card-checkbox:has(input:checked) {
  opacity: 1;
}

.card-checkbox input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #1f6feb;
}

.card-item.selected {
  border-color: #1f6feb;
  box-shadow: 0 0 0 1px #1f6feb;
}

.btn-reserve {
  background: #238636;
  color: white;
}

.btn-reserve:hover {
  background: #2ea043;
}

.btn-unreserve {
  background: #da3633;
  color: white;
}

.btn-unreserve:hover {
  background: #f85149;
}

.btn-take {
  background: #1f6feb;
  color: white;
}

.btn-take:hover {
  background: #388bfd;
}

.btn-return {
  background: #da3633;
  color: white;
}

.btn-return:hover {
  background: #f85149;
}

.btn-disabled {
  background: #21262d;
  color: #8b949e;
  cursor: not-allowed;
}

.qty-reserved {
  color: #d29922;
}

.qty-taken {
  color: #58a6ff;
}

.claimer.reserved {
  color: #d29922;
}

.claimer.taken {
  color: #58a6ff;
}

.claimer.reserved.me {
  color: #7ee787;
  font-weight: 600;
}

.claimer.taken.me {
  color: #7ee787;
  font-weight: 600;
}

.autocomplete-box {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #161b22;
  border: 1px solid #30363d;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
}

.autocomplete-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #c9d1d9;
}

.autocomplete-item:hover {
  background: #1f6feb;
  color: white;
}

.toolbar {
  position: relative;
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: pointer;
}
.modal-overlay.hidden {
  display: none;
}
.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
  cursor: default;
}
.modal-close {
  position: absolute;
  top: -36px;
  right: 0;
  background: none;
  border: none;
  color: #8b949e;
  font-size: 28px;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}
.modal-close:hover {
  color: #c9d1d9;
}
.modal-inner {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.modal-image {
  width: auto;
  height: 65vh;
  max-width: 50vw;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.modal-side {
  min-width: 220px;
}
.modal-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}
.modal-details {
  font-size: 14px;
  color: #8b949e;
  margin-bottom: 8px;
}
.modal-qty {
  font-size: 14px;
  margin-bottom: 12px;
}
.modal-claimers {
  font-size: 14px;
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  gap: 8px;
}
.modal-actions button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.modal-actions .btn-reserve {
  background: #238636;
  color: white;
}
.modal-actions .btn-reserve:hover {
  background: #2ea043;
}
.modal-actions .btn-unreserve {
  background: #da3633;
  color: white;
}
.modal-actions .btn-unreserve:hover {
  background: #f85149;
}
.modal-actions .btn-take {
  background: #1f6feb;
  color: white;
}
.modal-actions .btn-take:hover {
  background: #388bfd;
}
.modal-actions .btn-return {
  background: #da3633;
  color: white;
}
.modal-actions .btn-return:hover {
  background: #f85149;
}
.modal-actions .btn-disabled {
  background: #21262d;
  color: #8b949e;
  cursor: not-allowed;
}
@media (max-width: 700px) {
  .modal-inner {
    flex-direction: column;
    align-items: center;
  }
  .modal-image {
    width: 80vw;
    height: auto;
    max-width: 350px;
  }
  .modal-side {
    min-width: 0;
    text-align: center;
  }
  .modal-actions {
    justify-content: center;
  }
}

.card-categories {
  padding: 2px 12px 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cat-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  background: #1f6feb22;
  color: #58a6ff;
  border: 1px solid #1f6feb44;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stats-actions {
  margin-left: 16px;
}

.stats-actions .btn-small {
  margin-right: 4px;
}

/* ── Mobile Optimierungen ── */

@media (max-width: 768px) {
  header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  header h1 {
    font-size: 17px;
  }
  .header-right {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .header-right .btn-small {
    padding: 5px 10px;
    font-size: 11px;
  }
  .header-right span {
    font-size: 12px;
    width: 100%;
    text-align: right;
  }

  .toolbar {
    padding: 10px 12px;
    gap: 6px;
  }
  .toolbar > a {
    flex: 1;
    min-width: 0;
  }
  .toolbar > a > button {
    width: 100%;
    padding: 7px 6px;
    font-size: 12px;
  }
  .toolbar select {
    font-size: 12px;
    padding: 6px 8px;
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 6px;
  }
  .toolbar-form {
    flex: 1;
    min-width: 0;
    width: 100%;
  }
  .toolbar-form select {
    flex: 1;
    min-width: 0;
    font-size: 12px;
  }
  .toolbar-form input[type="text"] {
    font-size: 16px;
    min-width: 0;
  }
  .toolbar-form input[name="type"],
  .toolbar-form input[name="keyword"],
  .toolbar-form input[name="search"] {
    max-width: none;
  }
  .toolbar form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    order: 1;
  }
  .toolbar form select {
    flex: 1;
    min-width: 0;
  }

  #stats-bar {
    padding: 8px 12px;
    font-size: 12px;
  }
  #stats-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .stats-right {
    justify-content: flex-start;
  }
  #stats-bar label {
    font-size: 12px;
  }
  #stats-bar .btn-small {
    padding: 4px 8px;
    font-size: 11px;
  }

  .cards-grid {
    padding: 10px;
    gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(140px, 180px));
  }

  .card-name {
    font-size: 12px;
  }
  .card-details,
  .card-qty,
  .card-claimed-by {
    font-size: 11px;
  }
  .card-info {
    padding: 6px 8px 2px;
  }
  .card-categories {
    padding: 1px 8px 1px;
    gap: 2px;
  }
  .cat-tag {
    font-size: 8px;
    padding: 1px 4px;
  }
  .card-claimers {
    padding: 0 8px 2px;
    font-size: 11px;
    min-height: 3em;
    flex: 1;
  }
  .card-actions {
    padding: 0 8px 8px;
    gap: 3px;
  }
  .card-actions button {
    font-size: 11px;
    padding: 5px 4px;
  }

  .card-checkbox {
    opacity: 1;
  }
  .card-checkbox input {
    width: 20px;
    height: 20px;
  }

  #batch-bar {
    padding: 10px 12px;
    font-size: 13px;
    gap: 6px;
  }
  .batch-info {
    font-size: 13px;
  }
  .batch-info #selected-count {
    font-size: 15px;
  }
  #batch-bar .btn-small,
  .batch-delete-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .pagination {
    padding: 14px 12px;
    gap: 4px;
  }
  .page-btn {
    padding: 5px 9px;
    font-size: 12px;
  }
  .page-info {
    font-size: 11px;
    margin-left: 4px;
  }
}

@media (max-width: 480px) {
  .login-box {
    padding: 24px 16px;
  }
  .login-box h1 {
    font-size: 20px;
  }
  .login-box input,
  .login-box button {
    font-size: 16px;
    padding: 10px;
  }

  header h1 {
    font-size: 15px;
  }
  .header-right .btn-small {
    font-size: 10px;
    padding: 4px 8px;
  }
  .header-right span {
    font-size: 11px;
  }

  .toolbar {
    flex-direction: column;
    padding: 8px 10px;
    gap: 4px;
  }
  .toolbar > a {
    flex: none;
    width: 100%;
  }
  .toolbar > a > button {
    width: 100%;
    padding: 8px 8px;
    font-size: 12px;
  }
  .toolbar form {
    gap: 4px;
  }
  .toolbar-form {
    flex-direction: column;
  }
  .toolbar-form select,
  .toolbar-form input[type="text"] {
    width: 100%;
  }

  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 8px;
  }

  .card-name {
    font-size: 11px;
  }
  .card-details,
  .card-qty,
  .card-claimers {
    font-size: 10px;
    flex: 1;
  }
  .card-actions button {
    font-size: 10px;
    padding: 4px 3px;
  }

  #stats-bar {
    font-size: 11px;
  }
  .stats-right {
    gap: 4px;
  }

  .pagination {
    gap: 3px;
    padding: 10px 8px;
  }
  .page-btn {
    padding: 4px 7px;
    font-size: 11px;
  }

  .modal-overlay {
    padding: 12px;
  }
  .modal-image {
    width: 90vw;
    max-width: 300px;
  }
  .modal-name {
    font-size: 16px;
  }
  .modal-details,
  .modal-qty,
  .modal-claimers {
    font-size: 13px;
  }
  .modal-actions button {
    font-size: 13px;
    padding: 8px 14px;
  }
  .modal-close {
    font-size: 24px;
    top: -30px;
  }

  .admin-layout {
    padding: 12px;
    gap: 12px;
  }
  .admin-section {
    min-width: 0;
    padding: 14px;
  }

  #import-section {
    margin: 10px 12px;
    padding: 14px;
  }
  #import-section h2 {
    font-size: 15px;
  }
  #import-section textarea {
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .cards-grid {
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    padding: 6px;
  }
  .card-actions {
    flex-direction: column;
    gap: 2px;
  }

  .toolbar-form select {
    width: 100%;
  }

  .stats-right {
    flex-wrap: wrap;
    gap: 3px;
  }
}
