body {
  background-color: var(--bg-app);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.admin-header {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  line-height: 1;
}

.brand-tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent-teal);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  padding: 3px 7px;
  border-radius: 4px;
  line-height: 1;
}

.admin-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 30px 24px;
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.admin-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 250px;
  min-width: 240px;
  flex-shrink: 0;
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  position: sticky;
  top: 90px;
  box-sizing: border-box;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: var(--accent-teal);
  background: rgba(6, 182, 212, 0.12);
  border-left: 3px solid var(--accent-teal);
}

.admin-pane {
  display: none;
  flex-grow: 1;
  width: calc(100% - 282px);
  min-width: 0;
}

.admin-pane.active {
  display: block;
}

@media (max-width: 960px) {
  .admin-container {
    flex-direction: column;
    align-items: stretch;
    padding: 20px 16px;
  }

  .admin-tabs {
    width: 100%;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .tab-btn {
    width: auto;
  }

  .admin-pane {
    width: 100%;
  }
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--text-main);
  font-family: inherit;
  box-sizing: border-box;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-teal);
}

.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  background: rgba(0,0,0,0.3);
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.btn-action-edit {
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.2);
  color: var(--accent-teal);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-action-edit:hover {
  background: var(--accent-teal);
  color: #0f172a;
}

.btn-action-del {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-action-del:hover {
  background: var(--accent-red);
  color: #fff;
}

/* Modal dialog styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-medium);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  transform: scale(0.95);
  transition: transform var(--transition-medium);
}

.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

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

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

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px;
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--text-main);
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent-teal);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-admin {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-yellow);
}

.badge-user {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--accent-teal);
}

.sql-editor-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.sql-editor-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.sql-editor-header h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.sql-editor-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.sql-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sql-textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: 14px;
  background: rgba(15,23,42,0.7);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text-main);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  box-sizing: border-box;
  outline: none;
}

.sql-textarea:focus {
  border-color: var(--accent-teal);
}

.sql-status {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.sql-results-container {
  min-height: 120px;
}

.sql-results,
.sql-results-empty {
  min-width: 100%;
}

.sql-results-empty {
  padding: 28px;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

.sql-results-error {
  color: var(--accent-red);
}

.sql-results-table td {
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
}

.sql-null {
  color: var(--text-muted);
  font-style: italic;
}

.product-import-panel {
  margin-top: 0;
}

.product-import-upload {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

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

.product-import-upload input[type="file"] {
  width: 100%;
  padding: 10px;
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--text-main);
  box-sizing: border-box;
}

.product-import-summary {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}

.product-import-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.product-import-stat {
  background: rgba(15,23,42,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
}

.product-import-stat span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.product-import-stat strong {
  font-size: 1.1rem;
}

.product-import-list,
.product-import-errors,
.product-import-success {
  background: rgba(15,23,42,0.45);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
}

.product-import-list strong,
.product-import-errors strong {
  display: block;
  margin-bottom: 6px;
}

.product-import-list span {
  color: var(--text-muted);
  line-height: 1.5;
}

.product-import-error {
  color: var(--accent-red);
  padding: 4px 0;
}

.product-import-success {
  color: var(--accent-teal);
  font-weight: 600;
}

.product-import-sql-preview {
  min-height: 260px;
}

.product-import-validation {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-import-validation.valid {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
}

.product-import-validation.invalid {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.06);
}

.validation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.validation-title {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.product-import-validation.valid .validation-title {
  color: var(--accent-teal);
}

.product-import-validation.invalid .validation-title {
  color: var(--accent-red);
}

.validation-format-tag {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 4px;
}

.validation-columns-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.column-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.column-pill.matched {
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--text-main);
}

.column-pill.missing {
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--accent-red);
}

.column-badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 4px;
  font-family: monospace;
}

.column-badge.badge-primary {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-teal);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.column-badge.badge-secondary {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.badge-required {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.import-guide-table code {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent-teal);
}

/* Excel Spreadsheet Mockup */
.excel-mockup-intro {
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.excel-window-mockup {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  margin-bottom: 20px;
}

.excel-window-bar {
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.excel-window-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.excel-sheet-tabs {
  display: flex;
  gap: 4px;
}

.excel-tab {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px 4px 0 0;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
}

.excel-tab.active {
  background: #0f172a;
  color: var(--accent-teal);
  border-color: rgba(6, 182, 212, 0.4);
  border-bottom: 2px solid var(--accent-teal);
}

.excel-sheet-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.excel-grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
}

.excel-grid-table th,
.excel-grid-table td {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 10px;
}

.excel-col-letters th {
  background: #1e293b;
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  padding: 6px 12px;
}

.excel-col-letters th .col-purpose {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

.excel-col-letters th.highlight-b,
.excel-col-letters th.highlight-c {
  background: rgba(6, 182, 212, 0.18);
  color: var(--accent-teal);
  border-top: 2px solid var(--accent-teal);
}

.excel-col-letters th.highlight-d,
.excel-col-letters th.highlight-i,
.excel-col-letters th.highlight-m,
.excel-col-letters th.highlight-n,
.excel-col-letters th.highlight-r {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border-top: 2px solid #10b981;
}

.excel-col-letters th.col-empty-col {
  background: rgba(15, 23, 42, 0.7);
  color: #64748b;
  min-width: 45px;
}

.excel-row-num-col,
.excel-row-num {
  width: 38px;
  min-width: 38px;
  background: #1e293b;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  user-select: none;
}

.excel-row-header {
  background: rgba(30, 41, 59, 0.8);
  font-weight: 700;
  color: #cbd5e1;
}

.excel-row-header td.cell-key {
  color: var(--text-main);
  background: rgba(6, 182, 212, 0.08);
}

.excel-row-category {
  background: rgba(56, 189, 248, 0.12);
}

.excel-cat-cell {
  background: rgba(56, 189, 248, 0.18);
  font-weight: 800;
  color: #38bdf8;
  font-size: 0.9rem;
}

.excel-cat-title {
  margin-right: 10px;
  letter-spacing: 0.5px;
}

.excel-cat-badge {
  font-size: 0.68rem;
  background: rgba(56, 189, 248, 0.25);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #bae6fd;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.excel-empty-notice {
  color: #64748b;
  font-style: italic;
  font-size: 0.75rem;
  text-align: center;
}

.excel-row-item:nth-child(even) {
  background: rgba(15, 23, 42, 0.4);
}

.excel-row-item:nth-child(odd) {
  background: rgba(30, 41, 59, 0.3);
}

.excel-row-item td.cell-name {
  font-weight: 600;
  color: #f8fafc;
}

.excel-row-item td.cell-unit {
  text-align: center;
  color: #94a3b8;
}

.excel-row-item td.cell-num {
  text-align: right;
  color: #cbd5e1;
}

.excel-row-item td.cell-price {
  text-align: right;
  font-weight: 700;
  color: #34d399;
}

.excel-row-item td.cell-coeff {
  text-align: right;
  font-weight: 600;
  color: #fbbf24;
}

.excel-row-item td.cell-purchase {
  text-align: right;
  font-weight: 700;
  color: #60a5fa;
}

.excel-row-item td.cell-link a {
  color: #38bdf8;
  text-decoration: underline;
}

.excel-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.excel-rule-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.rule-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.rule-content strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.rule-content p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .sql-editor-header {
    flex-direction: column;
  }

  .sql-actions {
    width: 100%;
    justify-content: stretch;
  }

  .sql-actions .btn {
    flex: 1;
  }

  .product-import-stats {
    grid-template-columns: 1fr;
  }
}
