/* ==========================================================
   In-page sheet - a spreadsheet that lives in the dashboard
   instead of an embedded Google Sheet.
   ========================================================== */

.sheet-table-wrap {
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #1f2d3d;
}

/* ---------- toolbar ---------- */

.sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #f1f5f9;
  border-radius: 10px;
}

.sheet-toolbar button {
  border: none;
  border-radius: 7px;
  padding: 8px 13px;
  font-size: 0.9em;
  font-weight: 600;
  color: #fff;
  background: #174a6c;
  cursor: pointer;
}

.sheet-toolbar button:hover {
  background: #0f3552;
}

.sheet-toolbar button[data-act="import"] {
  background: #2f9e5c;
}

.sheet-toolbar button[data-act="reset"] {
  background: #6b7c8c;
}

.sheet-toolbar .sheet-search {
  flex: 1 1 180px;
  min-width: 140px;
  border: 1px solid #d8e0e8;
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 0.9em;
  font-family: inherit;
}

.sheet-toolbar .sheet-status {
  flex: 1 1 100%;
  color: #64748b;
  font-size: 0.84em;
}

/* ---------- grid ---------- */

.sheet-scroll {
  overflow-x: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

table.sheet-grid {
  border-collapse: collapse;
  /* Fixed layout honours the widths exactly, so a column can be dragged
     narrower than its heading - the text simply clips. */
  table-layout: fixed;
  width: auto;
  font-size: 0.85em;
}

table.sheet-grid th,
table.sheet-grid td {
  border: 1px solid #e2e8f0;
  padding: 0;
  vertical-align: top;
  overflow: hidden;
}

table.sheet-grid thead th {
  position: relative;
  background: #f8fafc;
  font-weight: 700;
  font-size: 0.92em;
  letter-spacing: 0.02em;
  color: #334155;
  white-space: nowrap;
}

.sheet-th-inner {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 8px 6px;
  min-width: 0;
  overflow: hidden;
}

.sheet-th-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-col-menu-btn {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.9em;
  line-height: 1;
}

.sheet-col-menu-btn:hover {
  color: #174a6c;
}

/* drag handle for column width */
.sheet-col-resize {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}

table.sheet-grid tbody td {
  cursor: cell;
}

.sheet-cell {
  display: block;
  min-height: 1.2em;
  padding: 7px 9px;
  white-space: pre-wrap;
  word-break: break-word;
}

table.sheet-grid tbody tr:nth-child(even) {
  background: #fbfdff;
}

table.sheet-grid tbody tr:hover {
  background: #eef4fa;
}

.sheet-cell-input {
  width: 100%;
  box-sizing: border-box;
  border: 2px solid #2d7ff9;
  border-radius: 3px;
  padding: 5px 7px;
  font-size: 1em;
  font-family: inherit;
  color: #1f2d3d;
}

/* row number + delete */
.sheet-rownum {
  width: 44px;
  background: #f8fafc;
  color: #94a3b8;
  font-size: 0.85em;
  text-align: center;
  user-select: none;
}

.sheet-rownum .sheet-row-del {
  border: none;
  background: transparent;
  color: #d9534f;
  cursor: pointer;
  font-size: 1.05em;
  line-height: 1;
  padding: 0 2px;
}

.sheet-addcol-btn {
  border: none;
  background: transparent;
  color: #174a6c;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 10px;
  white-space: nowrap;
}

.sheet-empty {
  padding: 28px;
  text-align: center;
  color: #8a97a5;
}

/* ---------- column menu ---------- */

.sheet-col-menu {
  position: absolute;
  z-index: 1500;
  min-width: 180px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  padding: 6px;
}

.sheet-col-menu button {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 0.9em;
  font-weight: 600;
  color: #1f2d3d;
  text-align: left;
  cursor: pointer;
}

.sheet-col-menu button:hover {
  background: #eef4fa;
}

.sheet-col-menu button[data-act="delete-col"] {
  color: #d9534f;
}

/* ---------- visible controls, drag handles, fit mode ---------- */

.sheet-rownum {
  width: 54px;
  cursor: grab;
  white-space: nowrap;
}

.sheet-rownum .sheet-row-index {
  margin-right: 2px;
}

.sheet-col-del {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: #d9534f;
  cursor: pointer;
  padding: 0 2px;
  font-size: 1.05em;
  line-height: 1;
}

.sheet-col-del:hover {
  color: #a3302d;
}

.sheet-drag-handle {
  flex: 0 0 auto;
  color: #b6c2ce;
  cursor: grab;
  font-size: 0.9em;
  line-height: 1;
  user-select: none;
}

table.sheet-grid th[draggable="true"]:active .sheet-drag-handle,
.sheet-rownum:active {
  cursor: grabbing;
}

/* where the dragged column or row will land */
.sheet-drop-target {
  outline: 2px solid #2d7ff9;
  outline-offset: -2px;
  background: #e8f1fe !important;
}

