:root {
  --et-primary: #079455;
  --et-primary-dark: #067647;
  --et-primary-soft: #ecfdf3;
  --et-ink: #101828;
  --et-muted: #667085;
  --et-border: #e4e7ec;
  --et-canvas: #f8fafc;
  --et-surface: #ffffff;
  --et-shadow: 0 18px 48px rgba(16, 24, 40, .09);
}

.excel-table-module {
  position: relative;
  width: 100%;
  margin: 0 0 24px;
  overflow: visible;
  border: 1px solid var(--et-border);
  border-radius: 22px;
  background: var(--et-surface);
  box-shadow: var(--et-shadow);
  color: var(--et-ink);
}

.excel-table-module.et-embedded {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.excel-table-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid #eef1f4;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
}

.excel-table-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  color: var(--et-primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.excel-table-kicker::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--et-primary);
  box-shadow: 0 0 0 5px rgba(7, 148, 85, .10);
}

.excel-table-title {
  margin: 0;
  color: #172b4d;
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 850;
  line-height: 1.2;
}

.excel-table-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
  color: var(--et-muted);
  font-size: 13px;
}

.excel-table-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.excel-table-meta strong { color: #344054; }

.excel-table-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.excel-table-stat {
  min-width: 92px;
  padding: 10px 14px;
  border: 1px solid #d1fadf;
  border-radius: 14px;
  color: #475467;
  background: linear-gradient(145deg, #fff, #f0fdf4);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.excel-table-stat b {
  display: block;
  color: var(--et-primary-dark);
  font-size: 18px;
  line-height: 1.15;
}

.excel-table-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.65fr) repeat(2, minmax(170px, .8fr)) repeat(2, minmax(150px, .7fr));
  gap: 14px;
  align-items: end;
  padding: 18px 24px;
  border-bottom: 1px solid var(--et-border);
  background: #fff;
}

.excel-table-toolbar.et-no-period {
  grid-template-columns: minmax(260px, 1.7fr) repeat(2, minmax(180px, .85fr));
}

.excel-table-field {
  min-width: 0;
}

.excel-table-field > label {
  display: block;
  margin: 0 0 7px;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.excel-table-search-wrap { position: relative; }
.excel-table-search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-52%);
  color: #667085;
  font-size: 20px;
  line-height: 1;
  pointer-events: none;
}

.excel-table-control {
  width: 100%;
  min-height: 46px;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  padding: 10px 13px;
  color: #344054;
  background-color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .025);
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.excel-table-search { padding-left: 45px; }
.excel-table-control:hover { border-color: #98a2b3; }
.excel-table-control:focus {
  border-color: var(--et-primary);
  box-shadow: 0 0 0 4px rgba(7, 148, 85, .11);
}

.excel-table-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.excel-table-actions > .excel-table-control {
  width: 92px !important;
  flex: 0 0 92px;
}

.excel-table-btn,
.excel-table-page-btn {
  min-height: 42px;
  border: 1px solid #d0d5dd;
  border-radius: 11px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #344054;
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
  transition: transform .16s ease, border-color .16s ease, background-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.excel-table-btn:hover,
.excel-table-page-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #98a2b3;
  background: #f9fafb;
  box-shadow: 0 5px 14px rgba(16, 24, 40, .08);
}

.excel-table-btn.et-primary {
  border-color: var(--et-primary);
  color: #fff;
  background: linear-gradient(135deg, #039855, #079455);
  box-shadow: 0 8px 18px rgba(7, 148, 85, .20);
}

.excel-table-column-menu { position: relative; }
.excel-table-column-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 100;
  display: none;
  width: min(360px, calc(100vw - 32px));
  max-height: 330px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--et-border);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .16);
}

.excel-table-column-panel.is-open {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.excel-table-column-panel label {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #eaecf0;
  border-radius: 10px;
  color: #344054;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.excel-table-column-panel input { accent-color: var(--et-primary); }

.excel-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  background: #fff;
  scrollbar-width: thin;
  scrollbar-color: #98a2b3 #f2f4f7;
}

.excel-table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.excel-table-scroll::-webkit-scrollbar-track { background: #f2f4f7; }
.excel-table-scroll::-webkit-scrollbar-thumb { background: #98a2b3; border: 2px solid #f2f4f7; border-radius: 999px; }

.excel-table {
  width: 100%;
  margin: 0 !important;
  border-collapse: separate;
  border-spacing: 0;
  color: #344054;
}

.excel-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 14px 15px;
  border-top: 0;
  border-bottom: 1px solid #d0d5dd;
  color: #344054;
  background: linear-gradient(180deg, #f0fdf4 0%, #eaf8ef 100%) !important;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  vertical-align: middle;
}

.excel-table tbody td,
.excel-table tfoot td {
  padding: 13px 15px;
  border-color: #eef1f4;
  vertical-align: middle;
}

.excel-table tbody tr { transition: background-color .15s ease, box-shadow .15s ease; }
.excel-table tbody tr:hover { background: #fbfefc; }
.excel-table tbody tr.is-selected { background: #ecfdf3 !important; box-shadow: inset 4px 0 0 var(--et-primary); }
.excel-table tbody tr:nth-child(even) { background-color: #fcfdfd; }

.excel-table-sort {
  display: inline-block;
  margin-left: 6px;
  color: #667085;
  font-size: 11px;
}

.excel-table-col-hidden,
.excel-table-row-hidden { display: none !important; }

.excel-table-summary-row td {
  font-weight: 800;
  background: #f8fafc;
}
.excel-table-subtotal td { color: #344054; }
.excel-table-grand-total td { color: var(--et-primary-dark); background: #ecfdf3; }
.excel-table-summary-label { text-transform: uppercase; letter-spacing: .03em; }

.excel-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--et-border);
  background: #fbfcfd;
}

.excel-table-footer-info {
  color: var(--et-muted);
  font-size: 13px;
}

.excel-table-footer-info strong { color: #344054; }

.excel-table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.excel-table-page-btn {
  min-width: 38px;
  min-height: 38px;
  padding: 0 10px;
}

.excel-table-page-btn.is-active {
  border-color: var(--et-primary);
  color: #fff;
  background: var(--et-primary);
}

.excel-table-page-btn:disabled { opacity: .45; cursor: not-allowed; }

.excel-table-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99999;
  max-width: min(360px, calc(100vw - 32px));
  padding: 13px 16px;
  border-radius: 13px;
  color: #fff;
  background: #101828;
  box-shadow: 0 20px 48px rgba(16, 24, 40, .25);
  font-size: 13px;
  font-weight: 750;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.excel-table-toast.is-visible { opacity: 1; transform: none; }

/* Product spreadsheet integration */
.pm-sheet-card .excel-table-module {
  border: 0;
  border-radius: 0 0 20px 20px;
  box-shadow: none;
}
.pm-sheet-card .excel-table-top { padding-top: 18px; }
.pm-sheet-card .excel-table-scroll { max-height: 72vh; }
.pm-sheet-card .excel-table.excel-table { min-width: 1500px; }
.pm-sheet-card .excel-table-toolbar { background: #fbfdfc; }

/* Delivery page integration */
.ii-table-wrap.excel-table-scroll {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.ii-page .excel-table-module {
  overflow: hidden;
  border-color: rgba(209, 250, 229, .95);
}
.ii-page .excel-table-title { color: #0f3d34; }
.ii-page .excel-table-scroll { max-height: 620px; }
.ii-page .excel-table tbody td { min-width: 180px; }

@media (max-width: 1199.98px) {
  .excel-table-toolbar,
  .excel-table-toolbar.et-no-period {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .excel-table-field.et-search-field { grid-column: 1 / -1; }
}

@media (max-width: 767.98px) {
  .excel-table-module {
    border-radius: 16px;
    margin-bottom: 18px;
  }
  .excel-table-top {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 16px 15px;
  }
  .excel-table-title { font-size: 21px; }
  .excel-table-stats { width: 100%; justify-content: flex-start; }
  .excel-table-stat { min-width: 82px; flex: 1 1 82px; }
  .excel-table-toolbar,
  .excel-table-toolbar.et-no-period {
    grid-template-columns: 1fr;
    padding: 15px 16px;
  }
  .excel-table-field.et-search-field { grid-column: auto; }
  .excel-table-actions {
    justify-content: stretch;
    gap: 8px;
  }
  .excel-table-actions > .excel-table-control {
    width: 100% !important;
    flex: 1 1 100%;
  }
  .excel-table-column-menu { flex: 1 1 calc(50% - 4px); }
  .excel-table-column-menu > .excel-table-btn { width: 100%; }
  .excel-table-actions > .excel-table-btn { flex: 1 1 calc(50% - 4px); }
  .excel-table-column-panel.is-open { grid-template-columns: 1fr; }
  .excel-table-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }
  .excel-table-pagination { justify-content: flex-start; }
  .excel-table thead th,
  .excel-table tbody td,
  .excel-table tfoot td { padding: 11px 12px; }
}

@media print {
  .excel-table-toolbar,
  .excel-table-footer,
  .excel-table-column-panel,
  .excel-table-toast { display: none !important; }
  .excel-table-module { border: 0; box-shadow: none; }
  .excel-table-scroll { overflow: visible !important; max-height: none !important; }
  .excel-table-row-hidden { display: table-row !important; }
  .excel-table-col-hidden { display: table-cell !important; }
}
