:root {
  --top-nav-height: 71px;
}

body {
  font-family: 'Roboto', sans-serif;
  background: #f2f2f2;
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: auto 1fr;
  padding: 0;
  margin: 0;
  min-height: 100vh;
  position: relative;
}

#top-nav {
  grid-column: 1 / -1;
  grid-row: 1;
}

#sidebar {
  grid-column: 1;
  grid-row: 2;
}

#main-content {
  grid-column: 2;
  grid-row: 2;
}

#top-nav {
  background: #1d1f2a;
  border-bottom: 2px solid #e04f2b;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 999;
  flex-wrap: wrap;
}

#toggle-sidebar-btn {
  width: 40px;
  height: 40px;
  background: #1d1f2a;
  color: #e04f2b;
  border: 2px solid #e04f2b;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.5rem;
  display: block;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

#toggle-sidebar-btn:hover {
  background: #e04f2b;
  color: white;
}

#database-selector {
  padding: 10px 15px;
  background: #2b2d3a;
  border: 2px solid #444;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #ccc;
  transition: all 0.3s ease;
  flex-shrink: 0;
  font-weight: 600;
}

#database-selector:hover {
  background: #e04f2b;
  color: white;
  border-color: #e04f2b;
}

#database-selector:focus {
  outline: none;
  background: #e04f2b;
  color: white;
  border-color: #e04f2b;
}

#sidebar {
  width: 250px;
  background: #fff;
  border-right: 2px solid #222;
  position: sticky;
  top: var(--top-nav-height);
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease;
  z-index: 99;
  height: calc(100vh - var(--top-nav-height));
  max-height: calc(100vh - var(--top-nav-height));
  align-self: start;
}

#sidebar.hidden {
  width: 0;
  border-right: none;
  overflow: hidden;
}

#operative-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  padding: 20px 20px 20px 20px;
  flex: 1;
  margin-top: 0;
}

.operative-item {
  padding: 10px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.operative-item:hover {
  background: #e04f2b;
  color: white;
  border-color: #e04f2b;
}

#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  display: flex;
  justify-content: center;
  min-height: min-content;
  transition: flex 0.3s ease;
}

#main-content.sidebar-hidden {
  flex: 1;
}

#tabs-container {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab-button {
  padding: 10px 18px;
  background: #2b2d3a;
  border: 2px solid #444;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ccc;
  transition: all 0.3s ease;
}

.tab-button:hover {
  background: #e04f2b;
  color: white;
  border-color: #e04f2b;
}

.tab-button.active {
  background: #f05a28;
  color: white;
  border-color: #f05a28;
}

#cards-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 800px;
}

#cards-container.operatives-view {
  display: flex;
}

#cards-container.ploys-view {
  display: flex;
}

.card {
  width: 100%;
  background: white;
  border: 2px solid #222;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.card-header {
  background: #1d1f2a;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 4px solid #e04f2b;
}

.card-header h1 {
  font-size: 1.4rem;
  letter-spacing: 1px;
}

.stats {
  display: flex;
  gap: 12px;
}

.stat {
  background: #2b2d3a;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.weapon-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 5px;
}

.weapon-table th {
  background: #f05a28;
  color: #fff;
  text-align: left;
  padding: 8px;
  font-size: 0.9rem;
}

.weapon-table td {
  padding: 8px;
  border-bottom: 1px solid #ccc;
  font-size: 0.9rem;
}

.weapon-table tr:nth-child(even) {
  background: #f9f9f9;
}

.rules {
  padding: 15px 20px;
  font-size: 0.9rem;
  line-height: 1.4;
  border-top: 1px dashed #ccc;
  border-bottom: 1px dashed #ccc;
}

.rules strong {
  color: #e04f2b;
}

.footer {
  background: #1d1f2a;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 15px;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

.ploys-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  max-width: 800px;
}

.ploy-item {
  background: white;
  border: 2px solid #222;
  border-radius: 6px;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
}

.ploy-item:hover {
  box-shadow: 0 6px 15px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}

.ploy-item h3 {
  margin: 0 0 10px 0;
  color: #f05a28;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
}

.ploy-item p {
  margin: 0;
  color: #333;
  font-size: 0.95rem;
  line-height: 1.5;
}

.equipment-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  max-width: 800px;
}

.equipment-item {
  background: white;
  border: 2px solid #222;
  border-radius: 6px;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
}

.equipment-item:hover {
  box-shadow: 0 6px 15px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}

.equipment-item h3 {
  margin: 0 0 10px 0;
  color: #f05a28;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
}

.equipment-item p {
  margin: 0;
  color: #333;
  font-size: 0.95rem;
  line-height: 1.5;
}

.ratial-container {
  background: white;
  border: 2px solid #222;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 800px;
  overflow: hidden;
}

.ratial-header {
  background: #1d1f2a;
  color: white;
  padding: 30px 20px;
  border-bottom: 4px solid #f05a28;
  text-align: center;
}

.ratial-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.ratial-subtitle {
  color: #f05a28;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 1px;
  margin-top: 10px;
}

.ratial-section {
  padding: 20px;
  border-bottom: 1px solid #ddd;
}

.ratial-section:last-child {
  border-bottom: none;
}

.ratial-section h3 {
  color: #f05a28;
  font-size: 1.1rem;
  margin: 0 0 10px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.ratial-section p {
  color: #333;
  font-size: 0.95rem;
  margin: 0;
  line-height: 1.6;
}

.ratial-section ul {
  color: #333;
  font-size: 0.95rem;
  margin: 0;
  padding-left: 20px;
  line-height: 1.6;
}

.ratial-section li {
  margin: 8px 0;
}

.ratial-section strong {
  color: #1d1f2a;
  font-weight: 600;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  max-width: 800px;
}

.rule-item {
  background: white;
  border: 2px solid #222;
  border-radius: 6px;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
}

.rule-item:hover {
  box-shadow: 0 6px 15px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}

.rule-item h3 {
  margin: 0 0 10px 0;
  color: #f05a28;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
}

.rule-item p {
  margin: 0;
  color: #333;
  font-size: 0.95rem;
  line-height: 1.5;
}

#cards-container.hidden {
  display: none;
}

#cards-container.visible {
  display: flex;
}

/* Mobile responsive - sidebar positioning */
@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  #top-nav {
    grid-column: 1;
    grid-row: 1;
  }

  #sidebar {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 2px solid #222;
    transition: max-height 0.3s ease;
    overflow: hidden;
    max-height: 500px;
  }

  #sidebar.hidden {
    max-height: 0;
    overflow: hidden;
  }

  #main-content {
    grid-column: 1;
    grid-row: 3;
    padding: 20px;
  }

  #operative-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 15px;
    margin-top: 0;
  }
}
