:root {
  /* FerroBoard Theme */
  --bg-dark: #141820;
  --bg-card: #1b2029;
  --bg-card-hover: #262c38;
  --bg-slot: #141820;
  --border-color: #343c4c;
  --border-glow: #4c8df6;
  --text-main: #e8ecf4;
  --text-muted: #8b94a7;
  --accent-purple: #4c8df6;
  --accent-purple-glow: transparent;
  --accent-dim: #2f5ba8;
  --accent-gold: #f0a24c;
  --accent-gold-glow: transparent;
  --accent-emerald: #4cd08a;
  --accent-emerald-glow: transparent;
  --accent-red: #e5534b;
  --accent-blue: #4c8df6;
  --radius-lg: 6px;
  --radius-md: 5px;
  --radius-sm: 4px;
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background glows removed (flat UI) */
.ambient-glow {
  display: none;
}
.glow-1, .glow-2 {
  background: none;
}

.app-layout {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  object-fit: cover;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-main {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-main);
}

.version-badge {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--bg-card-hover);
  color: var(--accent-purple);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-dim);
}

.clan-name {
  font-size: 0.85rem;
  color: var(--accent-gold);
  font-weight: 600;
  display: block;
}

.nav-tabs {
  display: flex;
  background: var(--bg-dark);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-tab:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.nav-tab.active {
  background: var(--accent-dim);
  color: var(--text-main);
  border: 1px solid var(--accent-purple);
}

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

.sync-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-emerald);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn-refresh {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-refresh:hover {
  background: var(--accent-dim);
  border-color: var(--accent-purple);
}

/* Stats Overview Bar */
.stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.12s ease;
}

.stat-card:hover {
  border-color: var(--accent-purple);
}

.stat-icon {
  font-size: 2rem;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  padding: 8px;
  border-radius: var(--radius-sm);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.stat-netherite .stat-value { color: var(--accent-red); }
.stat-diamonds .stat-value { color: var(--accent-blue); }
.stat-totems .stat-value { color: var(--accent-gold); }

/* Main Content & Tabs */
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Toolbar & Filters */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 300px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  font-size: 1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 40px 12px 44px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.12s ease;
}

.search-input-wrapper input:focus {
  border-color: var(--accent-purple);
}

.clear-search {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.filter-pills {
  display: flex;
  gap: 6px;
}

.pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.pill:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.pill.active {
  background: var(--accent-dim);
  color: var(--text-main);
  border-color: var(--accent-purple);
}

/* Items Grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  position: relative;
  overflow: hidden;
}

.item-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-purple);
}

.item-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.item-icon-box {
  width: 44px;
  height: 44px;
  background: var(--bg-slot);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  overflow: hidden;
}

/* Minecraft Pixel-Art Icons */
.mc-icon-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  vertical-align: middle;
}

.mc-pixel-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: transform 0.12s ease;
  user-select: none;
}

.item-card:hover .mc-pixel-icon {
  transform: scale(1.1);
}

.mc-icon-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal-icon-box {
  width: 48px;
  height: 48px;
  background: var(--bg-slot);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.modal-icon-box .mc-pixel-icon {
  width: 36px;
  height: 36px;
}

.audit-mini-icon {
  width: 18px !important;
  height: 18px !important;
  margin-right: 4px;
  vertical-align: -3px;
}

.item-name-block {
  flex: 1;
}

.item-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
}

.item-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.item-card-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-dark);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.item-count-badge {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.item-chests-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Audit Log Timeline */
.audit-header-bar, .chests-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.audit-title-block h2, .chests-header-bar h2 {
  font-size: 1.3rem;
  color: var(--text-main);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.audit-filter-wrapper input {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
}

.audit-filter-wrapper input:focus {
  border-color: var(--accent-purple);
}

.audit-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audit-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.audit-card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-card-hover);
}

.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-dark);
  image-rendering: pixelated;
  flex-shrink: 0;
}

.audit-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audit-primary-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.audit-player-name {
  font-weight: 700;
  color: var(--accent-gold);
}

.audit-action-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.action-withdrew {
  background: rgba(229, 83, 75, 0.15);
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.action-deposited {
  background: rgba(76, 208, 138, 0.15);
  color: var(--accent-emerald);
  border: 1px solid var(--accent-emerald);
}

.audit-container-name {
  font-size: 0.85rem;
  color: var(--text-main);
}

.audit-coords {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.audit-changes-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.diff-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.diff-positive {
  background: rgba(76, 208, 138, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(76, 208, 138, 0.5);
}

.diff-negative {
  background: rgba(229, 83, 75, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(229, 83, 75, 0.5);
}

.audit-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Chests Grid */
.chests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.chest-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.12s ease;
}

.chest-card:hover {
  border-color: var(--accent-purple);
}

.chest-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chest-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.dim-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.dim-overworld { background: rgba(76, 208, 138, 0.15); color: var(--accent-emerald); border-color: rgba(76, 208, 138, 0.5); }
.dim-nether { background: rgba(229, 83, 75, 0.15); color: var(--accent-red); border-color: rgba(229, 83, 75, 0.5); }
.dim-end { background: rgba(76, 141, 246, 0.15); color: var(--accent-purple); border-color: var(--accent-dim); }

.chest-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chest-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.btn-tp-copy {
  background: var(--bg-card-hover);
  border: 1px solid var(--accent-dim);
  color: var(--accent-purple);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.btn-tp-copy:hover {
  background: var(--accent-dim);
  color: var(--text-main);
}

.btn-danger-sm {
  background: var(--bg-card-hover);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.btn-danger-sm:hover {
  background: var(--accent-red);
  color: var(--text-main);
  border-color: var(--accent-red);
}

/* Setup & Guide */
.setup-guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.guide-intro {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.guide-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.guide-box {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-purple);
  text-transform: uppercase;
}

.guide-box h3 {
  font-size: 1.15rem;
  color: var(--text-main);
}

.guide-box ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-main);
  font-size: 0.88rem;
}

.guide-box code, .ingame-mod-box code {
  background: var(--bg-card-hover);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  color: var(--accent-gold);
  font-size: 0.82rem;
}

.ingame-mod-box {
  background: var(--bg-card-hover);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 12, 16, 0.8);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-count-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-gold);
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Toast */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card-hover);
  border: 1px solid var(--accent-emerald);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 2000;
}

.toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav-tabs {
    width: 100%;
    overflow-x: auto;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
