/* ═══════════════════════════════════════════════
   EightDish Edcrm — Mantine Design Language
   ═══════════════════════════════════════════════ */

:root {
  --mantine-primary: #228be6;
  --mantine-primary-hover: #1c7ed6;
  --mantine-primary-light: #e7f5ff;
  --mantine-primary-shadow: rgba(34, 139, 230, 0.3);
  --mantine-dark: #1a1b1e;
  --mantine-dark-hover: #25262b;
  --mantine-gray-0: #f8f9fa;
  --mantine-gray-1: #f1f3f5;
  --mantine-gray-2: #e9ecef;
  --mantine-gray-3: #dee2e6;
  --mantine-gray-4: #ced4da;
  --mantine-gray-5: #adb5bd;
  --mantine-gray-6: #868e96;
  --mantine-gray-7: #495057;
  --mantine-gray-8: #343a40;
  --mantine-text: #1a1b1e;
  --mantine-text-secondary: #868e96;
  --mantine-red: #fa5252;
  --mantine-red-light: #fff5f5;
  --mantine-green: #40c057;
  --mantine-green-light: #ebfbee;
  --mantine-yellow: #fab005;
  --mantine-yellow-light: #fff9db;
  --mantine-radius-sm: 4px;
  --mantine-radius: 8px;
  --mantine-radius-lg: 12px;
  --mantine-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --mantine-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --mantine-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --mantine-font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

body {
  font-family: var(--mantine-font-family);
  background: var(--mantine-gray-0);
  color: var(--mantine-text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ══════════════ Login ══════════════ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--mantine-gray-0);
  padding: 16px;
}

.login-card {
  background: #fff;
  border: 1px solid var(--mantine-gray-2);
  border-radius: var(--mantine-radius-lg);
  padding: 44px 40px 36px;
  width: 408px;
  max-width: 100%;
  box-shadow: var(--mantine-shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo-img {
  max-width: 240px;
  height: auto;
  margin-bottom: 16px;
  display: inline-block;
}

.topbar-logo {
  height: 36px;
  width: auto;
  filter: brightness(10);
  opacity: .9;
}

.login-header p {
  color: var(--mantine-text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--mantine-text-secondary);
}

.login-footer a {
  color: var(--mantine-primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}

.login-footer a:hover {
  color: var(--mantine-primary-hover);
}

.btn-full {
  width: 100%;
  height: 42px !important;
  font-size: 15px !important;
}

/* ══════════════ Form Fields (Login) ══════════════ */

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--mantine-gray-7);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--mantine-gray-3);
  border-radius: var(--mantine-radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--mantine-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--mantine-primary-shadow);
}

.field input::placeholder {
  color: var(--mantine-gray-5);
}

/* ══════════════ Message ══════════════ */

.msg {
  padding: 10px 14px;
  border-radius: var(--mantine-radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
  line-height: 1.5;
}

.msg.show {
  display: block;
}

.msg.error {
  background: var(--mantine-red-light);
  color: var(--mantine-red);
  border: 1px solid #ffe3e3;
}

.msg.success {
  background: var(--mantine-green-light);
  color: #2f9e44;
  border: 1px solid #d3f9d8;
}

/* ══════════════ Topbar ══════════════ */

.topbar {
  background: var(--mantine-dark);
  color: #fff;
  padding: 0 32px;
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar p {
  font-size: 12px;
  color: var(--mantine-gray-5);
  margin-top: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  font-size: 13px;
  color: var(--mantine-gray-4);
  display: flex;
  align-items: center;
  gap: 6px;
}

.role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: var(--mantine-yellow);
  color: var(--mantine-dark);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ══════════════ Buttons ══════════════ */

button {
  border: 0;
  border-radius: var(--mantine-radius-sm);
  padding: 0 16px;
  height: 36px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
}

button.primary {
  background: var(--mantine-primary);
  color: #fff;
}

button.primary:hover {
  background: var(--mantine-primary-hover);
}

button.secondary {
  background: #fff;
  color: var(--mantine-gray-7);
  border: 1px solid var(--mantine-gray-3);
}

button.secondary:hover {
  background: var(--mantine-gray-1);
}

button.danger {
  background: var(--mantine-red-light);
  color: var(--mantine-red);
}

button.danger:hover {
  background: #ffe3e3;
}
button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ══════════════ Main Layout ══════════════ */

main {
  padding: 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ══════════════ Dashboard Cards ══════════════ */

.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: #fff;
  border: 1px solid var(--mantine-gray-2);
  border-radius: var(--mantine-radius);
  padding: 20px 24px;
  transition: box-shadow 0.15s;
}

.card:hover {
  box-shadow: var(--mantine-shadow);
}

.card span {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--mantine-text);
  line-height: 1.2;
  letter-spacing: -1px;
}

.card label {
  color: var(--mantine-text-secondary);
  font-size: 13px;
  margin-top: 6px;
  display: block;
  font-weight: 500;
}

/* ══════════════ Panel (Table Container) ══════════════ */

.panel {
  background: #fff;
  border: 1px solid var(--mantine-gray-2);
  border-radius: var(--mantine-radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}

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

.panel-title h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--mantine-text);
}

.toolbar {
  display: flex;
  gap: 8px;
}

/* ══════════════ Filters Bar ══════════════ */

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters input {
  width: 220px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--mantine-gray-3);
  border-radius: var(--mantine-radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--mantine-gray-0);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filters input:focus {
  border-color: var(--mantine-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--mantine-primary-shadow);
  background: #fff;
}

.filters input::placeholder {
  color: var(--mantine-gray-5);
}

.filters select {
  width: 160px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--mantine-gray-3);
  border-radius: var(--mantine-radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--mantine-gray-0);
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23868e96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.filters select:focus {
  border-color: var(--mantine-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--mantine-primary-shadow);
  background-color: #fff;
}

/* ══════════════ Table ══════════════ */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--mantine-radius-sm);
  border: 1px solid var(--mantine-gray-2);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  background: var(--mantine-gray-0);
  color: var(--mantine-gray-7);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--mantine-gray-2);
  position: sticky;
  top: 0;
}

td {
  border-bottom: 1px solid var(--mantine-gray-1);
}

td small {
  color: var(--mantine-gray-5);
  font-size: 12px;
}

tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: var(--mantine-gray-0);
}

.td-date {
  white-space: nowrap;
  font-size: 12px;
  color: var(--mantine-gray-5);
}

.ops {
  white-space: nowrap;
}

.ops button {
  margin-right: 4px;
  font-size: 12px;
  height: 30px;
  padding: 0 12px;
}

.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--mantine-gray-5);
  padding: 12px 4px 0;
}
.page-controls { display: flex; gap: 6px; }
.page-btn {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
  background: var(--mantine-gray-0);
  color: var(--mantine-gray-7);
  border: 1px solid var(--mantine-gray-3);
}
.page-btn:hover { background: var(--mantine-primary); color: #fff; border-color: var(--mantine-primary); }

.empty {
  text-align: center;
  color: var(--mantine-gray-5);
  padding: 64px 0 !important;
  font-size: 14px;
}

/* ══════════════ Tags & Badges ══════════════ */

.level-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.level-普通 {
  background: var(--mantine-gray-1);
  color: var(--mantine-gray-6);
}

.level-重点 {
  background: var(--mantine-yellow-light);
  color: #e67700;
}

.level-核心 {
  background: var(--mantine-red-light);
  color: #e03131;
}

.stage-tag {
  display: inline-block;
  font-size: 12px;
  color: var(--mantine-gray-7);
  font-weight: 500;
}

/* vendor row cursor */
.vendor-row {
  cursor: pointer;
}

/* ══════════════ Modal ══════════════ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--mantine-radius-lg);
  width: 800px;
  max-width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--mantine-shadow-lg);
}

.modal-detail {
  width: 640px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--mantine-text);
}

.modal-close {
  width: 32px;
  height: 32px;
  background: var(--mantine-gray-0);
  color: var(--mantine-gray-6);
  border-radius: var(--mantine-radius-sm);
  font-size: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 1px solid transparent;
}

.modal-close:hover {
  background: var(--mantine-gray-1);
  color: var(--mantine-text);
}

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 0 28px 24px;
}

/* ══════════════ Form in Modal ══════════════ */

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--mantine-gray-7);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--mantine-gray-3);
  border-radius: var(--mantine-radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23868e96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-group select:disabled {
  background-color: var(--mantine-gray-0);
  color: var(--mantine-gray-5);
  cursor: not-allowed;
}

.form-group textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--mantine-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--mantine-primary-shadow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--mantine-gray-5);
}

/* ══════════════ Detail View ══════════════ */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-item.full {
  grid-column: 1 / -1;
}

.detail-item label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--mantine-gray-5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.detail-item span {
  font-size: 14px;
  color: var(--mantine-text);
  line-height: 1.5;
}

/* ══════════════ Batch Bar ══════════════ */

.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--mantine-primary-light);
  border-radius: var(--mantine-radius-sm);
  margin-bottom: 12px;
  font-size: 13px;
}
.batch-bar #batchCount { font-weight: 600; color: var(--mantine-primary); margin-right: auto; }
.batch-bar button { height: 32px; font-size: 12px; }

/* ══════════════ Checkbox Column ══════════════ */

.col-check { width: 40px; text-align: center; }
.col-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--mantine-primary); }

/* ══════════════ Detail Tabs ══════════════ */

.detail-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--mantine-gray-2); margin-bottom: 16px; }
.dtab { padding: 8px 16px; font-size: 13px; background: none; color: var(--mantine-gray-5); border: 0; border-bottom: 2px solid transparent; cursor: pointer; height: auto; }
.dtab.active { color: var(--mantine-primary); border-bottom-color: var(--mantine-primary); font-weight: 600; }
.dtab:hover { color: var(--mantine-text); }

/* ══════════════ File Upload ══════════════ */

.file-upload-area { padding: 12px 0; }
.file-upload-area form { display: flex; gap: 10px; align-items: center; }
.file-upload-area input[type=file] { flex: 1; font-size: 13px; }
.file-list { margin-top: 8px; max-height: 360px; overflow-y: auto; }
.file-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--mantine-gray-1); }
.file-item:last-child { border-bottom: 0; }
.file-info { display: flex; flex-direction: column; gap: 2px; }
.file-name { font-size: 13px; font-weight: 600; color: var(--mantine-text); }
.file-meta { font-size: 11px; color: var(--mantine-gray-5); }
.file-item button { height: 30px; font-size: 12px; }

/* ══════════════ Vendor History ══════════════ */

.history-list { max-height: 400px; overflow-y: auto; }
.history-item { padding: 10px 0; border-bottom: 1px solid var(--mantine-gray-1); }
.history-item:last-child { border-bottom: 0; }
.history-meta { font-size: 12px; color: var(--mantine-gray-6); margin-bottom: 4px; }
.history-diff { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.history-diff .old { color: var(--mantine-red); text-decoration: line-through; }
.history-diff .arrow { color: var(--mantine-gray-5); }
.history-diff .new { color: var(--mantine-green); font-weight: 600; }
.history-time { font-size: 11px; color: var(--mantine-gray-5); margin-top: 2px; }

/* ══════════════ Charts ══════════════ */

.chart-panel { display: none; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-box { background: var(--mantine-gray-0); border-radius: var(--mantine-radius); padding: 16px; }
.chart-box canvas { max-height: 260px; max-width: 100%; }

/* ══════════════ Footer ══════════════ */

footer {
  text-align: center;
  padding: 20px 16px 24px;
  font-size: 12px;
  color: var(--mantine-gray-5);
}

/* ══════════════ Responsive ══════════════ */

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    height: auto;
    padding: 16px;
    text-align: center;
  }

  .topbar h1 {
    font-size: 16px;
  }

  main {
    padding: 16px;
  }

  .dashboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .filters input {
    width: 100%;
  }

  .filters select {
    width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal {
    width: 100%;
  }

  .modal-body {
    padding: 16px 20px;
  }

  .modal-header {
    padding: 20px 20px 0;
  }

  .modal-footer {
    padding: 0 20px 20px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
