  :root {
  --btn-bg: #1188ff;
  --btn-text: #fff;
  --accent: #28a745;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* Trigger button */
.open-modal-btn {
  background: none;
  color: #000;
  border: 0;
  padding: 10px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
  box-shadow: 1px 1px 12px #ddd;
  transition: 0.2s;
  -webkit-transition: 0.2s;
}
.open-modal-btn:hover {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 0;
  padding: 10px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
  transition: 0.2s;
  -webkit-transition: 0.2s;
}

/* Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  z-index: 9998;
}
.modal-overlay.open { display: block; }

/* Modal wrapper */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }

/* Card */
.modal-card {
  position: relative; /* for absolutely positioned close button */
  background: #fff;
  width: min(640px, 92vw);
  max-height: 80vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  transform: translateY(6px) scale(0.98);
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
}
.modal.open .modal-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Header */
.modal-header {
  padding: 16px 56px 16px 18px; /* extra right padding for X button space */
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
}
.modal-title {
  font-size: 16px;
  font-weight: 400;
  margin: 0;
}

/* Close (X) button */
.close-btn {
  position: absolute;
  margin: 0;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #555;
}
.close-btn:hover {
  background: rgba(0,0,0,0.06);
  color: #000;
}
.close-btn:focus-visible {
  outline: 2px solid #0b63b6;
  outline-offset: 2px;
}

/* Body */
.modal-body {
  padding: 10px 18px;
  overflow: auto; /* scroll inside, not page */
}

/* File rows */
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.file-item:last-child { border-bottom: 0; }

.file-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
}

.file-name {
  font-size: 14px;
  color: #0b63b6;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-sub {
  font-size: 12px;
  color: #666;
}


/* Container */
.file-table-wrap {
  margin-top: 8px;
  overflow: auto;
  border: 1px solid #eee;
  border-radius: 8px;
}

/* Table uses auto layout so content drives widths */
.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  table-layout: auto; /* important */
}

/* Column sizing via colgroup:
   - Name fills remaining space
   - Type/Size/Actions shrink to min needed */
.file-table col.col-name   { width: auto; }
.file-table col.col-type,
.file-table col.col-size,
.file-table col.col-actions { width: 1%; }  /* forces minimal width */

.file-table thead th {
  text-align: left;
  background: #fafafa;
  color: #333;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap; /* keeps headers tight */
}

.file-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f3f3;
  vertical-align: middle;
}

.file-table tbody tr:last-child td {
  border-bottom: none;
}

/* Keep Type & Size tight */
.file-table td:nth-child(2),
.file-table th:nth-child(2),
.file-table td:nth-child(3),
.file-table th:nth-child(3),
.file-table td:nth-child(4),
.file-table th:nth-child(4) {
  white-space: nowrap;
  text-align: center;
}

/* Type column */
.file-table col.col-type {
  width: 1%;
  min-width: 70px;  /* tweak as needed */
}

/* Size column */
.file-table col.col-size {
  width: 1%;
  min-width: 80px;  /* tweak as needed */
}

/* Download column */
.file-table col.col-actions {
  width: 1%;
  min-width: 60px;  /* tweak as needed for the icon button */
}

/* Filename stretches, with ellipsis */
.cell-name { width: auto; }
.name-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Actions column: narrow & right-aligned */
.cell-action { text-align: right; }

/* Icon button base */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;   /* transparent background by default */
  color: #444;               /* icon color (black/gray) */
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

/* SVG inside button */
.icon-btn .download-icon {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;      /* important: SVG path uses the parent button color */
  fill: none;
}

/* Hover/focus state */
.icon-btn:hover,
.icon-btn:focus-visible {
  background: #e9f5ff;       /* light blue background */
  color: #0b63b6;            /* icon turns blue */
}

.icon-btn:focus-visible {
  outline: 2px solid #0b63b6;
  outline-offset: 2px;
}



/* Compact download button */
.modal .file-item .download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto !important;
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

/* Prevent body scroll when modal is open */
.no-scroll { overflow: hidden; }
