* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

:root {
  --primary-color: #5b6fa0;
  --primary-dark: #4a5a85;
  --secondary-color: #3d4e6d;
  --accent-color: #6b7fa5;
  --parent-name-color: #2563eb;
  --bg-gradient-1: linear-gradient(135deg, #3d4e6d 0%, #2a3a52 100%);
  --bg-gradient-2: linear-gradient(135deg, #5b6fa0 0%, #4a5a85 100%);
  --text-primary: #333;
  --text-secondary: #666;
  --text-light: #999;
  --bg-primary: white;
  --bg-secondary: #f8f9fa;
  --border-color: #e0e0e0;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.3);
}

body.dark-mode {
  --bg-gradient-1: linear-gradient(135deg, #0f1419 0%, #1a1f2e 100%);
  --bg-gradient-2: linear-gradient(135deg, #2d3748 0%, #1f2937 100%);
  --text-primary: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-light: #808080;
  --parent-name-color: #60a5fa;
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --border-color: #404040;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-gradient-1);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 20px;
  transition: background 0.3s, color 0.3s;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  width: 200%;
  height: 200%;
  background-image: url('resources/logo-pattern.png');
  background-repeat: repeat;
  background-size: 250px 250px;
  opacity: 0.03;
  z-index: -1;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(30deg);
  transform-origin: center;
}

.background-logo {
  display: none;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  background: var(--bg-gradient-2);
  color: white;
  padding: 30px 40px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 30px;
  margin-bottom: 20px;
}

.header-content {
  flex: 1;
}

.header h1 {
  font-size: 2.5em;
  font-weight: 700;
  margin-bottom: 5px;
}

.header p {
  font-size: 1.1em;
  opacity: 0.95;
}

/* Header Stats */
.header-stats {
  display: flex;
  gap: 20px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.15);
  padding: 12px 18px;
  border-radius: 8px;
  text-align: center;
  backdrop-filter: blur(10px);
  border: none;
  white-space: nowrap;
  min-width: 100px;
  flex: 1;
}

.stat-value {
  font-size: 1.8em;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8em;
  opacity: 0.9;
  margin-top: 4px;
}

/* Dark Mode Toggle */
.btn-dark-mode {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2em;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  width: 44px;
}

.btn-dark-mode:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

/* Header Actions */
.header-actions {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.btn-profile {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2em;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  width: 44px;
}

.btn-profile:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.search-bar {
  display: flex;
  gap: 10px;
  max-width: 500px;
}

.search-bar input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  transition: all 0.3s;
}

.search-bar input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.search-bar input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.btn-search {
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1em;
  transition: all 0.3s;
  font-weight: 600;
}

.btn-search:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

/* Main Content */
.main {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  border-bottom: 2px solid var(--border-color);
}

.tab-btn {
  padding: 12px 24px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 1.05em;
  font-weight: 600;
  color: var(--text-light);
  transition: all 0.3s;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.tab-btn:hover:not(:disabled) {
  color: var(--primary-color);
}

.tab-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Search Results */
.search-results {
  background: var(--bg-secondary);
  border: none;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 30px;
  transition: all 0.3s;
}

.search-results.hidden {
  display: none;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h2 {
  color: var(--primary-color);
  font-size: 1.4em;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.8em;
  color: var(--text-light);
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-close:hover {
  color: #e74c3c;
  transform: scale(1.1);
}

.search-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.filter-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.filter-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.results-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
  gap: 15px;
}

.results-list:has(.empty-state) {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60px;
}

.result-item {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s;
  position: relative;
  padding-right: 48px;
}

.result-item:hover {
  box-shadow: 0 4px 16px rgba(91, 111, 160, 0.2);
  transform: translateY(-2px);
}

.result-item h4 {
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 1.15em;
}

.result-item p {
  color: var(--text-secondary);
  font-size: 0.9em;
  margin: 4px 0;
  line-height: 1.5;
}

.result-actions {
  position: absolute;
  top: 10px;
  right: 10px;
}

.btn-go {
  padding: 5px 10px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8em;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-go:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--primary-color);
}

.item-location {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.location-badge {
  display: inline-block;
  background: var(--bg-secondary);
  color: var(--primary-color);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* Browse Section */
.browse-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  height: 70vh;
}

.list-panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.list-panel h3 {
  color: var(--primary-color);
  margin-bottom: 15px;
  font-size: 1.1em;
  flex-shrink: 0;
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  gap: 10px;
}

.column-header h3 {
  margin-bottom: 0;
  flex: 1;
}

.column-header h3 .parent-name {
  color: var(--parent-name-color);
  font-weight: 600;
}

.column-count {
  background: rgba(91, 111, 160, 0.15);
  border: none;
  color: var(--primary-color);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85em;
  font-weight: 600;
  min-width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}

.list-item {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.95em;
  color: var(--text-primary);
  font-weight: 500;
  position: relative;
  padding-right: 34px;
}

.list-item[data-item-id] {
  border-left: 4px solid var(--primary-color);
}

.list-item:hover {
  border-color: var(--primary-color);
  background: var(--bg-secondary);
}

.list-item.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(91, 111, 160, 0.3);
}

.edit-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 4px;
  font-size: 0.75em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  outline: none;
}

.list-item.active .edit-btn {
  opacity: 1;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.edit-btn:hover {
  color: var(--text-primary);
  background: rgba(91, 111, 160, 0.12);
  transform: translateY(-1px);
}

.item-qty {
  font-size: 0.85em;
  margin-top: 4px;
  color: var(--primary-color);
}

.list-item.active .item-qty {
  color: white;
}

.empty-state-mini {
  color: var(--text-light);
  text-align: center;
  padding: 20px;
  font-size: 0.9em;
}

.add-item-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  background: rgba(91, 111, 160, 0.08);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 1.2em;
  color: var(--text-light);
  font-weight: 600;
  margin-top: 8px;
}

.add-item-btn:hover {
  background: rgba(91, 111, 160, 0.15);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Direct Items Section */
.direct-items-section {
  margin-top: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.collapsible-header {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.95em;
  font-weight: 500;
  color: var(--text-primary);
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.collapsible-header::after {
  content: ' ▼';
  font-size: 0.8em;
  margin-left: 8px;
  transition: transform 0.3s;
}

.collapsible-header.collapsed::after {
  transform: rotate(-90deg);
}

.collapsible-header:hover {
  background: rgba(91, 111, 160, 0.1);
}

.collapsible-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--bg-primary);
  max-height: 500px;
  overflow-y: auto;
  transition: max-height 0.3s, padding 0.3s;
}

.collapsible-content.collapsed {
  max-height: 0;
  padding: 0;
  overflow: hidden;
}

.direct-item {
  padding: 10px 12px !important;
  font-size: 0.9em !important;
  background: var(--bg-secondary) !important;
}

.direct-item:hover {
  background: rgba(91, 111, 160, 0.1) !important;
}

.direct-item.active {
  background: var(--primary-color) !important;
  color: white;
  border-color: var(--primary-color) !important;
}

.details-content {
  animation: fadeIn 0.3s;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 1.2em;
  text-align: center;
  padding: 20px;
}

/* Manage Section */
.manage-container {
  display: flex;
  flex-direction: column;
  gap: 40px;
  max-width: 1200px;
}

.manage-section {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.manage-section:last-child {
  border-bottom: none;
}

.manage-section h3 {
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 1.15em;
}

.changelog-window {
  background: #000000;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  min-height: 300px;
  padding: 16px;
  color: #ffffff;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  overflow-y: auto;
  max-height: 500px;
}

.changelog-entry {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.2s;
}

.changelog-entry:hover {
  background: rgba(255, 255, 255, 0.05);
}

.changelog-entry:last-child {
  border-bottom: none;
}

.changelog-message {
  flex: 1;
  line-height: 1.6;
  word-break: break-word;
}

.changelog-message strong {
  color: #4ade80;
  font-weight: 600;
}

.changelog-time {
  color: #94a3b8;
  font-size: 0.85em;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.form-card {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 24px;
  border: 2px solid var(--border-color);
  transition: all 0.3s;
  box-shadow: var(--shadow-sm);
}

.form-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 16px rgba(91, 111, 160, 0.1);
}

.form-card h3 {
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 1.15em;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row input {
  flex: 1;
  max-width: 300px;
}

.form-row button {
  flex-shrink: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tags-management-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.owners-management-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: fit-content;
}

.tag-management-item {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-radius: 20px;
  justify-content: center;
}

.tag-management-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  margin-right: 4px;
}

.tag-management-preview {
  padding: 4px 10px;
  border-radius: 16px;
  color: white;
  font-size: 0.85em;
  white-space: nowrap;
  flex-shrink: 0;
}

.tag-management-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.tag-color-picker,
.owner-color-picker {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
}

.btn-delete-tag {
  width: 20px;
  height: 20px;
  padding: 0;
  background: none;
  color: #ff6b6b;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color 0.2s;
}

.btn-delete-tag:hover {
  color: #ff5252;
  background: none;
}

.btn-delete-owner {
  width: 20px;
  height: 20px;
  padding: 0;
  background: none;
  color: #ff6b6b;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color 0.2s;
}

.btn-delete-owner:hover {
  color: #ff5252;
  background: none;
}

.edit-form {
  gap: 12px;
}

.edit-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 0 6px;
  border-top: 1px solid var(--border-color);
}

#editSpaceFields,
#editStorageFields {
  padding: 0 !important;
  border: none !important;
}

.edit-item-fields {
  border: none;
  padding: 0;
  gap: 36px;
}

.edit-field-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.edit-field-group.full-width {
  width: 100%;
}

.edit-section-title {
  font-size: 0.95em;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin: 0;
  opacity: 0.8;
}

.edit-location-section {
  padding: 0;
  border: none;
}

.edit-location-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.edit-location-grid .edit-field-group {
  margin-top: 0;
}

.edit-details-section {
  padding: 0;
}

.edit-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 0;
}

.field-label {
  font-size: 0.75em;
  color: var(--text-secondary);
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.edit-form .field-label:first-of-type {
  margin-top: 0;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.95em;
  transition: all 0.3s;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-group select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-color: var(--bg-secondary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  background: color-mix(in srgb, var(--bg-secondary) 85%, var(--primary-color) 15%);
  box-shadow: 0 0 0 2px rgba(91, 111, 160, 0.2);
}

.form-group select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-group select:disabled {
  background-color: var(--bg-secondary);
  color: var(--text-light);
  opacity: 0.6;
  cursor: not-allowed;
}

.form-group textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.5;
  padding: 14px 16px;
}

.form-group input::placeholder {
  color: var(--text-light);
}

.form-group select::placeholder,
.form-group textarea::placeholder {
  color: var(--text-light);
}

/* Tag Input Styles */
.tag-input-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tags-display {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  min-height: 0;
  align-items: center;
}

.tag-input-field {
  position: relative;
  flex: 1 1 220px;
  min-width: 200px;
}

.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-color);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.9em;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.tag-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  cursor: pointer;
  font-weight: bold;
  opacity: 0.8;
  transition: opacity 0.2s;
  color: white;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 1.2em;
}

.tag-remove:hover {
  opacity: 1;
}

#editTagsInput {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.95em;
  transition: all 0.3s;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

#editTagsInput:focus {
  outline: none;
  background: color-mix(in srgb, var(--bg-secondary) 85%, var(--primary-color) 15%);
  box-shadow: 0 0 0 2px rgba(91, 111, 160, 0.2);
}

#editTagsInput::placeholder {
  color: var(--text-light);
}

.tag-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow-md);
}

.tag-suggestions.hidden {
  display: none;
}

.tag-suggestion-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}

.tag-suggestion-item:last-child {
  border-bottom: none;
}

/* Direct location options */
select option.direct-option {
  color: var(--primary-color);
  font-weight: 600;
}

/* Not-in options */
select option.not-in-option {
  color: var(--primary-color);
  font-weight: 400;
}

select option.not-in-option:hover,
select option.not-in-option:checked {
  color: var(--primary-color);
}

select.not-in-selected {
  opacity: 0.5;
  color: var(--text-secondary);
}

.tag-suggestion-item:hover,
.tag-suggestion-item.active {
  background: var(--bg-secondary);
}

.form-group button {
  align-self: flex-start;
}

/* Buttons */
.btn-primary {
  padding: 12px 24px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: all 0.3s;
}

.btn-primary:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.05);
}

.btn-primary:active {
  background: rgba(255, 255, 255, 0.1);
}

.btn-secondary {
  padding: 10px 16px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: 600;
  transition: all 0.2s;
  align-self: flex-start;
  margin-top: 8px;
}

.btn-secondary:hover {
  border-color: var(--primary-color);
  color: var(--text-primary);
  background: var(--bg-secondary);
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 16px 24px;
  background: #333;
  color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

.toast.success {
  background: #4caf50;
}

.toast.error {
  background: #f44336;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.3s;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s;
}

.edit-modal-content {
  max-width: 900px;
  width: 95%;
  padding: 40px 50px;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.edit-modal-content .modal-header {
  margin-bottom: 28px;
}

.modal-header h2 {
  color: var(--text-primary);
  font-size: 1.3em;
}

.color-picker-content {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 30px;
  max-width: 350px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s;
}

.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 20px;
}

.color-picker-option {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.color-picker-option:hover {
  transform: scale(1.1);
}

.color-picker-option.selected {
  border-color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 1200px) {
  .browse-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .container {
    border-radius: 0;
    min-height: 100vh;
  }

  .browse-container {
    grid-template-columns: 1fr;
    height: auto;
  }

  .list-panel {
    max-height: 400px;
  }

  .header {
    padding: 20px;
  }

  .header-top {
    flex-direction: column;
    gap: 15px;
  }

  .header h1 {
    font-size: 1.8em;
  }

  .header-stats {
    flex-wrap: wrap;
    gap: 12px;
  }

  .stat-item {
    flex: 1;
    min-width: 100px;
    padding: 10px 12px;
  }

  .stat-value {
    font-size: 1.5em;
  }

  .search-bar {
    max-width: 100%;
  }

  .main {
    padding: 20px;
  }

  .manage-container {
    gap: 20px;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .results-list {
    grid-template-columns: 1fr;
  }

  .search-bar input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}
/* View Modal Styles */
.view-field {
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: none;
  border-radius: 8px;
  color: var(--text-primary);
  word-wrap: break-word;
  white-space: normal;
  min-height: 40px;
  display: flex;
  align-items: center;
  font-family: inherit;
  font-size: 0.95em;
}

.view-textarea {
  white-space: pre-wrap;
  min-height: 140px;
  align-items: flex-start;
  padding: 14px 16px;
  line-height: 1.5;
}

#viewName {
  font-weight: 600;
}

/* View Modal Redesign */
.view-modal-content {
  max-width: 600px;
  border-left: 4px solid var(--primary-color);
}

.modal-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85em;
}

.edit-modal-content .modal-header {
  margin-bottom: 12px;
}

.view-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.view-image-frame {
  width: 100%;
  height: 200px;
  background: var(--bg-secondary);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-placeholder {
  color: var(--text-secondary);
  font-size: 0.95em;
  opacity: 0.7;
}

.view-item-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.view-section-spaced {
  margin-top: 12px;
}

.view-section-spaced-lg {
  margin-top: 20px;
}

.view-text {
  color: var(--text-primary);
  font-size: 0.95em;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: normal;
}

.view-description {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text-secondary);
}

.quantity-text {
  font-weight: 500;
  color: var(--primary-color);
}

#editItemBtn {
  margin-top: 8px;
  align-self: flex-start;
}

.view-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.owner-badge {
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 0.9em;
  white-space: nowrap;
}